public bool hasSamePropertyAs(AMPropertyTrack _track)
 {
     if (_track.obj == obj && _track.component == component && _track.getTrackType() == getTrackType())
     {
         return(true);
     }
     return(false);
 }
    public string getValueString(bool brief)
    {
        string s = "";

        if (AMPropertyTrack.isValueTypeNumeric(valueType))
        {
            //s+= start_val.ToString();
            s += formatNumeric(start_val);
            if (!brief && endFrame != -1)
            {
                s += " -> " + formatNumeric(end_val);
            }
            //if(!brief && endFrame != -1) s += " -> "+end_val.ToString();
        }
        else if (valueType == (int)AMPropertyTrack.ValueType.Vector2)
        {
            s += start_vect2.ToString();
            if (!brief && endFrame != -1)
            {
                s += " -> " + end_vect2.ToString();
            }
        }
        else if (valueType == (int)AMPropertyTrack.ValueType.Vector3)
        {
            s += start_vect3.ToString();
            if (!brief && endFrame != -1)
            {
                s += " -> " + end_vect3.ToString();
            }
        }
        else if (valueType == (int)AMPropertyTrack.ValueType.Color)
        {
            //return null;
            s += start_color.ToString();
            if (!brief && endFrame != -1)
            {
                s += " -> " + end_color.ToString();
            }
        }
        else if (valueType == (int)AMPropertyTrack.ValueType.Rect)
        {
            //return null;
            s += start_rect.ToString();
            if (!brief && endFrame != -1)
            {
                s += " -> " + end_rect.ToString();
            }
        }
        else if (valueType == (int)AMPropertyTrack.ValueType.String)
        {
            s += start_str;
        }
        return(s);
    }
Beispiel #3
0
    void OnGUI()
    {
        AMTimeline.loadSkin(oData, ref skin, ref cachedSkinName, position);
        if (!aData)
        {
            AMTimeline.MessageBox("Animator requires an AnimatorData component in your scene. Launch Animator to add the component.", AMTimeline.MessageBoxType.Warning);
            return;
        }
        if (!track)
        {
            return;
        }
        if (!(track).obj)
        {
            AMTimeline.MessageBox("Assign a GameObject to the track first.", AMTimeline.MessageBoxType.Warning);
            return;
        }
        GUILayout.Label("Select a property to add to track '" + track.name + "'" /*, styleLabel*/);
        scrollView = GUILayout.BeginScrollView(scrollView);
        if (arrComponents != null && arrComponents.Length > 0)
        {
            for (int i = 0; i < arrComponents.Length; i++)
            {
                // skip behaviours because they may repeat properties
                // if script is missing (unlikely but it happens in error) then catch and skip
                try {
                    if (arrComponents[i].GetType() == typeof(Behaviour))
                    {
                        continue;
                    }
                } catch {
                    continue;
                }
                Component myComponent = _go.GetComponent(arrComponents[i].GetType());
                if (myComponent == null)
                {
                    continue;
                }

                // component button
                GUILayout.BeginHorizontal(GUILayout.Width(position.width - 5f));
                string componentName = myComponent.GetType().Name;
                if (GUILayout.Button(componentName /*,buttonStyle*/))
                {
                    if (selectionIndex != i)
                    {
                        selectionIndex = i;
                    }
                    else
                    {
                        selectionIndex = -1;
                    }
                }
                string lblToggle;
                if (selectionIndex != i)
                {
                    lblToggle = "+";
                }
                else
                {
                    lblToggle = "-";
                }

                GUILayout.Label(lblToggle, GUILayout.Width(15f));

                GUILayout.EndHorizontal();

                if (selectionIndex == i)
                {
                    //scrollViewComponent = GUILayout.BeginScrollView(scrollViewComponent);
                    int numberOfProperties = 0;
                    // check for special properties
                    if (componentName == "MegaMorph")
                    {
                        processMegaMorph(myComponent);
                        numberOfProperties++;
                    }
                    FieldInfo[] fields = myComponent.GetType().GetFields();
                    // loop through all fields sfields
                    foreach (FieldInfo fieldInfo in fields)
                    {
                        if (!AMPropertyTrack.isValidType(fieldInfo.FieldType))
                        {
                            // invalid type
                            continue;
                        }
                        // fields
                        GUILayout.BeginHorizontal();
                        // field button
                        if (GUILayout.Button(fieldInfo.Name, GUILayout.Width(150f)))
                        {
                            // select the field
                            processSelectProperty(myComponent, fieldInfo, null);
                        }
                        GUILayout.Label(fieldInfo.GetValue(myComponent).ToString());
                        GUILayout.EndHorizontal();
                        numberOfProperties++;
                    }
                    PropertyInfo[] properties = myComponent.GetType().GetProperties();
                    // properties
                    foreach (PropertyInfo propertyInfo in properties)
                    {
                        if (propertyInfo.PropertyType == typeof(HideFlags))
                        {
                            continue;
                        }
                        if (shouldIgnoreProperty(propertyInfo.Name))
                        {
                            continue;
                        }
                        if (propertyInfo.CanWrite && AMPropertyTrack.isValidType(propertyInfo.PropertyType))
                        {
                            object propertyValue;
                            try{
                                propertyValue = propertyInfo.GetValue(myComponent, null);
                            } catch {
                                continue;
                            }
                            GUILayout.BeginHorizontal();
                            if (GUILayout.Button(propertyInfo.Name, GUILayout.Width(150f)))
                            {
                                // select the property
                                processSelectProperty(myComponent, null, propertyInfo);
                            }

                            GUILayout.Label(propertyValue.ToString());
                            GUILayout.EndHorizontal();
                            numberOfProperties++;
                        }
                    }
                    if (numberOfProperties <= 0)
                    {
                        GUILayout.Label("No usable properties found");
                    }
                    //GUILayout.EndScrollView();
                }
            }
        }
        GUILayout.EndScrollView();
    }
