mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[unity] 2018.3 prefab handling for scene components and inspectors.
This commit is contained in:
parent
7175cf98e7
commit
80272fb719
@ -30,6 +30,12 @@
|
|||||||
|
|
||||||
// With contributions from: Mitch Thompson
|
// 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 System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
@ -122,7 +128,11 @@ namespace Spine.Unity.Editor {
|
|||||||
skeletonRenderer.Initialize(false);
|
skeletonRenderer.Initialize(false);
|
||||||
skeletonRenderer.LateUpdate();
|
skeletonRenderer.LateUpdate();
|
||||||
skeleton = skeletonRenderer.skeleton;
|
skeleton = skeletonRenderer.skeleton;
|
||||||
|
#if NEW_PREFAB_SYSTEM
|
||||||
|
isPrefab = false;
|
||||||
|
#else
|
||||||
isPrefab |= PrefabUtility.GetPrefabType(selectedObject) == PrefabType.Prefab;
|
isPrefab |= PrefabUtility.GetPrefabType(selectedObject) == PrefabType.Prefab;
|
||||||
|
#endif
|
||||||
UpdateAttachments();
|
UpdateAttachments();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,7 +28,11 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#if UNITY_2018_3 || UNITY_2019
|
||||||
|
#define NEW_PREFAB_SYSTEM
|
||||||
|
#else
|
||||||
#define NO_PREFAB_MESH
|
#define NO_PREFAB_MESH
|
||||||
|
#endif
|
||||||
|
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -81,7 +85,11 @@ namespace Spine.Unity.Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnEnable () {
|
protected virtual void OnEnable () {
|
||||||
|
#if NEW_PREFAB_SYSTEM
|
||||||
|
isInspectingPrefab = false;
|
||||||
|
#else
|
||||||
isInspectingPrefab = (PrefabUtility.GetPrefabType(target) == PrefabType.Prefab);
|
isInspectingPrefab = (PrefabUtility.GetPrefabType(target) == PrefabType.Prefab);
|
||||||
|
#endif
|
||||||
|
|
||||||
SpineEditorUtilities.ConfirmInitialization();
|
SpineEditorUtilities.ConfirmInitialization();
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,10 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#if UNITY_2018_3 || UNITY_2019
|
||||||
|
#define NEW_PREFAB_SYSTEM
|
||||||
|
#endif
|
||||||
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
|
||||||
@ -61,7 +65,11 @@ namespace Spine.Unity.Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void OnInspectorGUI () {
|
public override void OnInspectorGUI () {
|
||||||
|
#if !NEW_PREFAB_SYSTEM
|
||||||
bool isInspectingPrefab = (PrefabUtility.GetPrefabType(target) == PrefabType.Prefab);
|
bool isInspectingPrefab = (PrefabUtility.GetPrefabType(target) == PrefabType.Prefab);
|
||||||
|
#else
|
||||||
|
bool isInspectingPrefab = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Try to auto-assign SkeletonRenderer field.
|
// Try to auto-assign SkeletonRenderer field.
|
||||||
if (skeletonRenderer.objectReferenceValue == null) {
|
if (skeletonRenderer.objectReferenceValue == null) {
|
||||||
@ -94,8 +102,10 @@ namespace Spine.Unity.Editor {
|
|||||||
EditorGUILayout.PropertyField(slotName, new GUIContent("Slot"));
|
EditorGUILayout.PropertyField(slotName, new GUIContent("Slot"));
|
||||||
if (EditorGUI.EndChangeCheck()) {
|
if (EditorGUI.EndChangeCheck()) {
|
||||||
serializedObject.ApplyModifiedProperties();
|
serializedObject.ApplyModifiedProperties();
|
||||||
|
#if !NEW_PREFAB_SYSTEM
|
||||||
if (!isInspectingPrefab)
|
if (!isInspectingPrefab)
|
||||||
rebuildRequired = true;
|
rebuildRequired = true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
using (new SpineInspectorUtility.LabelWidthScope(150f)) {
|
using (new SpineInspectorUtility.LabelWidthScope(150f)) {
|
||||||
|
|||||||
@ -28,7 +28,9 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
// Contributed by: Mitch Thompson
|
#if UNITY_2018_3 || UNITY_2019
|
||||||
|
#define NEW_PREFAB_SYSTEM
|
||||||
|
#endif
|
||||||
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
@ -46,7 +48,11 @@ namespace Spine.Unity.Editor {
|
|||||||
SkeletonUtility skeletonUtility;
|
SkeletonUtility skeletonUtility;
|
||||||
Skeleton skeleton;
|
Skeleton skeleton;
|
||||||
SkeletonRenderer skeletonRenderer;
|
SkeletonRenderer skeletonRenderer;
|
||||||
|
|
||||||
|
#if !NEW_PREFAB_SYSTEM
|
||||||
bool isPrefab;
|
bool isPrefab;
|
||||||
|
#endif
|
||||||
|
|
||||||
readonly GUIContent SpawnHierarchyButtonLabel = new GUIContent("Spawn Hierarchy", Icons.skeleton);
|
readonly GUIContent SpawnHierarchyButtonLabel = new GUIContent("Spawn Hierarchy", Icons.skeleton);
|
||||||
|
|
||||||
void OnEnable () {
|
void OnEnable () {
|
||||||
@ -62,14 +68,18 @@ namespace Spine.Unity.Editor {
|
|||||||
|
|
||||||
if (!skeletonRenderer.valid) return;
|
if (!skeletonRenderer.valid) return;
|
||||||
|
|
||||||
|
#if !NEW_PREFAB_SYSTEM
|
||||||
isPrefab |= PrefabUtility.GetPrefabType(this.target) == PrefabType.Prefab;
|
isPrefab |= PrefabUtility.GetPrefabType(this.target) == PrefabType.Prefab;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnInspectorGUI () {
|
public override void OnInspectorGUI () {
|
||||||
|
#if !NEW_PREFAB_SYSTEM
|
||||||
if (isPrefab) {
|
if (isPrefab) {
|
||||||
GUILayout.Label(new GUIContent("Cannot edit Prefabs", Icons.warning));
|
GUILayout.Label(new GUIContent("Cannot edit Prefabs", Icons.warning));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!skeletonRenderer.valid) {
|
if (!skeletonRenderer.valid) {
|
||||||
GUILayout.Label(new GUIContent("Spine Component invalid. Check Skeleton Data Asset.", Icons.warning));
|
GUILayout.Label(new GUIContent("Spine Component invalid. Check Skeleton Data Asset.", Icons.warning));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user