Skip to content

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.

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