Răsfoiți Sursa

[unity] 2018.3 prefab handling for scene components and inspectors.

pharan 6 ani în urmă
părinte
comite
80272fb719

+ 10 - 0
spine-unity/Assets/Spine/Editor/spine-unity/Editor/SkeletonDebugWindow.cs

@@ -30,6 +30,12 @@
 
 // With contributions from: Mitch Thompson
 
+#if UNITY_2018_3 || UNITY_2019
+#define NEW_PREFAB_SYSTEM
+#else
+#define NO_PREFAB_MESH
+#endif
+
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEditor;
@@ -122,7 +128,11 @@ namespace Spine.Unity.Editor {
 					skeletonRenderer.Initialize(false);
 					skeletonRenderer.LateUpdate();
 					skeleton = skeletonRenderer.skeleton;
+#if NEW_PREFAB_SYSTEM
+					isPrefab = false;
+#else
 					isPrefab |= PrefabUtility.GetPrefabType(selectedObject) == PrefabType.Prefab;
+#endif
 					UpdateAttachments();
 				}
 			} 

+ 8 - 0
spine-unity/Assets/Spine/Editor/spine-unity/Editor/SkeletonRendererInspector.cs

@@ -28,7 +28,11 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *****************************************************************************/
 
+#if UNITY_2018_3 || UNITY_2019
+#define NEW_PREFAB_SYSTEM
+#else
 #define NO_PREFAB_MESH
+#endif
 
 using UnityEditor;
 using System.Collections.Generic;
@@ -81,7 +85,11 @@ namespace Spine.Unity.Editor {
 		}
 
 		protected virtual void OnEnable () {
+#if NEW_PREFAB_SYSTEM
+			isInspectingPrefab = false;
+#else
 			isInspectingPrefab = (PrefabUtility.GetPrefabType(target) == PrefabType.Prefab);
+#endif
 
 			SpineEditorUtilities.ConfirmInitialization();
 

+ 10 - 0
spine-unity/Assets/Spine/Editor/spine-unity/Modules/BoundingBoxFollower/Editor/BoundingBoxFollowerInspector.cs

@@ -28,6 +28,10 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *****************************************************************************/
 
+#if UNITY_2018_3 || UNITY_2019
+#define NEW_PREFAB_SYSTEM
+#endif
+
 using UnityEngine;
 using UnityEditor;
 
@@ -61,7 +65,11 @@ namespace Spine.Unity.Editor {
 		}
 
 		public override void OnInspectorGUI () {
+			#if !NEW_PREFAB_SYSTEM
 			bool isInspectingPrefab = (PrefabUtility.GetPrefabType(target) == PrefabType.Prefab);
+			#else
+			bool isInspectingPrefab = false;
+			#endif
 
 			// Try to auto-assign SkeletonRenderer field.
 			if (skeletonRenderer.objectReferenceValue == null) {
@@ -94,8 +102,10 @@ namespace Spine.Unity.Editor {
 			EditorGUILayout.PropertyField(slotName, new GUIContent("Slot"));
 			if (EditorGUI.EndChangeCheck()) {
 				serializedObject.ApplyModifiedProperties();
+				#if !NEW_PREFAB_SYSTEM
 				if (!isInspectingPrefab)
 					rebuildRequired = true;
+				#endif
 			}
 
 			using (new SpineInspectorUtility.LabelWidthScope(150f)) {

+ 11 - 1
spine-unity/Assets/Spine/Editor/spine-unity/SkeletonUtility/Editor/SkeletonUtilityInspector.cs

@@ -28,7 +28,9 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *****************************************************************************/
 
-// Contributed by: Mitch Thompson
+#if UNITY_2018_3 || UNITY_2019
+#define NEW_PREFAB_SYSTEM
+#endif
 
 using UnityEngine;
 using UnityEditor;
@@ -46,7 +48,11 @@ namespace Spine.Unity.Editor {
 		SkeletonUtility skeletonUtility;
 		Skeleton skeleton;
 		SkeletonRenderer skeletonRenderer;
+		
+		#if !NEW_PREFAB_SYSTEM
 		bool isPrefab;
+		#endif
+
 		readonly GUIContent SpawnHierarchyButtonLabel = new GUIContent("Spawn Hierarchy", Icons.skeleton);
 
 		void OnEnable () {
@@ -62,14 +68,18 @@ namespace Spine.Unity.Editor {
 
 			if (!skeletonRenderer.valid) return;
 
+			#if !NEW_PREFAB_SYSTEM
 			isPrefab |= PrefabUtility.GetPrefabType(this.target) == PrefabType.Prefab;
+			#endif
 		}
 			
 		public override void OnInspectorGUI () {
+			#if !NEW_PREFAB_SYSTEM
 			if (isPrefab) {
 				GUILayout.Label(new GUIContent("Cannot edit Prefabs", Icons.warning));
 				return;
 			}
+			#endif
 
 			if (!skeletonRenderer.valid) {
 				GUILayout.Label(new GUIContent("Spine Component invalid. Check Skeleton Data Asset.", Icons.warning));