|
@@ -1,4 +1,38 @@
|
|
#pragma warning disable 0219
|
|
#pragma warning disable 0219
|
|
|
|
+/******************************************************************************
|
|
|
|
+ * Spine Runtimes Software License
|
|
|
|
+ * Version 2.1
|
|
|
|
+ *
|
|
|
|
+ * Copyright (c) 2013, Esoteric Software
|
|
|
|
+ * All rights reserved.
|
|
|
|
+ *
|
|
|
|
+ * You are granted a perpetual, non-exclusive, non-sublicensable and
|
|
|
|
+ * non-transferable license to install, execute and perform the Spine Runtimes
|
|
|
|
+ * Software (the "Software") solely for internal use. Without the written
|
|
|
|
+ * permission of Esoteric Software (typically granted by licensing Spine), you
|
|
|
|
+ * may not (a) modify, translate, adapt or otherwise create derivative works,
|
|
|
|
+ * improvements of the Software or develop new applications using the Software
|
|
|
|
+ * or (b) remove, delete, alter or obscure any trademarks or any copyright,
|
|
|
|
+ * trademark, patent or other intellectual property or proprietary rights
|
|
|
|
+ * notices on or in the Software, including any copy thereof. Redistributions
|
|
|
|
+ * in binary or source form must include this license and terms.
|
|
|
|
+ *
|
|
|
|
+ * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
|
|
|
|
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
|
|
|
+ * EVENT SHALL ESOTERIC SOFTARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
|
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
+ *****************************************************************************/
|
|
|
|
+
|
|
|
|
+/*****************************************************************************
|
|
|
|
+ * Spine Editor Utilities created by Mitch Thompson
|
|
|
|
+ * Full irrevocable rights and permissions granted to Esoteric Software
|
|
|
|
+*****************************************************************************/
|
|
|
|
|
|
using UnityEngine;
|
|
using UnityEngine;
|
|
using UnityEditor;
|
|
using UnityEditor;
|
|
@@ -15,6 +49,7 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|
public static Texture2D skeleton;
|
|
public static Texture2D skeleton;
|
|
public static Texture2D nullBone;
|
|
public static Texture2D nullBone;
|
|
public static Texture2D bone;
|
|
public static Texture2D bone;
|
|
|
|
+ public static Texture2D poseBones;
|
|
public static Texture2D boneNib;
|
|
public static Texture2D boneNib;
|
|
public static Texture2D slot;
|
|
public static Texture2D slot;
|
|
public static Texture2D skinPlaceholder;
|
|
public static Texture2D skinPlaceholder;
|
|
@@ -27,6 +62,11 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|
public static Texture2D animationRoot;
|
|
public static Texture2D animationRoot;
|
|
public static Texture2D spine;
|
|
public static Texture2D spine;
|
|
public static Texture2D _event;
|
|
public static Texture2D _event;
|
|
|
|
+ public static Texture2D constraintNib;
|
|
|
|
+ public static Texture2D warning;
|
|
|
|
+ public static Texture2D skeletonUtility;
|
|
|
|
+ public static Texture2D hingeChain;
|
|
|
|
+ public static Texture2D subMeshRenderer;
|
|
|
|
|
|
public static Mesh boneMesh{
|
|
public static Mesh boneMesh{
|
|
get{
|
|
get{
|
|
@@ -61,6 +101,7 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|
skeleton = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-skeleton.png");
|
|
skeleton = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-skeleton.png");
|
|
nullBone = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-null.png");
|
|
nullBone = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-null.png");
|
|
bone = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-bone.png");
|
|
bone = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-bone.png");
|
|
|
|
+ poseBones = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-poseBones.png");
|
|
boneNib = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-boneNib.png");
|
|
boneNib = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-boneNib.png");
|
|
slot = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-slot.png");
|
|
slot = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-slot.png");
|
|
skinPlaceholder = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-skinPlaceholder.png");
|
|
skinPlaceholder = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-skinPlaceholder.png");
|
|
@@ -73,6 +114,12 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|
animationRoot = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-animationRoot.png");
|
|
animationRoot = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-animationRoot.png");
|
|
spine = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-spine.png");
|
|
spine = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-spine.png");
|
|
_event = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-event.png");
|
|
_event = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-event.png");
|
|
|
|
+ constraintNib = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-constraintNib.png");
|
|
|
|
+ warning = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-warning.png");
|
|
|
|
+ skeletonUtility = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-skeletonUtility.png");
|
|
|
|
+ hingeChain = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-hingeChain.png");
|
|
|
|
+ subMeshRenderer = (Texture2D)AssetDatabase.LoadMainAssetAtPath( SpineEditorUtilities.editorGUIPath + "/icon-subMeshRenderer.png");
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -81,8 +128,9 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|
|
|
|
|
public static string editorPath = "";
|
|
public static string editorPath = "";
|
|
public static string editorGUIPath = "";
|
|
public static string editorGUIPath = "";
|
|
-
|
|
|
|
- static List<int> skeletonRendererInstanceIDs;
|
|
|
|
|
|
+
|
|
|
|
+ static Dictionary<int, GameObject> skeletonRendererTable;
|
|
|
|
+ static Dictionary<int, SkeletonUtilityBone> skeletonUtilityBoneTable;
|
|
|
|
|
|
public static float defaultScale = 0.01f;
|
|
public static float defaultScale = 0.01f;
|
|
public static float defaultMix = 0.2f;
|
|
public static float defaultMix = 0.2f;
|
|
@@ -96,7 +144,8 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|
|
|
|
|
Icons.Initialize();
|
|
Icons.Initialize();
|
|
|
|
|
|
- skeletonRendererInstanceIDs = new List<int>();
|
|
|
|
|
|
+ skeletonRendererTable = new Dictionary<int, GameObject>();
|
|
|
|
+ skeletonUtilityBoneTable = new Dictionary<int, SkeletonUtilityBone>();
|
|
|
|
|
|
EditorApplication.hierarchyWindowChanged += HierarchyWindowChanged;
|
|
EditorApplication.hierarchyWindowChanged += HierarchyWindowChanged;
|
|
EditorApplication.hierarchyWindowItemOnGUI += HierarchyWindowItemOnGUI;
|
|
EditorApplication.hierarchyWindowItemOnGUI += HierarchyWindowItemOnGUI;
|
|
@@ -105,22 +154,49 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|
}
|
|
}
|
|
|
|
|
|
static void HierarchyWindowChanged(){
|
|
static void HierarchyWindowChanged(){
|
|
- skeletonRendererInstanceIDs.Clear();
|
|
|
|
|
|
+ skeletonRendererTable.Clear();
|
|
|
|
+ skeletonUtilityBoneTable.Clear();
|
|
|
|
|
|
SkeletonRenderer[] arr = Object.FindObjectsOfType<SkeletonRenderer>();
|
|
SkeletonRenderer[] arr = Object.FindObjectsOfType<SkeletonRenderer>();
|
|
|
|
|
|
foreach(SkeletonRenderer r in arr)
|
|
foreach(SkeletonRenderer r in arr)
|
|
- skeletonRendererInstanceIDs.Add(r.gameObject.GetInstanceID());
|
|
|
|
|
|
+ skeletonRendererTable.Add( r.gameObject.GetInstanceID(), r.gameObject );
|
|
|
|
+
|
|
|
|
+ SkeletonUtilityBone[] boneArr = Object.FindObjectsOfType<SkeletonUtilityBone>();
|
|
|
|
+ foreach(SkeletonUtilityBone b in boneArr)
|
|
|
|
+ skeletonUtilityBoneTable.Add(b.gameObject.GetInstanceID(), b);
|
|
}
|
|
}
|
|
|
|
|
|
static void HierarchyWindowItemOnGUI(int instanceId, Rect selectionRect){
|
|
static void HierarchyWindowItemOnGUI(int instanceId, Rect selectionRect){
|
|
- if(skeletonRendererInstanceIDs.Contains(instanceId)){
|
|
|
|
|
|
+ if(skeletonRendererTable.ContainsKey(instanceId)){
|
|
Rect r = new Rect (selectionRect);
|
|
Rect r = new Rect (selectionRect);
|
|
r.x = r.width - 15;
|
|
r.x = r.width - 15;
|
|
r.width = 15;
|
|
r.width = 15;
|
|
|
|
|
|
GUI.Label(r, Icons.spine);
|
|
GUI.Label(r, Icons.spine);
|
|
}
|
|
}
|
|
|
|
+ else if(skeletonUtilityBoneTable.ContainsKey(instanceId)){
|
|
|
|
+ Rect r = new Rect (selectionRect);
|
|
|
|
+ //r.x = r.width - 15;
|
|
|
|
+ r.x -= 26;
|
|
|
|
+
|
|
|
|
+ if(skeletonUtilityBoneTable[instanceId] != null){
|
|
|
|
+ if( skeletonUtilityBoneTable[instanceId].transform.childCount == 0 )
|
|
|
|
+ r.x += 15;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ r.width = 15;
|
|
|
|
+
|
|
|
|
+ if( skeletonUtilityBoneTable[instanceId].mode == SkeletonUtilityBone.Mode.Follow ){
|
|
|
|
+ GUI.Label(r, Icons.bone);
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ GUI.Label(r, Icons.poseBones);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
[MenuItem("Assets/Spine/Ingest")]
|
|
[MenuItem("Assets/Spine/Ingest")]
|
|
@@ -335,20 +411,24 @@ public class SpineEditorUtilities : AssetPostprocessor {
|
|
|
|
|
|
string primaryName = Path.GetFileNameWithoutExtension(spineJson.name);
|
|
string primaryName = Path.GetFileNameWithoutExtension(spineJson.name);
|
|
string assetPath = Path.GetDirectoryName( AssetDatabase.GetAssetPath(spineJson));
|
|
string assetPath = Path.GetDirectoryName( AssetDatabase.GetAssetPath(spineJson));
|
|
|
|
+ string filePath = assetPath + "/" + primaryName + "_SkeletonData.asset";
|
|
|
|
|
|
if(spineJson != null && atlasAsset != null){
|
|
if(spineJson != null && atlasAsset != null){
|
|
|
|
|
|
- SkeletonDataAsset skelDataAsset = SkeletonDataAsset.CreateInstance<SkeletonDataAsset>();
|
|
|
|
- skelDataAsset.atlasAsset = atlasAsset;
|
|
|
|
- skelDataAsset.skeletonJSON = spineJson;
|
|
|
|
- skelDataAsset.fromAnimation = new string[0];
|
|
|
|
- skelDataAsset.toAnimation = new string[0];
|
|
|
|
- skelDataAsset.duration = new float[0];
|
|
|
|
- skelDataAsset.defaultMix = defaultMix;
|
|
|
|
- skelDataAsset.scale = defaultScale;
|
|
|
|
-
|
|
|
|
- AssetDatabase.CreateAsset(skelDataAsset, assetPath + "/" + primaryName + "_SkeletonData.asset");
|
|
|
|
- AssetDatabase.SaveAssets();
|
|
|
|
|
|
+ SkeletonDataAsset skelDataAsset = (SkeletonDataAsset)AssetDatabase.LoadAssetAtPath(filePath, typeof(SkeletonDataAsset));
|
|
|
|
+ if(skelDataAsset == null){
|
|
|
|
+ skelDataAsset = SkeletonDataAsset.CreateInstance<SkeletonDataAsset>();
|
|
|
|
+ skelDataAsset.atlasAsset = atlasAsset;
|
|
|
|
+ skelDataAsset.skeletonJSON = spineJson;
|
|
|
|
+ skelDataAsset.fromAnimation = new string[0];
|
|
|
|
+ skelDataAsset.toAnimation = new string[0];
|
|
|
|
+ skelDataAsset.duration = new float[0];
|
|
|
|
+ skelDataAsset.defaultMix = defaultMix;
|
|
|
|
+ skelDataAsset.scale = defaultScale;
|
|
|
|
+
|
|
|
|
+ AssetDatabase.CreateAsset(skelDataAsset, filePath);
|
|
|
|
+ AssetDatabase.SaveAssets();
|
|
|
|
+ }
|
|
|
|
|
|
return skelDataAsset;
|
|
return skelDataAsset;
|
|
}
|
|
}
|