Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use actual prefab rotation inside brush prefab #273

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Alireza-Ta
Copy link

If you paint a grid with a brush prefab it doesn't use prefab's rotation, instead it uses m_Rotation which is set to default and ignores the rotation.

@unity-cla-assistant
Copy link

unity-cla-assistant commented Feb 24, 2021

CLA assistant check
All committers have signed the CLA.

@@ -46,7 +46,8 @@ public override void Paint(GridLayout grid, GameObject brushTarget, Vector3Int p
{
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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants