Skip to content

Commit

Permalink
Hotfix build v1.0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
HappyFaceIndustries committed Aug 5, 2015
1 parent 4b89ed0 commit d495fab
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 45 deletions.
47 changes: 30 additions & 17 deletions KerbalAnimationSuite/API/KerbalAnimationClip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,25 +357,38 @@ public void SetValue(float value, string animationName, KAS_ValueType type)

public float GetValue(string animationName, KAS_ValueType type)
{
switch (type)
try
{
case KAS_ValueType.RotW:
return RotationW [animationName];
case KAS_ValueType.RotX:
return RotationX [animationName];
case KAS_ValueType.RotY:
return RotationY [animationName];
case KAS_ValueType.RotZ:
return RotationZ [animationName];
case KAS_ValueType.PosX:
return PositionX [animationName];
case KAS_ValueType.PosY:
return PositionY [animationName];
case KAS_ValueType.PosZ:
return PositionZ [animationName];
default:
return 0f;
switch (type)
{
case KAS_ValueType.RotW:
return RotationW [animationName];
case KAS_ValueType.RotX:
return RotationX [animationName];
case KAS_ValueType.RotY:
return RotationY [animationName];
case KAS_ValueType.RotZ:
return RotationZ [animationName];
case KAS_ValueType.PosX:
return PositionX [animationName];
case KAS_ValueType.PosY:
return PositionY [animationName];
case KAS_ValueType.PosZ:
return PositionZ [animationName];
default:
return 0f;
}
}
catch(KeyNotFoundException e)
{
//ignore colliders
if (animationName.ToLower ().Contains ("collider"))
return 0f;

Debug.LogError ("key not found: " + animationName);
Debug.LogException (e);
}
return 0f;
}
}
private enum KAS_ValueType
Expand Down
47 changes: 30 additions & 17 deletions KerbalAnimationSuite/KAS_AnimationClip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -432,25 +432,38 @@ public void SetValue(float value, string animationName, KAS_ValueType type)
/// <param name="type">Type.</param>
public float GetValue(string animationName, KAS_ValueType type)
{
switch (type)
try
{
case KAS_ValueType.RotW:
return RotationW [animationName];
case KAS_ValueType.RotX:
return RotationX [animationName];
case KAS_ValueType.RotY:
return RotationY [animationName];
case KAS_ValueType.RotZ:
return RotationZ [animationName];
case KAS_ValueType.PosX:
return PositionX [animationName];
case KAS_ValueType.PosY:
return PositionY [animationName];
case KAS_ValueType.PosZ:
return PositionZ [animationName];
default:
return 0f;
switch (type)
{
case KAS_ValueType.RotW:
return RotationW [animationName];
case KAS_ValueType.RotX:
return RotationX [animationName];
case KAS_ValueType.RotY:
return RotationY [animationName];
case KAS_ValueType.RotZ:
return RotationZ [animationName];
case KAS_ValueType.PosX:
return PositionX [animationName];
case KAS_ValueType.PosY:
return PositionY [animationName];
case KAS_ValueType.PosZ:
return PositionZ [animationName];
default:
return 0f;
}
}
catch(KeyNotFoundException e)
{
//ignore colliders
if (animationName.ToLower ().Contains ("collider"))
return 0f;

Debug.LogError ("key not found: " + animationName);
Debug.LogException (e);
}
return 0f;
}
}

Expand Down
50 changes: 39 additions & 11 deletions KerbalAnimationSuite/KerbalAnimationSuite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,14 @@ void DrawBoneSelection(string boneName)

