Skip to content

Commit c1d995d

Browse files
author
Sander van Rossen
committed
drag & dropping non brush prefabs will now use it's scale and rotation
1 parent 26473b3 commit c1d995d

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

RealtimeCSG/Assets/Plugins/RealtimeCSG/API/Foundation/Editor/Version.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace RealtimeCSG.Foundation
22
{
33
internal static class Versioning
44
{
5-
public const string PluginVersion = "1_565";
5+
public const string PluginVersion = "1_566";
66
public const string PluginDLLVersion = "1_559";
77
}
88
}

RealtimeCSG/Assets/Plugins/RealtimeCSG/Editor/Scripts/View/DragAndDrop/SceneDragTool.Meshes.cs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using UnityEditor;
1+
using UnityEditor;
22
using UnityEngine;
33
using System.Collections.Generic;
44
using InternalRealtimeCSG;
@@ -172,10 +172,26 @@ void EnableVisualObjects()
172172
{
173173
if (obj == null || !obj)
174174
continue;
175-
obj.transform.rotation = hoverRotation;
176-
obj.transform.position = hoverPosition;
177-
// if (hoverParent != null && !CSGPrefabUtility.IsPrefabAsset(hoverParent.gameObject))
178-
// obj.transform.SetParent(hoverParent, true);
175+
var scale = Vector3.one;
176+
var rotation = hoverRotation;
177+
var position = hoverPosition;
178+
#if UNITY_2018_3_OR_NEWER
179+
if (CSGPrefabUtility.IsPrefabInstance(obj))
180+
{
181+
var outer = CSGPrefabUtility.GetOutermostPrefabInstanceRoot(obj);
182+
var prefabAsset = CSGPrefabUtility.GetPrefabAsset(outer);
183+
var transform = prefabAsset.transform;
184+
185+
rotation *= transform.localRotation;
186+
//position += transform.localPosition;
187+
scale = transform.localScale;
188+
}
189+
#endif
190+
obj.transform.rotation = rotation;
191+
obj.transform.position = position;
192+
obj.transform.localScale = scale;
193+
// if (hoverParent != null && !CSGPrefabUtility.IsPrefabAsset(hoverParent.gameObject))
194+
// obj.transform.SetParent(hoverParent, true);
179195
obj.transform.SetSiblingIndex(hoverSiblingIndex + counter);
180196
counter++;
181197
}

0 commit comments

Comments
 (0)