mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Merge pull request #500 from EsotericSoftware/unity-attributes
[Unity] Property Attribute updates New [SpineEventData] attribute. Some refactoring.
This commit is contained in:
commit
3843b7f9d3
@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Spine Attribute Drawers created by Mitch Thompson
|
* Spine Attribute Drawers created by Mitch Thompson
|
||||||
* Full irrevocable rights and permissions granted to Esoteric Software
|
* Full irrevocable rights and permissions granted to Esoteric Software
|
||||||
@ -8,9 +7,6 @@ using UnityEngine;
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Spine;
|
using Spine;
|
||||||
|
|
||||||
@ -25,20 +21,17 @@ public struct SpineDrawerValuePair {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[CustomPropertyDrawer(typeof(SpineSlot))]
|
public abstract class SpineTreeItemDrawerBase<T> : PropertyDrawer where T:SpineAttributeBase {
|
||||||
public class SpineSlotDrawer : PropertyDrawer {
|
protected SkeletonDataAsset skeletonDataAsset;
|
||||||
SkeletonDataAsset skeletonDataAsset;
|
protected T TargetAttribute { get { return (T)attribute; } }
|
||||||
|
|
||||||
|
public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) {
|
||||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
|
|
||||||
if (property.propertyType != SerializedPropertyType.String) {
|
if (property.propertyType != SerializedPropertyType.String) {
|
||||||
EditorGUI.LabelField(position, "ERROR:", "May only apply to type string");
|
EditorGUI.LabelField(position, "ERROR:", "May only apply to type string");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineSlot attrib = (SpineSlot)attribute;
|
var dataProperty = property.serializedObject.FindProperty(TargetAttribute.dataField);
|
||||||
|
|
||||||
var dataProperty = property.serializedObject.FindProperty(attrib.dataField);
|
|
||||||
|
|
||||||
if (dataProperty != null) {
|
if (dataProperty != null) {
|
||||||
if (dataProperty.objectReferenceValue is SkeletonDataAsset) {
|
if (dataProperty.objectReferenceValue is SkeletonDataAsset) {
|
||||||
@ -73,21 +66,38 @@ public class SpineSlotDrawer : PropertyDrawer {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Selector(SerializedProperty property) {
|
protected virtual void Selector (SerializedProperty property) {
|
||||||
SpineSlot attrib = (SpineSlot)attribute;
|
|
||||||
SkeletonData data = skeletonDataAsset.GetSkeletonData(true);
|
SkeletonData data = skeletonDataAsset.GetSkeletonData(true);
|
||||||
if (data == null)
|
if (data == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GenericMenu menu = new GenericMenu();
|
GenericMenu menu = new GenericMenu();
|
||||||
|
PopulateMenu (menu, property, this.TargetAttribute, data);
|
||||||
|
menu.ShowAsContext();
|
||||||
|
}
|
||||||
|
|
||||||
menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
|
protected abstract void PopulateMenu (GenericMenu menu, SerializedProperty property, T targetAttribute, SkeletonData data);
|
||||||
menu.AddSeparator("");
|
|
||||||
|
|
||||||
|
protected virtual void HandleSelect (object val) {
|
||||||
|
var pair = (SpineDrawerValuePair)val;
|
||||||
|
pair.property.stringValue = pair.str;
|
||||||
|
pair.property.serializedObject.ApplyModifiedProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) {
|
||||||
|
return 18;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[CustomPropertyDrawer(typeof(SpineSlot))]
|
||||||
|
public class SpineSlotDrawer : SpineTreeItemDrawerBase<SpineSlot> {
|
||||||
|
|
||||||
|
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineSlot targetAttribute, SkeletonData data) {
|
||||||
for (int i = 0; i < data.Slots.Count; i++) {
|
for (int i = 0; i < data.Slots.Count; i++) {
|
||||||
string name = data.Slots.Items[i].Name;
|
string name = data.Slots.Items[i].Name;
|
||||||
if (name.StartsWith(attrib.startsWith)) {
|
if (name.StartsWith(targetAttribute.startsWith)) {
|
||||||
if (attrib.containsBoundingBoxes) {
|
if (targetAttribute.containsBoundingBoxes) {
|
||||||
|
|
||||||
int slotIndex = i;
|
int slotIndex = i;
|
||||||
|
|
||||||
@ -116,97 +126,164 @@ public class SpineSlotDrawer : PropertyDrawer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.ShowAsContext();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleSelect(object val) {
|
|
||||||
var pair = (SpineDrawerValuePair)val;
|
|
||||||
pair.property.stringValue = pair.str;
|
|
||||||
pair.property.serializedObject.ApplyModifiedProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) {
|
|
||||||
return 18;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[CustomPropertyDrawer(typeof(SpineSkin))]
|
[CustomPropertyDrawer(typeof(SpineSkin))]
|
||||||
public class SpineSkinDrawer : PropertyDrawer {
|
public class SpineSkinDrawer : SpineTreeItemDrawerBase<SpineSkin> {
|
||||||
SkeletonDataAsset skeletonDataAsset;
|
|
||||||
|
|
||||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
|
|
||||||
if (property.propertyType != SerializedPropertyType.String) {
|
|
||||||
EditorGUI.LabelField(position, "ERROR:", "May only apply to type string");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SpineSkin attrib = (SpineSkin)attribute;
|
|
||||||
|
|
||||||
var dataProperty = property.serializedObject.FindProperty(attrib.dataField);
|
|
||||||
|
|
||||||
if (dataProperty != null) {
|
|
||||||
if (dataProperty.objectReferenceValue is SkeletonDataAsset) {
|
|
||||||
skeletonDataAsset = (SkeletonDataAsset)dataProperty.objectReferenceValue;
|
|
||||||
} else if (dataProperty.objectReferenceValue is SkeletonRenderer) {
|
|
||||||
var renderer = (SkeletonRenderer)dataProperty.objectReferenceValue;
|
|
||||||
if (renderer != null)
|
|
||||||
skeletonDataAsset = renderer.skeletonDataAsset;
|
|
||||||
} else {
|
|
||||||
EditorGUI.LabelField(position, "ERROR:", "Invalid reference type");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (property.serializedObject.targetObject is Component) {
|
|
||||||
var component = (Component)property.serializedObject.targetObject;
|
|
||||||
if (component.GetComponentInChildren<SkeletonRenderer>() != null) {
|
|
||||||
var skeletonRenderer = component.GetComponentInChildren<SkeletonRenderer>();
|
|
||||||
skeletonDataAsset = skeletonRenderer.skeletonDataAsset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skeletonDataAsset == null) {
|
|
||||||
EditorGUI.LabelField(position, "ERROR:", "Must have reference to a SkeletonDataAsset");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
position = EditorGUI.PrefixLabel(position, label);
|
|
||||||
|
|
||||||
if (GUI.Button(position, property.stringValue, EditorStyles.popup)) {
|
|
||||||
Selector(property);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Selector(SerializedProperty property) {
|
|
||||||
SpineSkin attrib = (SpineSkin)attribute;
|
|
||||||
SkeletonData data = skeletonDataAsset.GetSkeletonData(true);
|
|
||||||
if (data == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
GenericMenu menu = new GenericMenu();
|
|
||||||
|
|
||||||
|
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineSkin targetAttribute, SkeletonData data) {
|
||||||
menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
|
menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
|
||||||
menu.AddSeparator("");
|
menu.AddSeparator("");
|
||||||
|
|
||||||
for (int i = 0; i < data.Skins.Count; i++) {
|
for (int i = 0; i < data.Skins.Count; i++) {
|
||||||
string name = data.Skins.Items[i].Name;
|
string name = data.Skins.Items[i].Name;
|
||||||
if (name.StartsWith(attrib.startsWith))
|
if (name.StartsWith(targetAttribute.startsWith))
|
||||||
menu.AddItem(new GUIContent(name), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
|
menu.AddItem(new GUIContent(name), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.ShowAsContext();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleSelect(object val) {
|
}
|
||||||
var pair = (SpineDrawerValuePair)val;
|
|
||||||
pair.property.stringValue = pair.str;
|
[CustomPropertyDrawer(typeof(SpineAnimation))]
|
||||||
pair.property.serializedObject.ApplyModifiedProperties();
|
public class SpineAnimationDrawer : SpineTreeItemDrawerBase<SpineAnimation> {
|
||||||
|
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineAnimation targetAttribute, SkeletonData data) {
|
||||||
|
var animations = skeletonDataAsset.GetAnimationStateData().SkeletonData.Animations;
|
||||||
|
for (int i = 0; i < animations.Count; i++) {
|
||||||
|
string name = animations.Items[i].Name;
|
||||||
|
if (name.StartsWith(targetAttribute.startsWith))
|
||||||
|
menu.AddItem(new GUIContent(name), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) {
|
}
|
||||||
return 18;
|
|
||||||
|
[CustomPropertyDrawer(typeof(SpineEventData))]
|
||||||
|
public class SpineEventDataDrawer : SpineTreeItemDrawerBase<SpineEventData> {
|
||||||
|
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineEventData targetAttribute, SkeletonData data) {
|
||||||
|
var events = skeletonDataAsset.GetSkeletonData(false).Events;
|
||||||
|
for (int i = 0; i < events.Count; i++) {
|
||||||
|
string name = events.Items[i].Name;
|
||||||
|
if (name.StartsWith(targetAttribute.startsWith))
|
||||||
|
menu.AddItem(new GUIContent(name), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[CustomPropertyDrawer(typeof(SpineAttachment))]
|
||||||
|
public class SpineAttachmentDrawer : SpineTreeItemDrawerBase<SpineAttachment> {
|
||||||
|
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineAttachment targetAttribute, SkeletonData data) {
|
||||||
|
List<Skin> validSkins = new List<Skin>();
|
||||||
|
SkeletonRenderer skeletonRenderer = null;
|
||||||
|
|
||||||
|
if (property.serializedObject.targetObject is Component) {
|
||||||
|
var component = (Component)property.serializedObject.targetObject;
|
||||||
|
if (component.GetComponentInChildren<SkeletonRenderer>() != null) {
|
||||||
|
skeletonRenderer = component.GetComponentInChildren<SkeletonRenderer>();
|
||||||
|
if (skeletonDataAsset != skeletonRenderer.skeletonDataAsset) {
|
||||||
|
Debug.LogError("DataField SkeletonDataAsset and SkeletonRenderer/SkeletonAnimation's SkeletonDataAsset do not match. Remove the explicit dataField parameter of your [SpineAttachment] field.");
|
||||||
|
}
|
||||||
|
|
||||||
|
skeletonDataAsset = skeletonRenderer.skeletonDataAsset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (skeletonRenderer != null && targetAttribute.currentSkinOnly) {
|
||||||
|
if (skeletonRenderer.skeleton.Skin != null) {
|
||||||
|
validSkins.Add(skeletonRenderer.skeleton.Skin);
|
||||||
|
} else {
|
||||||
|
validSkins.Add(data.Skins.Items[0]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
foreach (Skin skin in data.Skins) {
|
||||||
|
if (skin != null)
|
||||||
|
validSkins.Add(skin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<string> attachmentNames = new List<string>();
|
||||||
|
List<string> placeholderNames = new List<string>();
|
||||||
|
|
||||||
|
string prefix = "";
|
||||||
|
|
||||||
|
if (skeletonRenderer != null && targetAttribute.currentSkinOnly)
|
||||||
|
menu.AddDisabledItem(new GUIContent(skeletonRenderer.gameObject.name + " (SkeletonRenderer)"));
|
||||||
|
else
|
||||||
|
menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
|
||||||
|
menu.AddSeparator("");
|
||||||
|
|
||||||
|
menu.AddItem(new GUIContent("Null"), property.stringValue == "", HandleSelect, new SpineDrawerValuePair("", property));
|
||||||
|
menu.AddSeparator("");
|
||||||
|
|
||||||
|
Skin defaultSkin = data.Skins.Items[0];
|
||||||
|
|
||||||
|
SerializedProperty slotProperty = property.serializedObject.FindProperty(targetAttribute.slotField);
|
||||||
|
string slotMatch = "";
|
||||||
|
if (slotProperty != null) {
|
||||||
|
if (slotProperty.propertyType == SerializedPropertyType.String) {
|
||||||
|
slotMatch = slotProperty.stringValue.ToLower();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (Skin skin in validSkins) {
|
||||||
|
string skinPrefix = skin.Name + "/";
|
||||||
|
|
||||||
|
if (validSkins.Count > 1)
|
||||||
|
prefix = skinPrefix;
|
||||||
|
|
||||||
|
for (int i = 0; i < data.Slots.Count; i++) {
|
||||||
|
if (slotMatch.Length > 0 && data.Slots.Items[i].Name.ToLower().Contains(slotMatch) == false)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
attachmentNames.Clear();
|
||||||
|
placeholderNames.Clear();
|
||||||
|
|
||||||
|
skin.FindNamesForSlot(i, attachmentNames);
|
||||||
|
if (skin != defaultSkin) {
|
||||||
|
defaultSkin.FindNamesForSlot(i, attachmentNames);
|
||||||
|
skin.FindNamesForSlot(i, placeholderNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (int a = 0; a < attachmentNames.Count; a++) {
|
||||||
|
|
||||||
|
string attachmentPath = attachmentNames[a];
|
||||||
|
string menuPath = prefix + data.Slots.Items[i].Name + "/" + attachmentPath;
|
||||||
|
string name = attachmentNames[a];
|
||||||
|
|
||||||
|
if (targetAttribute.returnAttachmentPath)
|
||||||
|
name = skin.Name + "/" + data.Slots.Items[i].Name + "/" + attachmentPath;
|
||||||
|
|
||||||
|
if (targetAttribute.placeholdersOnly && placeholderNames.Contains(attachmentPath) == false) {
|
||||||
|
menu.AddDisabledItem(new GUIContent(menuPath));
|
||||||
|
} else {
|
||||||
|
menu.AddItem(new GUIContent(menuPath), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[CustomPropertyDrawer(typeof(SpineBone))]
|
||||||
|
public class SpineBoneDrawer : SpineTreeItemDrawerBase<SpineBone> {
|
||||||
|
|
||||||
|
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineBone targetAttribute, SkeletonData data) {
|
||||||
|
menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
|
||||||
|
menu.AddSeparator("");
|
||||||
|
|
||||||
|
for (int i = 0; i < data.Bones.Count; i++) {
|
||||||
|
string name = data.Bones.Items[i].Name;
|
||||||
|
if (name.StartsWith(targetAttribute.startsWith))
|
||||||
|
menu.AddItem(new GUIContent(name), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[CustomPropertyDrawer(typeof(SpineAtlasRegion))]
|
[CustomPropertyDrawer(typeof(SpineAtlasRegion))]
|
||||||
@ -246,7 +323,7 @@ public class SpineAtlasRegionDrawer : PropertyDrawer {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Selector(SerializedProperty property) {
|
void Selector (SerializedProperty property) {
|
||||||
GenericMenu menu = new GenericMenu();
|
GenericMenu menu = new GenericMenu();
|
||||||
AtlasAsset atlasAsset = (AtlasAsset)atlasProp.objectReferenceValue;
|
AtlasAsset atlasAsset = (AtlasAsset)atlasProp.objectReferenceValue;
|
||||||
Atlas atlas = atlasAsset.GetAtlas();
|
Atlas atlas = atlasAsset.GetAtlas();
|
||||||
@ -262,323 +339,10 @@ public class SpineAtlasRegionDrawer : PropertyDrawer {
|
|||||||
menu.ShowAsContext();
|
menu.ShowAsContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleSelect(object val) {
|
static void HandleSelect (object val) {
|
||||||
var pair = (SpineDrawerValuePair)val;
|
var pair = (SpineDrawerValuePair)val;
|
||||||
pair.property.stringValue = pair.str;
|
pair.property.stringValue = pair.str;
|
||||||
pair.property.serializedObject.ApplyModifiedProperties();
|
pair.property.serializedObject.ApplyModifiedProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) {
|
|
||||||
return 18;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[CustomPropertyDrawer(typeof(SpineAnimation))]
|
|
||||||
public class SpineAnimationDrawer : PropertyDrawer {
|
|
||||||
SkeletonDataAsset skeletonDataAsset;
|
|
||||||
|
|
||||||
|
|
||||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
|
|
||||||
|
|
||||||
|
|
||||||
if (property.propertyType != SerializedPropertyType.String) {
|
|
||||||
EditorGUI.LabelField(position, "ERROR:", "May only apply to type string");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SpineAnimation attrib = (SpineAnimation)attribute;
|
|
||||||
|
|
||||||
var dataProperty = property.serializedObject.FindProperty(attrib.dataField);
|
|
||||||
|
|
||||||
if (dataProperty != null) {
|
|
||||||
if (dataProperty.objectReferenceValue is SkeletonDataAsset) {
|
|
||||||
skeletonDataAsset = (SkeletonDataAsset)dataProperty.objectReferenceValue;
|
|
||||||
} else if (dataProperty.objectReferenceValue is SkeletonRenderer) {
|
|
||||||
var renderer = (SkeletonRenderer)dataProperty.objectReferenceValue;
|
|
||||||
if (renderer != null)
|
|
||||||
skeletonDataAsset = renderer.skeletonDataAsset;
|
|
||||||
} else {
|
|
||||||
EditorGUI.LabelField(position, "ERROR:", "Invalid reference type");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else if (property.serializedObject.targetObject is Component) {
|
|
||||||
var component = (Component)property.serializedObject.targetObject;
|
|
||||||
if (component.GetComponentInChildren<SkeletonRenderer>() != null) {
|
|
||||||
var skeletonRenderer = component.GetComponentInChildren<SkeletonRenderer>();
|
|
||||||
skeletonDataAsset = skeletonRenderer.skeletonDataAsset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skeletonDataAsset == null) {
|
|
||||||
EditorGUI.LabelField(position, "ERROR:", "Must have reference to a SkeletonDataAsset");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
position = EditorGUI.PrefixLabel(position, label);
|
|
||||||
|
|
||||||
if (GUI.Button(position, property.stringValue, EditorStyles.popup)) {
|
|
||||||
Selector(property);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Selector(SerializedProperty property) {
|
|
||||||
|
|
||||||
SpineAnimation attrib = (SpineAnimation)attribute;
|
|
||||||
|
|
||||||
GenericMenu menu = new GenericMenu();
|
|
||||||
|
|
||||||
var animations = skeletonDataAsset.GetAnimationStateData().SkeletonData.Animations;
|
|
||||||
for (int i = 0; i < animations.Count; i++) {
|
|
||||||
string name = animations.Items[i].Name;
|
|
||||||
if (name.StartsWith(attrib.startsWith))
|
|
||||||
menu.AddItem(new GUIContent(name), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
|
|
||||||
}
|
|
||||||
|
|
||||||
menu.ShowAsContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandleSelect(object val) {
|
|
||||||
var pair = (SpineDrawerValuePair)val;
|
|
||||||
pair.property.stringValue = pair.str;
|
|
||||||
pair.property.serializedObject.ApplyModifiedProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) {
|
|
||||||
return 18;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[CustomPropertyDrawer(typeof(SpineAttachment))]
|
|
||||||
public class SpineAttachmentDrawer : PropertyDrawer {
|
|
||||||
|
|
||||||
SkeletonDataAsset skeletonDataAsset;
|
|
||||||
SkeletonRenderer skeletonRenderer;
|
|
||||||
|
|
||||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
|
|
||||||
|
|
||||||
if (property.propertyType != SerializedPropertyType.String) {
|
|
||||||
EditorGUI.LabelField(position, "ERROR:", "May only apply to type string");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SpineAttachment attrib = (SpineAttachment)attribute;
|
|
||||||
|
|
||||||
var dataProperty = property.serializedObject.FindProperty(attrib.dataField);
|
|
||||||
|
|
||||||
if (dataProperty != null) {
|
|
||||||
if (dataProperty.objectReferenceValue is SkeletonDataAsset) {
|
|
||||||
skeletonDataAsset = (SkeletonDataAsset)dataProperty.objectReferenceValue;
|
|
||||||
} else if (dataProperty.objectReferenceValue is SkeletonRenderer) {
|
|
||||||
var renderer = (SkeletonRenderer)dataProperty.objectReferenceValue;
|
|
||||||
if (renderer != null)
|
|
||||||
skeletonDataAsset = renderer.skeletonDataAsset;
|
|
||||||
else {
|
|
||||||
EditorGUI.LabelField(position, "ERROR:", "No SkeletonRenderer");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
EditorGUI.LabelField(position, "ERROR:", "Invalid reference type");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (property.serializedObject.targetObject is Component) {
|
|
||||||
var component = (Component)property.serializedObject.targetObject;
|
|
||||||
if (component.GetComponentInChildren<SkeletonRenderer>() != null) {
|
|
||||||
skeletonRenderer = component.GetComponentInChildren<SkeletonRenderer>();
|
|
||||||
skeletonDataAsset = skeletonRenderer.skeletonDataAsset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skeletonDataAsset == null && skeletonRenderer == null) {
|
|
||||||
EditorGUI.LabelField(position, "ERROR:", "Must have reference to a SkeletonDataAsset or SkeletonRenderer");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
position = EditorGUI.PrefixLabel(position, label);
|
|
||||||
|
|
||||||
if (GUI.Button(position, property.stringValue, EditorStyles.popup)) {
|
|
||||||
Selector(property);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Selector(SerializedProperty property) {
|
|
||||||
SkeletonData data = skeletonDataAsset.GetSkeletonData(true);
|
|
||||||
|
|
||||||
if (data == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
SpineAttachment attrib = (SpineAttachment)attribute;
|
|
||||||
|
|
||||||
List<Skin> validSkins = new List<Skin>();
|
|
||||||
|
|
||||||
if (skeletonRenderer != null && attrib.currentSkinOnly) {
|
|
||||||
if (skeletonRenderer.skeleton.Skin != null) {
|
|
||||||
validSkins.Add(skeletonRenderer.skeleton.Skin);
|
|
||||||
} else {
|
|
||||||
validSkins.Add(data.Skins.Items[0]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
foreach (Skin skin in data.Skins) {
|
|
||||||
if (skin != null)
|
|
||||||
validSkins.Add(skin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GenericMenu menu = new GenericMenu();
|
|
||||||
List<string> attachmentNames = new List<string>();
|
|
||||||
List<string> placeholderNames = new List<string>();
|
|
||||||
|
|
||||||
string prefix = "";
|
|
||||||
|
|
||||||
if (skeletonRenderer != null && attrib.currentSkinOnly)
|
|
||||||
menu.AddDisabledItem(new GUIContent(skeletonRenderer.gameObject.name + " (SkeletonRenderer)"));
|
|
||||||
else
|
|
||||||
menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
|
|
||||||
menu.AddSeparator("");
|
|
||||||
|
|
||||||
menu.AddItem(new GUIContent("Null"), property.stringValue == "", HandleSelect, new SpineDrawerValuePair("", property));
|
|
||||||
menu.AddSeparator("");
|
|
||||||
|
|
||||||
Skin defaultSkin = data.Skins.Items[0];
|
|
||||||
|
|
||||||
SerializedProperty slotProperty = property.serializedObject.FindProperty(attrib.slotField);
|
|
||||||
string slotMatch = "";
|
|
||||||
if (slotProperty != null) {
|
|
||||||
if (slotProperty.propertyType == SerializedPropertyType.String) {
|
|
||||||
slotMatch = slotProperty.stringValue.ToLower();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (Skin skin in validSkins) {
|
|
||||||
string skinPrefix = skin.Name + "/";
|
|
||||||
|
|
||||||
if (validSkins.Count > 1)
|
|
||||||
prefix = skinPrefix;
|
|
||||||
|
|
||||||
for (int i = 0; i < data.Slots.Count; i++) {
|
|
||||||
if (slotMatch.Length > 0 && data.Slots.Items[i].Name.ToLower().Contains(slotMatch) == false)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
attachmentNames.Clear();
|
|
||||||
placeholderNames.Clear();
|
|
||||||
|
|
||||||
skin.FindNamesForSlot(i, attachmentNames);
|
|
||||||
if (skin != defaultSkin) {
|
|
||||||
defaultSkin.FindNamesForSlot(i, attachmentNames);
|
|
||||||
skin.FindNamesForSlot(i, placeholderNames);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (int a = 0; a < attachmentNames.Count; a++) {
|
|
||||||
|
|
||||||
string attachmentPath = attachmentNames[a];
|
|
||||||
string menuPath = prefix + data.Slots.Items[i].Name + "/" + attachmentPath;
|
|
||||||
string name = attachmentNames[a];
|
|
||||||
|
|
||||||
if (attrib.returnAttachmentPath)
|
|
||||||
name = skin.Name + "/" + data.Slots.Items[i].Name + "/" + attachmentPath;
|
|
||||||
|
|
||||||
if (attrib.placeholdersOnly && placeholderNames.Contains(attachmentPath) == false) {
|
|
||||||
menu.AddDisabledItem(new GUIContent(menuPath));
|
|
||||||
} else {
|
|
||||||
menu.AddItem(new GUIContent(menuPath), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
menu.ShowAsContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandleSelect(object val) {
|
|
||||||
var pair = (SpineDrawerValuePair)val;
|
|
||||||
pair.property.stringValue = pair.str;
|
|
||||||
pair.property.serializedObject.ApplyModifiedProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) {
|
|
||||||
return 18;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[CustomPropertyDrawer(typeof(SpineBone))]
|
|
||||||
public class SpineBoneDrawer : PropertyDrawer {
|
|
||||||
SkeletonDataAsset skeletonDataAsset;
|
|
||||||
|
|
||||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
|
|
||||||
if (property.propertyType != SerializedPropertyType.String) {
|
|
||||||
EditorGUI.LabelField(position, "ERROR:", "May only apply to type string");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SpineBone attrib = (SpineBone)attribute;
|
|
||||||
|
|
||||||
var dataProperty = property.serializedObject.FindProperty(attrib.dataField);
|
|
||||||
|
|
||||||
if (dataProperty != null) {
|
|
||||||
if (dataProperty.objectReferenceValue is SkeletonDataAsset) {
|
|
||||||
skeletonDataAsset = (SkeletonDataAsset)dataProperty.objectReferenceValue;
|
|
||||||
} else if (dataProperty.objectReferenceValue is SkeletonRenderer) {
|
|
||||||
var renderer = (SkeletonRenderer)dataProperty.objectReferenceValue;
|
|
||||||
if (renderer != null)
|
|
||||||
skeletonDataAsset = renderer.skeletonDataAsset;
|
|
||||||
} else {
|
|
||||||
EditorGUI.LabelField(position, "ERROR:", "Invalid reference type");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (property.serializedObject.targetObject is Component) {
|
|
||||||
var component = (Component)property.serializedObject.targetObject;
|
|
||||||
if (component.GetComponentInChildren<SkeletonRenderer>() != null) {
|
|
||||||
var skeletonRenderer = component.GetComponentInChildren<SkeletonRenderer>();
|
|
||||||
skeletonDataAsset = skeletonRenderer.skeletonDataAsset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skeletonDataAsset == null) {
|
|
||||||
EditorGUI.LabelField(position, "ERROR:", "Must have reference to a SkeletonDataAsset");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
position = EditorGUI.PrefixLabel(position, label);
|
|
||||||
|
|
||||||
if (GUI.Button(position, property.stringValue, EditorStyles.popup)) {
|
|
||||||
Selector(property);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Selector(SerializedProperty property) {
|
|
||||||
SpineBone attrib = (SpineBone)attribute;
|
|
||||||
SkeletonData data = skeletonDataAsset.GetSkeletonData(true);
|
|
||||||
if (data == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
GenericMenu menu = new GenericMenu();
|
|
||||||
|
|
||||||
menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
|
|
||||||
menu.AddSeparator("");
|
|
||||||
|
|
||||||
for (int i = 0; i < data.Bones.Count; i++) {
|
|
||||||
string name = data.Bones.Items[i].Name;
|
|
||||||
if (name.StartsWith(attrib.startsWith))
|
|
||||||
menu.AddItem(new GUIContent(name), name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
|
|
||||||
}
|
|
||||||
|
|
||||||
menu.ShowAsContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandleSelect(object val) {
|
|
||||||
var pair = (SpineDrawerValuePair)val;
|
|
||||||
pair.property.stringValue = pair.str;
|
|
||||||
pair.property.serializedObject.ApplyModifiedProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) {
|
|
||||||
return 18;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -7,9 +7,12 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
|
||||||
public class SpineSlot : PropertyAttribute {
|
public abstract class SpineAttributeBase : PropertyAttribute {
|
||||||
public string startsWith = "";
|
|
||||||
public string dataField = "";
|
public string dataField = "";
|
||||||
|
public string startsWith = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SpineSlot : SpineAttributeBase {
|
||||||
public bool containsBoundingBoxes = false;
|
public bool containsBoundingBoxes = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -21,17 +24,29 @@ public class SpineSlot : PropertyAttribute {
|
|||||||
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
|
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <param name="containsBoundingBoxes">Disables popup results that don't contain bounding box attachments when true.</param>
|
/// <param name="containsBoundingBoxes">Disables popup results that don't contain bounding box attachments when true.</param>
|
||||||
public SpineSlot (string startsWith = "", string dataField = "", bool containsBoundingBoxes = false) {
|
public SpineSlot(string startsWith = "", string dataField = "", bool containsBoundingBoxes = false) {
|
||||||
this.startsWith = startsWith;
|
this.startsWith = startsWith;
|
||||||
this.dataField = dataField;
|
this.dataField = dataField;
|
||||||
this.containsBoundingBoxes = containsBoundingBoxes;
|
this.containsBoundingBoxes = containsBoundingBoxes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SpineSkin : PropertyAttribute {
|
public class SpineEventData : SpineAttributeBase {
|
||||||
public string startsWith = "";
|
/// <summary>
|
||||||
public string dataField = "";
|
/// Smart popup menu for Spine Events (Spine.EventData)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="startsWith">Filters popup results to elements that begin with supplied string.</param>
|
||||||
|
/// <param name="dataField">If specified, a locally scoped field with the name supplied by in dataField will be used to fill the popup results.
|
||||||
|
/// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives).
|
||||||
|
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
|
||||||
|
/// </param>
|
||||||
|
public SpineEventData(string startsWith = "", string dataField = "") {
|
||||||
|
this.startsWith = startsWith;
|
||||||
|
this.dataField = dataField;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SpineSkin : SpineAttributeBase {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Smart popup menu for Spine Skins
|
/// Smart popup menu for Spine Skins
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -40,15 +55,12 @@ public class SpineSkin : PropertyAttribute {
|
|||||||
/// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives)
|
/// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives)
|
||||||
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
|
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
|
||||||
/// </param>
|
/// </param>
|
||||||
public SpineSkin (string startsWith = "", string dataField = "") {
|
public SpineSkin(string startsWith = "", string dataField = "") {
|
||||||
this.startsWith = startsWith;
|
this.startsWith = startsWith;
|
||||||
this.dataField = dataField;
|
this.dataField = dataField;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class SpineAnimation : PropertyAttribute {
|
public class SpineAnimation : SpineAttributeBase {
|
||||||
public string startsWith = "";
|
|
||||||
public string dataField = "";
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Smart popup menu for Spine Animations
|
/// Smart popup menu for Spine Animations
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -57,24 +69,18 @@ public class SpineAnimation : PropertyAttribute {
|
|||||||
/// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives)
|
/// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives)
|
||||||
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
|
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
|
||||||
/// </param>
|
/// </param>
|
||||||
public SpineAnimation (string startsWith = "", string dataField = "") {
|
public SpineAnimation(string startsWith = "", string dataField = "") {
|
||||||
this.startsWith = startsWith;
|
this.startsWith = startsWith;
|
||||||
this.dataField = dataField;
|
this.dataField = dataField;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SpineAttachment : PropertyAttribute {
|
public class SpineAttachment : SpineAttributeBase {
|
||||||
public bool returnAttachmentPath = false;
|
public bool returnAttachmentPath = false;
|
||||||
public bool currentSkinOnly = false;
|
public bool currentSkinOnly = false;
|
||||||
public bool placeholdersOnly = false;
|
public bool placeholdersOnly = false;
|
||||||
public string dataField = "";
|
|
||||||
public string slotField = "";
|
public string slotField = "";
|
||||||
|
|
||||||
|
|
||||||
public SpineAttachment () {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Smart popup menu for Spine Attachments
|
/// Smart popup menu for Spine Attachments
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -86,7 +92,7 @@ public class SpineAttachment : PropertyAttribute {
|
|||||||
/// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives)
|
/// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives)
|
||||||
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
|
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
|
||||||
/// </param>
|
/// </param>
|
||||||
public SpineAttachment (bool currentSkinOnly = true, bool returnAttachmentPath = false, bool placeholdersOnly = false, string slotField = "", string dataField = "") {
|
public SpineAttachment(bool currentSkinOnly = true, bool returnAttachmentPath = false, bool placeholdersOnly = false, string slotField = "", string dataField = "") {
|
||||||
this.currentSkinOnly = currentSkinOnly;
|
this.currentSkinOnly = currentSkinOnly;
|
||||||
this.returnAttachmentPath = returnAttachmentPath;
|
this.returnAttachmentPath = returnAttachmentPath;
|
||||||
this.placeholdersOnly = placeholdersOnly;
|
this.placeholdersOnly = placeholdersOnly;
|
||||||
@ -94,11 +100,11 @@ public class SpineAttachment : PropertyAttribute {
|
|||||||
this.dataField = dataField;
|
this.dataField = dataField;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Hierarchy GetHierarchy (string fullPath) {
|
public static Hierarchy GetHierarchy(string fullPath) {
|
||||||
return new Hierarchy(fullPath);
|
return new Hierarchy(fullPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Spine.Attachment GetAttachment (string attachmentPath, Spine.SkeletonData skeletonData) {
|
public static Spine.Attachment GetAttachment(string attachmentPath, Spine.SkeletonData skeletonData) {
|
||||||
var hierarchy = SpineAttachment.GetHierarchy(attachmentPath);
|
var hierarchy = SpineAttachment.GetHierarchy(attachmentPath);
|
||||||
if (hierarchy.name == "")
|
if (hierarchy.name == "")
|
||||||
return null;
|
return null;
|
||||||
@ -106,7 +112,7 @@ public class SpineAttachment : PropertyAttribute {
|
|||||||
return skeletonData.FindSkin(hierarchy.skin).GetAttachment(skeletonData.FindSlotIndex(hierarchy.slot), hierarchy.name);
|
return skeletonData.FindSkin(hierarchy.skin).GetAttachment(skeletonData.FindSlotIndex(hierarchy.slot), hierarchy.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Spine.Attachment GetAttachment (string attachmentPath, SkeletonDataAsset skeletonDataAsset) {
|
public static Spine.Attachment GetAttachment(string attachmentPath, SkeletonDataAsset skeletonDataAsset) {
|
||||||
return GetAttachment(attachmentPath, skeletonDataAsset.GetSkeletonData(true));
|
return GetAttachment(attachmentPath, skeletonDataAsset.GetSkeletonData(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,14 +121,15 @@ public class SpineAttachment : PropertyAttribute {
|
|||||||
public string slot;
|
public string slot;
|
||||||
public string name;
|
public string name;
|
||||||
|
|
||||||
public Hierarchy (string fullPath) {
|
public Hierarchy(string fullPath) {
|
||||||
string[] chunks = fullPath.Split(new char[] { '/' }, System.StringSplitOptions.RemoveEmptyEntries);
|
string[] chunks = fullPath.Split(new char[]{'/'}, System.StringSplitOptions.RemoveEmptyEntries);
|
||||||
if (chunks.Length == 0) {
|
if (chunks.Length == 0) {
|
||||||
skin = "";
|
skin = "";
|
||||||
slot = "";
|
slot = "";
|
||||||
name = "";
|
name = "";
|
||||||
return;
|
return;
|
||||||
} else if (chunks.Length < 2) {
|
}
|
||||||
|
else if (chunks.Length < 2) {
|
||||||
throw new System.Exception("Cannot generate Attachment Hierarchy from string! Not enough components! [" + fullPath + "]");
|
throw new System.Exception("Cannot generate Attachment Hierarchy from string! Not enough components! [" + fullPath + "]");
|
||||||
}
|
}
|
||||||
skin = chunks[0];
|
skin = chunks[0];
|
||||||
@ -135,10 +142,7 @@ public class SpineAttachment : PropertyAttribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SpineBone : PropertyAttribute {
|
public class SpineBone : SpineAttributeBase {
|
||||||
public string startsWith = "";
|
|
||||||
public string dataField = "";
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Smart popup menu for Spine Bones
|
/// Smart popup menu for Spine Bones
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -147,19 +151,19 @@ public class SpineBone : PropertyAttribute {
|
|||||||
/// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives)
|
/// Valid types are SkeletonDataAsset and SkeletonRenderer (and derivatives)
|
||||||
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
|
/// If left empty and the script the attribute is applied to is derived from Component, GetComponent<SkeletonRenderer>() will be called as a fallback.
|
||||||
/// </param>
|
/// </param>
|
||||||
public SpineBone (string startsWith = "", string dataField = "") {
|
public SpineBone(string startsWith = "", string dataField = "") {
|
||||||
this.startsWith = startsWith;
|
this.startsWith = startsWith;
|
||||||
this.dataField = dataField;
|
this.dataField = dataField;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Spine.Bone GetBone (string boneName, SkeletonRenderer renderer) {
|
public static Spine.Bone GetBone(string boneName, SkeletonRenderer renderer) {
|
||||||
if (renderer.skeleton == null)
|
if (renderer.skeleton == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return renderer.skeleton.FindBone(boneName);
|
return renderer.skeleton.FindBone(boneName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Spine.BoneData GetBoneData (string boneName, SkeletonDataAsset skeletonDataAsset) {
|
public static Spine.BoneData GetBoneData(string boneName, SkeletonDataAsset skeletonDataAsset) {
|
||||||
var data = skeletonDataAsset.GetSkeletonData(true);
|
var data = skeletonDataAsset.GetSkeletonData(true);
|
||||||
|
|
||||||
return data.FindBone(boneName);
|
return data.FindBone(boneName);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user