mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Spine.Unity namespace and some editor tweaks.
This commit is contained in:
parent
50a0960a7d
commit
9e8fdeef6c
@ -28,17 +28,17 @@
|
|||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
//#define BAKE_ALL_BUTTON
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Spine;
|
using Spine;
|
||||||
|
|
||||||
|
namespace Spine.Unity {
|
||||||
|
|
||||||
[CustomEditor(typeof(AtlasAsset))]
|
[CustomEditor(typeof(AtlasAsset))]
|
||||||
public class AtlasAssetInspector : Editor {
|
public class AtlasAssetInspector : Editor {
|
||||||
@ -78,8 +78,6 @@ public class AtlasAssetInspector : Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
override public void OnInspectorGUI () {
|
override public void OnInspectorGUI () {
|
||||||
serializedObject.Update();
|
serializedObject.Update();
|
||||||
AtlasAsset asset = (AtlasAsset)target;
|
AtlasAsset asset = (AtlasAsset)target;
|
||||||
@ -166,6 +164,48 @@ public class AtlasAssetInspector : Editor {
|
|||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
}
|
}
|
||||||
EditorGUI.indentLevel--;
|
EditorGUI.indentLevel--;
|
||||||
|
|
||||||
|
#if BAKE_ALL_BUTTON
|
||||||
|
// Check state
|
||||||
|
bool allBaked = true;
|
||||||
|
bool allUnbaked = true;
|
||||||
|
for (int i = 0; i < regions.Count; i++) {
|
||||||
|
allBaked &= baked[i];
|
||||||
|
allUnbaked &= !baked[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!allBaked && GUILayout.Button("Bake All")) {
|
||||||
|
for (int i = 0; i < regions.Count; i++) {
|
||||||
|
if (!baked[i]) {
|
||||||
|
baked[i] = true;
|
||||||
|
bakedObjects[i] = SpineEditorUtilities.BakeRegion(atlasAsset, regions[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (!allUnbaked && GUILayout.Button("Unbake All")) {
|
||||||
|
bool unbakeResult = EditorUtility.DisplayDialog("Delete All Baked Regions", "Are you sure you want to unbake all region prefabs? This cannot be undone.", "Yes", "Cancel");
|
||||||
|
switch (unbakeResult) {
|
||||||
|
case true:
|
||||||
|
//delete
|
||||||
|
for (int i = 0; i < regions.Count; i++) {
|
||||||
|
if (baked[i]) {
|
||||||
|
string atlasAssetPath = AssetDatabase.GetAssetPath(atlasAsset);
|
||||||
|
string atlasAssetDirPath = Path.GetDirectoryName(atlasAssetPath);
|
||||||
|
string bakedDirPath = Path.Combine(atlasAssetDirPath, atlasAsset.name);
|
||||||
|
string bakedPrefabPath = Path.Combine(bakedDirPath, SpineEditorUtilities.GetPathSafeRegionName(regions[i]) + ".prefab").Replace("\\", "/");
|
||||||
|
AssetDatabase.DeleteAsset(bakedPrefabPath);
|
||||||
|
baked[i] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case false:
|
||||||
|
//do nothing
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serializedObject.ApplyModifiedProperties() ||
|
if (serializedObject.ApplyModifiedProperties() ||
|
||||||
@ -175,3 +215,5 @@ public class AtlasAssetInspector : Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ using UnityEditor.AnimatedValues;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Spine;
|
using Spine;
|
||||||
|
|
||||||
|
namespace Spine.Unity {
|
||||||
[CustomEditor(typeof(SkeletonDataAsset))]
|
[CustomEditor(typeof(SkeletonDataAsset))]
|
||||||
public class SkeletonDataAssetInspector : Editor {
|
public class SkeletonDataAssetInspector : Editor {
|
||||||
static bool showAnimationStateData = true;
|
static bool showAnimationStateData = true;
|
||||||
@ -975,3 +976,5 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -28,14 +28,13 @@
|
|||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Spine;
|
|
||||||
|
|
||||||
public class Menus {
|
namespace Spine.Unity {
|
||||||
|
public static class Menus {
|
||||||
[MenuItem("Assets/Create/Spine Atlas")]
|
[MenuItem("Assets/Create/Spine Atlas")]
|
||||||
static public void CreateAtlas () {
|
static public void CreateAtlas () {
|
||||||
CreateAsset<AtlasAsset>("New Atlas");
|
CreateAsset<AtlasAsset>("New Atlas");
|
||||||
@ -82,3 +81,4 @@ public class Menus {
|
|||||||
EditorGUIUtility.PingObject(Selection.activeObject);
|
EditorGUIUtility.PingObject(Selection.activeObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -28,12 +28,13 @@
|
|||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Spine;
|
using Spine;
|
||||||
|
|
||||||
|
namespace Spine.Unity {
|
||||||
|
|
||||||
[CustomEditor(typeof(SkeletonAnimation))]
|
[CustomEditor(typeof(SkeletonAnimation))]
|
||||||
public class SkeletonAnimationInspector : SkeletonRendererInspector {
|
public class SkeletonAnimationInspector : SkeletonRendererInspector {
|
||||||
protected SerializedProperty animationName, loop, timeScale, autoReset;
|
protected SerializedProperty animationName, loop, timeScale, autoReset;
|
||||||
@ -110,3 +111,4 @@ public class SkeletonAnimationInspector : SkeletonRendererInspector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* SkeletonAnimatorInspector created by Mitch Thompson
|
* SkeletonAnimatorInspector created by Mitch Thompson
|
||||||
* Full irrevocable rights and permissions granted to Esoteric Software
|
* Full irrevocable rights and permissions granted to Esoteric Software
|
||||||
@ -7,8 +5,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Spine;
|
|
||||||
|
|
||||||
|
namespace Spine.Unity {
|
||||||
[CustomEditor(typeof(SkeletonAnimator))]
|
[CustomEditor(typeof(SkeletonAnimator))]
|
||||||
public class SkeletonAnimatorInspector : SkeletonRendererInspector {
|
public class SkeletonAnimatorInspector : SkeletonRendererInspector {
|
||||||
protected SerializedProperty layerMixModes;
|
protected SerializedProperty layerMixModes;
|
||||||
@ -41,3 +39,4 @@ public class SkeletonAnimatorInspector : SkeletonRendererInspector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -33,6 +33,8 @@ using System;
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Spine.Unity {
|
||||||
|
|
||||||
[CustomEditor(typeof(SkeletonRenderer))]
|
[CustomEditor(typeof(SkeletonRenderer))]
|
||||||
public class SkeletonRendererInspector : Editor {
|
public class SkeletonRendererInspector : Editor {
|
||||||
protected static bool advancedFoldout;
|
protected static bool advancedFoldout;
|
||||||
@ -140,7 +142,7 @@ public class SkeletonRendererInspector : Editor {
|
|||||||
serializedObject.Update();
|
serializedObject.Update();
|
||||||
DrawInspectorGUI();
|
DrawInspectorGUI();
|
||||||
if (serializedObject.ApplyModifiedProperties() ||
|
if (serializedObject.ApplyModifiedProperties() ||
|
||||||
(Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")
|
(UnityEngine.Event.current.type == EventType.ValidateCommand && UnityEngine.Event.current.commandName == "UndoRedoPerformed")
|
||||||
) {
|
) {
|
||||||
if (!Application.isPlaying)
|
if (!Application.isPlaying)
|
||||||
((SkeletonRenderer)target).Initialize(true);
|
((SkeletonRenderer)target).Initialize(true);
|
||||||
@ -148,3 +150,4 @@ public class SkeletonRendererInspector : Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@ -34,6 +34,7 @@ using System.Collections;
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Spine.Unity {
|
||||||
public static class SpineInspectorUtility {
|
public static class SpineInspectorUtility {
|
||||||
|
|
||||||
#region Sorting Layer Field Helpers
|
#region Sorting Layer Field Helpers
|
||||||
@ -90,3 +91,5 @@ public static class SpineInspectorUtility {
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -149,7 +149,7 @@ namespace Spine.Unity {
|
|||||||
EditorGUIUtility.PingObject(Selection.activeObject);
|
EditorGUIUtility.PingObject(Selection.activeObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MenuItem("Assets/Spine/Instantiate (UnityUI)", false, 0)]
|
[MenuItem("Assets/Spine/Instantiate (UnityUI)", false, 10)]
|
||||||
static void InstantiateSkeletonGraphic () {
|
static void InstantiateSkeletonGraphic () {
|
||||||
Object[] arr = Selection.objects;
|
Object[] arr = Selection.objects;
|
||||||
foreach (Object o in arr) {
|
foreach (Object o in arr) {
|
||||||
@ -161,7 +161,7 @@ namespace Spine.Unity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[MenuItem("Assets/Spine/Instantiate (UnityUI)", true, 0)]
|
[MenuItem("Assets/Spine/Instantiate (UnityUI)", true, 10)]
|
||||||
static bool ValidateInstantiateSkeletonGraphic () {
|
static bool ValidateInstantiateSkeletonGraphic () {
|
||||||
Object[] arr = Selection.objects;
|
Object[] arr = Selection.objects;
|
||||||
|
|
||||||
|
|||||||
@ -212,7 +212,7 @@ namespace Spine.Unity {
|
|||||||
spineMeshGenerator.Scale = canvas.referencePixelsPerUnit; // TODO: move this to a listener to of the canvas?
|
spineMeshGenerator.Scale = canvas.referencePixelsPerUnit; // TODO: move this to a listener to of the canvas?
|
||||||
|
|
||||||
canvasRenderer.SetMesh(spineMeshGenerator.GenerateMesh(skeleton));
|
canvasRenderer.SetMesh(spineMeshGenerator.GenerateMesh(skeleton));
|
||||||
this.UpdateMaterial();
|
//this.UpdateMaterial(); // TODO: This allocates memory.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user