Skip to content

Use actual prefab rotation inside brush prefab #273

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Editor/Brushes/PrefabBrushes/PrefabBrush/PrefabBrush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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?


if (!existPrefabObjectInCell)
{
base.InstantiatePrefabInCell(grid, brushTarget, position, m_Prefab, m_Rotation);
Expand Down