mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Fixes needed for Unity 3.5.
Unity 3.5 is pretty terrible. :(
This commit is contained in:
parent
643439dc9c
commit
2eb8627894
@ -74,11 +74,14 @@ public class SkeletonComponentInspector : Editor {
|
|||||||
EditorGUILayout.EndHorizontal();
|
EditorGUILayout.EndHorizontal();
|
||||||
|
|
||||||
EditorGUILayout.PropertyField(timeScale);
|
EditorGUILayout.PropertyField(timeScale);
|
||||||
|
|
||||||
if (serializedObject.ApplyModifiedProperties() ||
|
if (!Application.isPlaying) {
|
||||||
(Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")
|
if (serializedObject.ApplyModifiedProperties() ||
|
||||||
) {
|
(Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")
|
||||||
component.Clear();
|
) {
|
||||||
|
component.Clear();
|
||||||
|
component.Update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,19 +78,21 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
EditorGUILayout.BeginHorizontal();
|
EditorGUILayout.BeginHorizontal();
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
if (GUILayout.Button("Add Mix")) {
|
if (GUILayout.Button("Add Mix")) {
|
||||||
duration.InsertArrayElementAtIndex(fromAnimation.arraySize);
|
duration.arraySize++;
|
||||||
toAnimation.InsertArrayElementAtIndex(fromAnimation.arraySize);
|
toAnimation.arraySize++;
|
||||||
fromAnimation.InsertArrayElementAtIndex(fromAnimation.arraySize);
|
fromAnimation.arraySize++;
|
||||||
}
|
}
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
EditorGUILayout.EndHorizontal();
|
EditorGUILayout.EndHorizontal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serializedObject.ApplyModifiedProperties() ||
|
if (!Application.isPlaying) {
|
||||||
(Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")
|
if (serializedObject.ApplyModifiedProperties() ||
|
||||||
) {
|
(Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")
|
||||||
asset.Clear();
|
) {
|
||||||
|
asset.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,8 +56,8 @@ public class AtlasAsset : ScriptableObject {
|
|||||||
try {
|
try {
|
||||||
atlas = new Atlas(new StringReader(atlasFile.text), "", new SingleTextureLoader(material));
|
atlas = new Atlas(new StringReader(atlasFile.text), "", new SingleTextureLoader(material));
|
||||||
return atlas;
|
return atlas;
|
||||||
} catch (Exception) {
|
} catch (Exception ex) {
|
||||||
Debug.LogException(new Exception("Error reading atlas file for atlas asset: " + name), this);
|
Debug.Log("Error reading atlas file for atlas asset: " + name + "\n" + ex.Message + "\n" + ex.StackTrace, this);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,14 +60,21 @@ public class SkeletonComponent : MonoBehaviour {
|
|||||||
|
|
||||||
skeleton = new Skeleton(skeletonDataAsset.GetSkeletonData(false));
|
skeleton = new Skeleton(skeletonDataAsset.GetSkeletonData(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateAnimation () {
|
||||||
|
skeleton.Update(Time.deltaTime * timeScale);
|
||||||
|
state.Update(Time.deltaTime * timeScale);
|
||||||
|
state.Apply(skeleton);
|
||||||
|
skeleton.UpdateWorldTransform();
|
||||||
|
}
|
||||||
|
|
||||||
public void Update () {
|
public void Update () {
|
||||||
// Clear fields if missing information to render.
|
// Clear fields if missing information to render.
|
||||||
if (skeletonDataAsset == null || skeletonDataAsset.GetSkeletonData(false) == null) {
|
if (skeletonDataAsset == null || skeletonDataAsset.GetSkeletonData(false) == null) {
|
||||||
Clear();
|
Clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize fields.
|
// Initialize fields.
|
||||||
if (skeleton == null || skeleton.Data != skeletonDataAsset.GetSkeletonData(false))
|
if (skeleton == null || skeleton.Data != skeletonDataAsset.GetSkeletonData(false))
|
||||||
Initialize();
|
Initialize();
|
||||||
@ -81,12 +88,8 @@ public class SkeletonComponent : MonoBehaviour {
|
|||||||
state.SetAnimation(animation, loop);
|
state.SetAnimation(animation, loop);
|
||||||
}
|
}
|
||||||
state.Loop = loop;
|
state.Loop = loop;
|
||||||
|
|
||||||
// Apply animation.
|
UpdateAnimation();
|
||||||
skeleton.Update(Time.deltaTime * timeScale);
|
|
||||||
state.Update(Time.deltaTime * timeScale);
|
|
||||||
state.Apply(skeleton);
|
|
||||||
skeleton.UpdateWorldTransform();
|
|
||||||
|
|
||||||
// Count quads.
|
// Count quads.
|
||||||
int quadCount = 0;
|
int quadCount = 0;
|
||||||
|
|||||||
@ -73,13 +73,15 @@ public class SkeletonDataAsset : ScriptableObject {
|
|||||||
skeletonData = json.ReadSkeletonData(new StringReader(skeletonJSON.text));
|
skeletonData = json.ReadSkeletonData(new StringReader(skeletonJSON.text));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
Debug.LogException(new Exception("Error reading skeleton JSON file for skeleton data asset: " + name, ex), this);
|
Debug.Log("Error reading skeleton JSON file for skeleton data asset: " + name + "\n" + ex.Message + "\n" + ex.StackTrace, this);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
stateData = new AnimationStateData(skeletonData);
|
stateData = new AnimationStateData(skeletonData);
|
||||||
for (int i = 0, n = fromAnimation.Length; i < n; i++)
|
for (int i = 0, n = fromAnimation.Length; i < n; i++) {
|
||||||
|
if (fromAnimation[i].Length == 0 || toAnimation[i].Length == 0) continue;
|
||||||
stateData.SetMix(fromAnimation[i], toAnimation[i], duration[i]);
|
stateData.SetMix(fromAnimation[i], toAnimation[i], duration[i]);
|
||||||
|
}
|
||||||
|
|
||||||
return skeletonData;
|
return skeletonData;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user