|
1 | | -using UnityEditor; |
| 1 | +using UnityEditor; |
2 | 2 | using UnityEngine; |
3 | 3 | using System.Collections.Generic; |
4 | 4 | using InternalRealtimeCSG; |
@@ -172,10 +172,26 @@ void EnableVisualObjects() |
172 | 172 | { |
173 | 173 | if (obj == null || !obj) |
174 | 174 | 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); |
179 | 195 | obj.transform.SetSiblingIndex(hoverSiblingIndex + counter); |
180 | 196 | counter++; |
181 | 197 | } |
|
0 commit comments