void UpdateAnimation()
{

if (Input.GetKey (KeyCode.LeftAlt) && Input.GetKeyDown (KeyCode.Minus))
{
Debug.Log ("evaPart: " + (evaPart == null ? "null" : "object"));
Debug.Log ("eva: " + (eva == null ? "null" : "object"));
Debug.Log ("joints01: " + (joints01 == null ? "null" : "object"));
Debug.Log ("AnimationNames: " + (AnimationNames == null ? "null" : "object"));
Debug.Log ("currentBoneTrns: " + (currentBoneTrns == null ? "null" : "object"));
}
}
List<KFSMState> GetEVAStates()
{
Expand Down Expand Up @@ -630,6 +637,9 @@ void PrintAnimationStates()
string loadAnimErrorText = "";
string tempSavePath = "";
string saveAnimErrorText = "";
string tempDurationString = "1";

ScreenMessage errorMessage = new ScreenMessage ("", 20000f, ScreenMessageStyle.UPPER_CENTER);

int animPage = 0;
int animPageCount = 2;
Expand Down Expand Up @@ -739,9 +749,7 @@ void AnimationWindow(int id)
GUILayout.Space (20f);
GUILayout.BeginHorizontal ();
GUILayout.Label ("Animation Duration: ");
string duration = animationClip.Duration.ToString();
duration = GUILayout.TextField (duration);
animationClip.Duration = float.Parse (duration);
tempDurationString = GUILayout.TextField (tempDurationString);
GUILayout.EndHorizontal ();
}
else
Expand Down Expand Up @@ -882,7 +890,7 @@ void AnimationWindow(int id)
if (GUILayout.Button ("Rebuild <color=orange>animation_hierarchy.dat</color>"))
{
PopulateAnimationNames ();
SaveAnimationNames ("KerbalAnimationSuite/animation_hierarchy");
SaveAnimationNames ("KerbalAnimationSuite/Config/animation_hierarchy");
}

GUILayout.EndScrollView ();
Expand Down Expand Up @@ -912,13 +920,16 @@ void AnimationWindow(int id)

Debug.Log ("Playing...");
evaPart.animation.Play ("CustomClip");

ScreenMessages.PostScreenMessage (errorMessage);
}
if (isPlayingAnimation && GUILayout.Button ("Stop Animation"))
{
evaPart.animation.Stop ();
SetAnimationTime (1f);
Debug.Log ("Stopping...");
isPlayingAnimation = false;
ScreenMessages.RemoveMessage (errorMessage);
}

if (animPage < animPageCount - 1)
Expand All @@ -940,21 +951,37 @@ void RebuildAnimationClip()
int line = 0;
try
{
try
{
animationClip.Duration = float.Parse (tempDurationString);
}
catch
{
tempDurationString = "1";
errorMessage.message = "<color=red>Invalid Duration value</color>";
animationClip.Duration = 1f;
}
animationClip.BuildAnimationClip ();
line = 1;
animation.RemoveClip ("CustomClip");
if(debug)
{
Debug.Log("animation: " + (evaPart.animation == null ? "null" : "object"));
Debug.Log("animationClip.clip: " + (animationClip.clip == null ? "null" : "object"));
}
if(evaPart.animation.GetClip("CustomClip") != null)
evaPart.animation.RemoveClip ("CustomClip");
line = 2;
animation.AddClip (animationClip, "CustomClip");
evaPart.animation.AddClip (animationClip, "CustomClip");
line = 3;
animation ["CustomClip"].layer = animationClip.Layer;
evaPart.animation ["CustomClip"].layer = animationClip.Layer;
line = 4;
foreach(var mt in animationClip.MixingTransforms)
{
line = 5;
if (KerbalAnimationSuite.AnimationNames.ContainsKey (mt) && transform.Find (AnimationNames [mt]) != null)
{
line = 6;
animation ["CustomClip"].AddMixingTransform (transform.Find (AnimationNames [mt]));
evaPart.animation ["CustomClip"].AddMixingTransform (transform.Find (AnimationNames [mt]));
line = 7;
}
else
Expand All @@ -966,9 +993,10 @@ void RebuildAnimationClip()
}
line = 10;
}
catch
catch(Exception e)
{
Debug.Log ("Line: " + line);
Debug.LogError (" Error encountered: Line: " + line);
Debug.LogException (e);
}
}
void SetAnimationTime(float normalizedTime, string animationName = "CustomClip")
Expand Down

0 comments on commit d495fab

Please sign in to comment.