|
@@ -38,6 +38,10 @@
|
|
#define NEWPLAYMODECALLBACKS
|
|
#define NEWPLAYMODECALLBACKS
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+#if UNITY_2018_3 || UNITY_2019
|
|
|
|
+#define NEW_PREFAB_SYSTEM
|
|
|
|
+#endif
|
|
|
|
+
|
|
#if UNITY_2018 || UNITY_2019
|
|
#if UNITY_2018 || UNITY_2019
|
|
#define NEWHIERARCHYWINDOWCALLBACKS
|
|
#define NEWHIERARCHYWINDOWCALLBACKS
|
|
#endif
|
|
#endif
|
|
@@ -1274,7 +1278,7 @@ namespace Spine.Unity.Editor {
|
|
}
|
|
}
|
|
|
|
|
|
string spineGameObjectName = string.Format("Spine GameObject ({0})", skeletonDataAsset.name.Replace("_SkeletonData", ""));
|
|
string spineGameObjectName = string.Format("Spine GameObject ({0})", skeletonDataAsset.name.Replace("_SkeletonData", ""));
|
|
- GameObject go = new GameObject(spineGameObjectName, typeof(MeshFilter), typeof(MeshRenderer), typeof(SkeletonAnimation));
|
|
|
|
|
|
+ GameObject go = EditorInstantiation.NewGameObject(spineGameObjectName, typeof(MeshFilter), typeof(MeshRenderer), typeof(SkeletonAnimation));
|
|
SkeletonAnimation newSkeletonAnimation = go.GetComponent<SkeletonAnimation>();
|
|
SkeletonAnimation newSkeletonAnimation = go.GetComponent<SkeletonAnimation>();
|
|
newSkeletonAnimation.skeletonDataAsset = skeletonDataAsset;
|
|
newSkeletonAnimation.skeletonDataAsset = skeletonDataAsset;
|
|
TryInitializeSkeletonRendererSettings(newSkeletonAnimation, skin);
|
|
TryInitializeSkeletonRendererSettings(newSkeletonAnimation, skin);
|
|
@@ -1298,12 +1302,30 @@ namespace Spine.Unity.Editor {
|
|
|
|
|
|
return newSkeletonAnimation;
|
|
return newSkeletonAnimation;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /// <summary>Handles creating a new GameObject in the Unity Editor. This uses the new ObjectFactory API where applicable.</summary>
|
|
|
|
+ public static GameObject NewGameObject (string name) {
|
|
|
|
+ #if NEW_PREFAB_SYSTEM
|
|
|
|
+ return ObjectFactory.CreateGameObject(gameObjectName);
|
|
|
|
+ #else
|
|
|
|
+ return new GameObject(name);
|
|
|
|
+ #endif
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>Handles creating a new GameObject in the Unity Editor. This uses the new ObjectFactory API where applicable.</summary>
|
|
|
|
+ public static GameObject NewGameObject (string name, params System.Type[] components) {
|
|
|
|
+ #if NEW_PREFAB_SYSTEM
|
|
|
|
+ return ObjectFactory.CreateGameObject(gameObjectName, components);
|
|
|
|
+ #else
|
|
|
|
+ return new GameObject(name, components);
|
|
|
|
+ #endif
|
|
|
|
+ }
|
|
|
|
|
|
public static void InstantiateEmptySpineGameObject<T> (string name) where T : MonoBehaviour {
|
|
public static void InstantiateEmptySpineGameObject<T> (string name) where T : MonoBehaviour {
|
|
var parentGameObject = Selection.activeObject as GameObject;
|
|
var parentGameObject = Selection.activeObject as GameObject;
|
|
var parentTransform = parentGameObject == null ? null : parentGameObject.transform;
|
|
var parentTransform = parentGameObject == null ? null : parentGameObject.transform;
|
|
|
|
|
|
- var gameObject = new GameObject(name, typeof(T));
|
|
|
|
|
|
+ var gameObject = EditorInstantiation.NewGameObject(name, typeof(T));
|
|
gameObject.transform.SetParent(parentTransform, false);
|
|
gameObject.transform.SetParent(parentTransform, false);
|
|
EditorUtility.FocusProjectWindow();
|
|
EditorUtility.FocusProjectWindow();
|
|
Selection.activeObject = gameObject;
|
|
Selection.activeObject = gameObject;
|
|
@@ -1333,7 +1355,7 @@ namespace Spine.Unity.Editor {
|
|
}
|
|
}
|
|
|
|
|
|
string spineGameObjectName = string.Format("Spine Mecanim GameObject ({0})", skeletonDataAsset.name.Replace("_SkeletonData", ""));
|
|
string spineGameObjectName = string.Format("Spine Mecanim GameObject ({0})", skeletonDataAsset.name.Replace("_SkeletonData", ""));
|
|
- GameObject go = new GameObject(spineGameObjectName, typeof(MeshFilter), typeof(MeshRenderer), typeof(Animator), typeof(SkeletonMecanim));
|
|
|
|
|
|
+ GameObject go = EditorInstantiation.NewGameObject(spineGameObjectName, typeof(MeshFilter), typeof(MeshRenderer), typeof(Animator), typeof(SkeletonMecanim));
|
|
|
|
|
|
if (skeletonDataAsset.controller == null) {
|
|
if (skeletonDataAsset.controller == null) {
|
|
SkeletonBaker.GenerateMecanimAnimationClips(skeletonDataAsset);
|
|
SkeletonBaker.GenerateMecanimAnimationClips(skeletonDataAsset);
|