private static bool parsePropertyTo(JSONAction a) { //AMTween.PlayAudio(audioSource, AMTween.Hash ("delay", getWaitTime(frameRate), "audioclip", audioClip, "loop", loop)); Hashtable hash = new Hashtable(); hash.Add("disable", true); hash.Add("delay", a.delay); hash.Add("time", a.time); setupHashEase(hash, a); if (a.strings == null || a.strings.Length < 2) { Debug.LogWarning("Animator: PropertyTo missing Component or property type."); return(false); } string componentName = a.strings[0]; bool missingTargets = false; switch (a.strings[1]) { case "morph": if (a.floats == null || a.floatsExtra == null) { missingTargets = true; } hash.Add("methodtype", "morph"); hash.Add("methodinfo", getMethodInfo(a.go, "MegaMorph", "SetPercent", new string[] { "System.Int32", "System.Single" })); hash.Add("from", a.floats); hash.Add("to", a.floatsExtra); break; case "integer": if (a.ints == null || a.ints.Length < 2) { missingTargets = true; } hash.Add("from", a.ints[0]); hash.Add("to", a.ints[1]); setupHashFieldOrPropertyInfo(hash, a); break; case "long": if (a.longs == null || a.longs.Length < 2) { missingTargets = true; } hash.Add("from", a.longs[0]); hash.Add("to", a.longs[1]); setupHashFieldOrPropertyInfo(hash, a); break; case "float": if (a.floats == null || a.floats.Length < 2) { missingTargets = true; } hash.Add("from", a.floats[0]); hash.Add("to", a.floats[1]); setupHashFieldOrPropertyInfo(hash, a); break; case "double": if (a.doubles == null || a.doubles.Length < 2) { missingTargets = true; } hash.Add("from", a.doubles[0]); hash.Add("to", a.doubles[1]); setupHashFieldOrPropertyInfo(hash, a); break; case "vector2": if (a.vect2s == null || a.vect2s.Length < 2) { missingTargets = true; } hash.Add("from", a.vect2s[0].toVector2()); hash.Add("to", a.vect2s[1].toVector2()); setupHashFieldOrPropertyInfo(hash, a); break; case "vector3": if (a.path == null || a.path.Length < 2) { missingTargets = true; } hash.Add("from", a.path[0].toVector3()); hash.Add("to", a.path[1].toVector3()); setupHashFieldOrPropertyInfo(hash, a); break; case "color": if (a.colors == null || a.colors.Length < 2) { missingTargets = true; } hash.Add("from", a.colors[0].toColor()); hash.Add("to", a.colors[1].toColor()); setupHashFieldOrPropertyInfo(hash, a); break; case "rect": if (a.rects == null || a.rects.Length < 2) { missingTargets = true; } hash.Add("from", a.rects[0].toRect()); hash.Add("to", a.rects[1].toRect()); setupHashFieldOrPropertyInfo(hash, a); break; default: Debug.LogWarning("Animator: PropertyTo unknown property type '" + a.strings[1] + "'."); return(false); } if (missingTargets) { Debug.LogWarning("Animator: PropertyTo missing 'to' or 'from' targets."); return(false); } AMTween.PropertyTo(getCMP(a.go, componentName), hash); //AMTween.PlayAudio((AudioSource)getCMP(a.go,"AudioSource"), hash); return(true); }
public override void execute(int frameRate, float delay) { if (targetsAreEqual()) { return; } if ((endFrame == -1) || !component || ((fieldInfo == null) && (propertyInfo == null) && (methodInfo == null))) { return; } if (fieldInfo != null) { if (hasCustomEase()) { if (AMPropertyTrack.isValueTypeNumeric(valueType)) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "fieldinfo", fieldInfo, "from", start_val, "to", end_val, "easecurve", easeCurve)); } if (valueType == (int)AMPropertyTrack.ValueType.Vector2) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "fieldinfo", fieldInfo, "from", start_vect2, "to", end_vect2, "easecurve", easeCurve)); } if (valueType == (int)AMPropertyTrack.ValueType.Vector3) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "fieldinfo", fieldInfo, "from", start_vect3, "to", end_vect3, "easecurve", easeCurve)); } if (valueType == (int)AMPropertyTrack.ValueType.Color) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "fieldinfo", fieldInfo, "from", start_color, "to", end_color, "easecurve", easeCurve)); } if (valueType == (int)AMPropertyTrack.ValueType.Rect) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "fieldinfo", fieldInfo, "from", start_vect2, "to", end_vect2, "easecurve", easeCurve)); } if (valueType == (int)AMPropertyTrack.ValueType.String) { CoroutineBehaviour.StartCoroutineDelay(component.gameObject, (x) => { fieldInfo.SetValue(component, start_str); }, getWaitTime(frameRate, delay)); } } else { if (AMPropertyTrack.isValueTypeNumeric(valueType)) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "fieldinfo", fieldInfo, "from", start_val, "to", end_val, "easetype", (AMTween.EaseType)easeType)); } if (valueType == (int)AMPropertyTrack.ValueType.Vector2) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "fieldinfo", fieldInfo, "from", start_vect2, "to", end_vect2, "easetype", (AMTween.EaseType)easeType)); } if (valueType == (int)AMPropertyTrack.ValueType.Vector3) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "fieldinfo", fieldInfo, "from", start_vect3, "to", end_vect3, "easetype", (AMTween.EaseType)easeType)); } if (valueType == (int)AMPropertyTrack.ValueType.Color) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "fieldinfo", fieldInfo, "from", start_color, "to", end_color, "easetype", (AMTween.EaseType)easeType)); } if (valueType == (int)AMPropertyTrack.ValueType.Rect) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "fieldinfo", fieldInfo, "from", start_vect2, "to", end_vect2, "easetype", (AMTween.EaseType)easeType)); } if (valueType == (int)AMPropertyTrack.ValueType.String) { CoroutineBehaviour.StartCoroutineDelay(component.gameObject, SetStringFunc, getWaitTime(frameRate, delay)); } } } else if (propertyInfo != null) { if (hasCustomEase()) { if (AMPropertyTrack.isValueTypeNumeric(valueType)) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "propertyinfo", propertyInfo, "from", start_val, "to", end_val, "easecurve", easeCurve)); } if (valueType == (int)AMPropertyTrack.ValueType.Vector2) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "propertyinfo", propertyInfo, "from", start_vect2, "to", end_vect2, "easecurve", easeCurve)); } if (valueType == (int)AMPropertyTrack.ValueType.Vector3) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "propertyinfo", propertyInfo, "from", start_vect3, "to", end_vect3, "easecurve", easeCurve)); } if (valueType == (int)AMPropertyTrack.ValueType.Color) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "propertyinfo", propertyInfo, "from", start_color, "to", end_color, "easecurve", easeCurve)); } if (valueType == (int)AMPropertyTrack.ValueType.Rect) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "propertyinfo", propertyInfo, "from", start_vect2, "to", end_vect2, "easecurve", easeCurve)); } if (valueType == (int)AMPropertyTrack.ValueType.String) { CoroutineBehaviour.StartCoroutineDelay(component.gameObject, (x) => { propertyInfo.SetValue(component, start_str, null); }, getWaitTime(frameRate, delay)); } } else { if (AMPropertyTrack.isValueTypeNumeric(valueType)) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "propertyinfo", propertyInfo, "from", start_val, "to", end_val, "easetype", (AMTween.EaseType)easeType)); } if (valueType == (int)AMPropertyTrack.ValueType.Vector2) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "propertyinfo", propertyInfo, "from", start_vect2, "to", end_vect2, "easetype", (AMTween.EaseType)easeType)); } if (valueType == (int)AMPropertyTrack.ValueType.Vector3) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "propertyinfo", propertyInfo, "from", start_vect3, "to", end_vect3, "easetype", (AMTween.EaseType)easeType)); } if (valueType == (int)AMPropertyTrack.ValueType.Color) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "propertyinfo", propertyInfo, "from", start_color, "to", end_color, "easetype", (AMTween.EaseType)easeType)); } if (valueType == (int)AMPropertyTrack.ValueType.Rect) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "propertyinfo", propertyInfo, "from", start_vect2, "to", end_vect2, "easetype", (AMTween.EaseType)easeType)); } if (valueType == (int)AMPropertyTrack.ValueType.String) { CoroutineBehaviour.StartCoroutineDelay(component.gameObject, (x) => { propertyInfo.SetValue(component, start_str, null); }, getWaitTime(frameRate, delay)); } } } else if (methodInfo != null) { if (hasCustomEase()) { if (valueType == (int)AMPropertyTrack.ValueType.MorphChannels) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "methodtype", "morph", "methodinfo", methodInfo, "from", start_morph.ToArray(), "to", end_morph.ToArray(), "easecurve", easeCurve)); } } else { if (valueType == (int)AMPropertyTrack.ValueType.MorphChannels) { AMTween.PropertyTo(component, AMTween.Hash("delay", getWaitTime(frameRate, delay), "time", getTime(frameRate), "methodtype", "morph", "methodinfo", methodInfo, "from", start_morph.ToArray(), "to", end_morph.ToArray(), "easetype", (AMTween.EaseType)easeType)); } } } else { Debug.LogError("Animator: No FieldInfo or PropertyInfo set."); } }