Use actual prefab rotation inside brush prefab#273
Open
Alireza-Ta wants to merge 1 commit intoUnity-Technologies:masterfrom
Open
Use actual prefab rotation inside brush prefab#273Alireza-Ta wants to merge 1 commit intoUnity-Technologies:masterfrom
Alireza-Ta wants to merge 1 commit intoUnity-Technologies:masterfrom
Conversation
| var objectsInCell = GetObjectsInCell(grid, brushTarget.transform, position); | ||
| var existPrefabObjectInCell = objectsInCell.Any(objectInCell => PrefabUtility.GetCorrespondingObjectFromSource(objectInCell) == m_Prefab); | ||
|
|
||
| m_Rotation = Quaternion.Euler(m_Prefab.transform.eulerAngles); |
Collaborator
There was a problem hiding this comment.
m_Rotation stores the rotation of the brush which can be changed using the rotation hot-keys. This will always override this stored rotation.
We could keep both rotations with the following code:
Suggested change
| m_Rotation = Quaternion.Euler(m_Prefab.transform.eulerAngles); | |
| m_Rotation = Quaternion.Euler(m_Prefab.transform.eulerAngles); |
Suggested change
| m_Rotation = Quaternion.Euler(m_Prefab.transform.eulerAngles); | |
| var rotation = Quaternion.Euler(m_Prefab.transform.eulerAngles) * m_Rotation; | |
| if (!existPrefabObjectInCell) | |
| { | |
| base.InstantiatePrefabInCell(grid, brushTarget, position, m_Prefab, rotation); | |
| } |
Would this be better and still suit your use-case?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If you paint a grid with a brush prefab it doesn't use prefab's rotation, instead it uses
m_Rotationwhich is set todefaultand ignores the rotation.