Beispiel #4
0
 public static void setValues(AMPropertyTrack _track)
 {
     track = _track;
 }
 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.");
     }
 }
    public override string ToString(int codeLanguage, int frameRate)
    {
        if (endFrame == -1 || targetsAreEqual())
        {
            return(null);
        }
        string memberInfoType = "";

        if (fieldInfo != null)
        {
            memberInfoType = "fieldinfo";
        }
        else if (propertyInfo != null)
        {
            memberInfoType = "propertyinfo";
        }
        else if (methodInfo != null)
        {
            memberInfoType = "methodinfo";
        }
        else
        {
            Debug.LogError("Animator: No FieldInfo or PropertyInfo set.");
            return("( Error: No FieldInfo, PropertyInfo or MethodInfo set. )");
        }
        if (codeLanguage == 0)
        {
            // c#
            if (valueType == (int)AMPropertyTrack.ValueType.MorphChannels)
            {
                return("AMTween.PropertyTo(obj.gameObject, AMTween.Hash(\"delay\", " + getWaitTime(frameRate, 0f) + "f, \"time\", " + getTime(frameRate) + "f, \"" + memberInfoType + "\", obj.memberinfo, \"methodtype\", \"morph\", \"from\", " + getFloatArrayString(codeLanguage, start_morph) + ", \"to\", " + getFloatArrayString(codeLanguage, end_morph) + ", " + getEaseString(codeLanguage) + "));");
            }
            if (AMPropertyTrack.isValueTypeNumeric(valueType))
            {
                return("AMTween.PropertyTo(obj.gameObject, AMTween.Hash(\"delay\", " + getWaitTime(frameRate, 0f) + "f, \"time\", " + getTime(frameRate) + "f, \"" + memberInfoType + "\", obj.memberinfo, \"from\", " + start_val + "f,\"to\", " + end_val + "f, " + getEaseString(codeLanguage) + "));");
            }
            if (valueType == (int)AMPropertyTrack.ValueType.Vector2)
            {
                return("AMTween.PropertyTo(obj.gameObject, AMTween.Hash(\"delay\", " + getWaitTime(frameRate, 0f) + "f, \"time\", " + getTime(frameRate) + "f, \"" + memberInfoType + "\", obj.memberinfo, \"from\", new Vector2(" + start_vect2.x + "f, " + start_vect2.y + "f), \"to\", new Vector2(" + end_vect2.x + "f, " + end_vect2.y + "f), " + getEaseString(codeLanguage) + "));");
            }
            if (valueType == (int)AMPropertyTrack.ValueType.Vector3)
            {
                return("AMTween.PropertyTo(obj.gameObject, AMTween.Hash(\"delay\", " + getWaitTime(frameRate, 0f) + "f, \"time\", " + getTime(frameRate) + "f, \"" + memberInfoType + "\", obj.memberinfo, \"from\", new Vector3(" + start_vect3.x + "f, " + start_vect3.y + "f, " + start_vect3.z + "f), \"to\", new Vector3(" + end_vect3.x + "f, " + end_vect3.y + "f, " + end_vect3.z + "f), " + getEaseString(codeLanguage) + "));");
            }
            if (valueType == (int)AMPropertyTrack.ValueType.Color)
            {
                return("AMTween.PropertyTo(obj.gameObject, AMTween.Hash(\"delay\", " + getWaitTime(frameRate, 0f) + "f, \"time\", " + getTime(frameRate) + "f, \"" + memberInfoType + "\", obj.memberinfo, \"from\", new Color(" + start_color.r + "f, " + start_color.g + "f, " + start_color.b + "f, " + start_color.a + "f), \"to\", new Color(" + end_color.r + "f, " + end_color.g + "f, " + end_color.b + "f, " + end_color.a + "f), " + getEaseString(codeLanguage) + "));");
            }
            if (valueType == (int)AMPropertyTrack.ValueType.Rect)
            {
                return("AMTween.PropertyTo(obj.gameObject, AMTween.Hash(\"delay\", " + getWaitTime(frameRate, 0f) + "f, \"time\", " + getTime(frameRate) + "f, \"" + memberInfoType + "\", obj.memberinfo, \"from\", new Rect(" + start_rect.x + "f, " + start_rect.y + "f, " + start_rect.width + "f, " + start_rect.height + "f), \"to\", new Rect(" + end_rect.x + "f, " + end_rect.y + "f, " + end_rect.width + "f, " + end_rect.height + "f), " + getEaseString(codeLanguage) + "));");
            }
            if (valueType == (int)AMPropertyTrack.ValueType.String)
            {
                return("//No code view for AMProperty with string property (<©f¦Ø¡¤)¡î");
            }
            return("( Error: ValueType " + valueType + " not found )");
        }
        else
        {
            // js
            if (valueType == (int)AMPropertyTrack.ValueType.MorphChannels)
            {
                return("AMTween.PropertyTo(obj.gameObject, {\"delay\": " + getWaitTime(frameRate, 0f) + ", \"time\": " + getTime(frameRate) + ", \"" + memberInfoType + "\": obj.memberinfo, \"methodtype\": \"morph\", \"from\": " + getFloatArrayString(codeLanguage, start_morph) + ", \"to\": " + getFloatArrayString(codeLanguage, end_morph) + ", " + getEaseString(codeLanguage) + "));");
            }
            if (AMPropertyTrack.isValueTypeNumeric(valueType))
            {
                return("AMTween.PropertyTo(obj.gameObject, {\"delay\": " + getWaitTime(frameRate, 0f) + ", \"time\": " + getTime(frameRate) + ", \"" + memberInfoType + "\": obj.memberinfo, \"from\": " + start_val + ",\"to\": " + end_val + ", " + getEaseString(codeLanguage) + "});");
            }
            if (valueType == (int)AMPropertyTrack.ValueType.Vector2)
            {
                return("AMTween.PropertyTo(obj.gameObject, {\"delay\": " + getWaitTime(frameRate, 0f) + ", \"time\": " + getTime(frameRate) + ", \"" + memberInfoType + "\": obj.memberinfo, \"from\": Vector2(" + start_vect2.x + ", " + start_vect2.y + "), \"to\": Vector2(" + end_vect2.x + ", " + end_vect2.y + "), " + getEaseString(codeLanguage) + "});");
            }
            if (valueType == (int)AMPropertyTrack.ValueType.Vector3)
            {
                return("AMTween.PropertyTo(obj.gameObject, {\"delay\": " + getWaitTime(frameRate, 0f) + ", \"time\": " + getTime(frameRate) + ", \"" + memberInfoType + "\": obj.memberinfo, \"from\": Vector3(" + start_vect3.x + ", " + start_vect3.y + ", " + start_vect3.z + "), \"to\": Vector3(" + end_vect3.x + ", " + end_vect3.y + ", " + end_vect3.z + "), " + getEaseString(codeLanguage) + "});");
            }
            if (valueType == (int)AMPropertyTrack.ValueType.Color)
            {
                return("AMTween.PropertyTo(obj.gameObject, {\"delay\": " + getWaitTime(frameRate, 0f) + ", \"time\": " + getTime(frameRate) + ", \"" + memberInfoType + "\": obj.memberinfo, \"from\": Color(" + start_color.r + ", " + start_color.g + ", " + start_color.b + ", " + start_color.a + "), \"to\": Color(" + end_color.r + ", " + end_color.g + ", " + end_color.b + ", " + end_color.a + "), " + getEaseString(codeLanguage) + "});");
            }
            if (valueType == (int)AMPropertyTrack.ValueType.Rect)
            {
                return("AMTween.PropertyTo(obj.gameObject, {\"delay\": " + getWaitTime(frameRate, 0f) + ", \"time\": " + getTime(frameRate) + ", \"" + memberInfoType + "\": obj.memberinfo, \"from\": Rect(" + start_rect.x + ", " + start_rect.y + ", " + start_rect.width + ", " + start_rect.height + "), \"to\": Rect(" + end_rect.x + ", " + end_rect.y + ", " + end_rect.width + ", " + end_rect.height + "), " + getEaseString(codeLanguage) + "});");
            }
            if (valueType == (int)AMPropertyTrack.ValueType.String)
            {
                return("//No code view for AMProperty with string property (<©f¦Ø¡¤)¡î");
            }
            return("( Error: ValueType " + valueType + " not found )");
        }
    }
 public bool hasSamePropertyAs(AMPropertyTrack _track)
 {
     if(_track.obj == obj && _track.component == component && _track.getTrackType() == getTrackType())
         return true;
     return false;
 }
 void OnDisable()
 {
     window = null;
     track = null;
 }
 public static void setValues(AMPropertyTrack _track)
 {
     track = _track;
 }
Beispiel #10
0
    AMActionData GenerateActionData(AMPropertyTrack propTrack, int frameRate, Component comp, object obj)
    {
        propTrack.RefreshData(comp);

        PropertyInfo propInfo = propTrack.GetCachedPropertyInfo();
        if(propInfo != null)
            return new AMActionPropertySet(this, frameRate, comp, propInfo, obj);
        else {
            FieldInfo fieldInfo = propTrack.GetCachedFieldInfo();
            if(fieldInfo != null)
                return new AMActionFieldSet(this, frameRate, comp, fieldInfo, obj);
        }
        return null;
    }
 public bool hasSamePropertyAs(AMITarget target, AMPropertyTrack _track)
 {
     if(_track.GetTarget(target) == GetTarget(target) && _track.GetTargetComp(target) == GetTargetComp(target) && _track.getTrackType() == getTrackType())
         return true;
     return false;
 }