Fixes needed for Unity 3.5.

Unity 3.5 is pretty terrible. :(
This commit is contained in:
NathanSweet 2013-04-22 11:55:22 +02:00
parent 643439dc9c
commit 2eb8627894
5 changed files with 34 additions and 24 deletions

View File

@ -74,11 +74,14 @@ public class SkeletonComponentInspector : Editor {
EditorGUILayout.EndHorizontal();
EditorGUILayout.PropertyField(timeScale);
if (serializedObject.ApplyModifiedProperties() ||
(Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")
) {
component.Clear();
if (!Application.isPlaying) {
if (serializedObject.ApplyModifiedProperties() ||
(Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")
) {
component.Clear();
component.Update();
}
}
}
}

View File

@ -78,19 +78,21 @@ public class SkeletonDataAssetInspector : Editor {
EditorGUILayout.BeginHorizontal();
EditorGUILayout.Space();
if (GUILayout.Button("Add Mix")) {
duration.InsertArrayElementAtIndex(fromAnimation.arraySize);
toAnimation.InsertArrayElementAtIndex(fromAnimation.arraySize);
fromAnimation.InsertArrayElementAtIndex(fromAnimation.arraySize);
duration.arraySize++;
toAnimation.arraySize++;
fromAnimation.arraySize++;
}
EditorGUILayout.Space();
EditorGUILayout.EndHorizontal();
}
}
if (serializedObject.ApplyModifiedProperties() ||
(Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")
) {
asset.Clear();
if (!Application.isPlaying) {
if (serializedObject.ApplyModifiedProperties() ||
(Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")
) {
asset.Clear();
}
}
}
}

View File

@ -56,8 +56,8 @@ public class AtlasAsset : ScriptableObject {
try {
atlas = new Atlas(new StringReader(atlasFile.text), "", new SingleTextureLoader(material));
return atlas;
} catch (Exception) {
Debug.LogException(new Exception("Error reading atlas file for atlas asset: " + name), this);
} catch (Exception ex) {
Debug.Log("Error reading atlas file for atlas asset: " + name + "\n" + ex.Message + "\n" + ex.StackTrace, this);
return null;
}
}

View File

@ -60,14 +60,21 @@ public class SkeletonComponent : MonoBehaviour {
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 () {
// Clear fields if missing information to render.
if (skeletonDataAsset == null || skeletonDataAsset.GetSkeletonData(false) == null) {
Clear();
return;
}
// Initialize fields.
if (skeleton == null || skeleton.Data != skeletonDataAsset.GetSkeletonData(false))
Initialize();
@ -81,12 +88,8 @@ public class SkeletonComponent : MonoBehaviour {
state.SetAnimation(animation, loop);
}
state.Loop = loop;
// Apply animation.
skeleton.Update(Time.deltaTime * timeScale);
state.Update(Time.deltaTime * timeScale);
state.Apply(skeleton);
skeleton.UpdateWorldTransform();
UpdateAnimation();
// Count quads.
int quadCount = 0;

View File

@ -73,13 +73,15 @@ public class SkeletonDataAsset : ScriptableObject {
skeletonData = json.ReadSkeletonData(new StringReader(skeletonJSON.text));
} catch (Exception ex) {
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;
}
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]);
}
return skeletonData;
}