Ejemplo n.º 1
0
        void _Object_ObjectChanged(object sender, System.EventArgs e)
        {
            if (IgnoreChanges)
            {
                return;
            }
            PropertyTrack <V> track = GetTrack();

            track.Object = _Object.Object;
            track.Invalidate();
            RebuildComponent();
            SetDirty();
        }
Ejemplo n.º 2
0
        public void Run(AnimationDescription desc)
        {
            foreach (var p in desc.Properties)
            {
                var t = new PropertyTrack(p);
                tracks.Add(t);
                t.Start(totalTime);
            }

            foreach (var a in desc.Actions)
            {
                var t = new ActionTrack(a);
                tracks.Add(t);
                t.Start(totalTime);
            }
        }
Ejemplo n.º 3
0
        void _Component_OptionChanged(object sender, System.EventArgs e)
        {
            if (IgnoreChanges)
            {
                return;
            }
            PropertyTrack <V> track = GetTrack();

            if (_Component.SelectedOption != null)
            {
                track.Component = (Component)_Component.SelectedOption.UserData;
            }
            else
            {
                track.Component = null;
            }
            track.Invalidate();
            RebuildProperties();
            SetDirty();
        }
Ejemplo n.º 4
0
        private void RefreshDefaultValue()
        {
            PropertyTrack <V> track = GetTrack();

            if (!string.IsNullOrEmpty(track.PropertyName) && track.Component != null)
            {
                PropertyInfo[] infos = track.Component.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
                foreach (var info in infos)
                {
                    if (info.Name == track.PropertyName)
                    {
                        if (info.PropertyType == track.PropertyType && info.CanWrite)
                        {
                            GetTrackBar().UpdateDefaultValue((V)info.GetGetMethod().Invoke(track.Component, null));
                            base.Refresh();
                        }
                        break;
                    }
                }
            }
        }
Ejemplo n.º 5
0
        void _Property_OptionChanged(object sender, System.EventArgs e)
        {
            if (IgnoreChanges)
            {
                return;
            }
            PropertyTrack <V> track = GetTrack();

            if (_Property.SelectedOption != null)
            {
                if (track.PropertyName != (string)_Property.SelectedOption.UserData)
                {
                    track.PropertyName = (string)_Property.SelectedOption.UserData;
                    track.Invalidate();
                    RefreshDefaultValue();
                }
            }
            else
            {
                track.PropertyName = null;
            }
            SetDirty();
        }
Ejemplo n.º 6
0
        void OnGUI()
        {
            TimelineWindow.loadSkin(ref skin, ref cachedSkinName, position);
            if (aData == null)
            {
                TimelineWindow.MessageBox("Animator requires an Animate component in your scene. Launch Animator to add the component.", TimelineWindow.MessageBoxType.Warning);
                return;
            }
            if (track == null)
            {
                return;
            }
            if (!(track.GetTarget(aData.target) as GameObject))
            {
                TimelineWindow.MessageBox("Assign a GameObject to the track first.", TimelineWindow.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;
                        FieldInfo[] fields             = myComponent.GetType().GetFields();
                        // loop through all fields sfields
                        foreach (FieldInfo fieldInfo in fields)
                        {
                            if (!PropertyTrack.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);
                            }
                            object val = fieldInfo.GetValue(myComponent);
                            GUILayout.Label(val != null ? val.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 && PropertyTrack.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 != null ? propertyValue.ToString() : "null");
                                GUILayout.EndHorizontal();
                                numberOfProperties++;
                            }
                        }
                        if (numberOfProperties <= 0)
                        {
                            GUILayout.Label("No usable properties found");
                        }
                        //GUILayout.EndScrollView();
                    }
                }
            }
            GUILayout.EndScrollView();
        }
Ejemplo n.º 7
0
 void OnDisable()
 {
     window = null;
     track  = null;
 }
Ejemplo n.º 8
0
 public static void setValues(PropertyTrack _track)
 {
     track = _track;
 }
Ejemplo n.º 9
0
        IEnumerator DoConvertTake(AMTakeData oldTake, Take newTake, bool isMeta, string assetPath)
        {
            newTake.name            = oldTake.name;
            newTake.frameRate       = oldTake.frameRate;
            newTake.endFramePadding = oldTake.endFramePadding;
            newTake.numLoop         = oldTake.numLoop;
            newTake.loopMode        = oldTake.loopMode;
            newTake.loopBackToFrame = oldTake.loopBackToFrame;
            newTake.trackCounter    = oldTake.track_count;
            newTake.groupCounter    = oldTake.group_count;

            //go through groups
            newTake.rootGroup            = new Group();
            newTake.rootGroup.group_name = oldTake.rootGroup.group_name;
            newTake.rootGroup.group_id   = oldTake.rootGroup.group_id;
            newTake.rootGroup.elements   = new List <int>(oldTake.rootGroup.elements);
            newTake.rootGroup.foldout    = oldTake.rootGroup.foldout;

            newTake.groupValues = new List <Group>();
            foreach (var oldGroup in oldTake.groupValues)
            {
                var newGroup = new Group();
                newGroup.group_name = oldGroup.group_name;
                newGroup.group_id   = oldGroup.group_id;
                newGroup.elements   = new List <int>(oldGroup.elements);
                newGroup.foldout    = oldGroup.foldout;

                newTake.groupValues.Add(newGroup);
            }

            //go through tracks
            newTake.trackValues = new List <Track>();
            foreach (var oldTrack in oldTake.trackValues)
            {
                AddMessage("  - convert track: " + oldTrack.name);

                Track newTrack = null;

                if (oldTrack is AMAnimationTrack)
                {
                    newTrack = new UnityAnimationTrack();

                    ConvertTrackCommonFields(oldTrack, newTrack, true, isMeta);

                    newTrack.keys = new List <Key>();
                    foreach (AMAnimationKey oldKey in oldTrack.keys)
                    {
                        var newKey = new UnityAnimationKey();

                        ConvertKeyCommonFields(oldKey, newKey);

                        newKey.wrapMode      = oldKey.wrapMode;
                        newKey.amClip        = oldKey.amClip;
                        newKey.crossfade     = oldKey.crossfade;
                        newKey.crossfadeTime = oldKey.crossfadeTime;

                        newTrack.keys.Add(newKey);
                    }
                }
                else if (oldTrack is AMAudioTrack)
                {
                    newTrack = new AudioTrack();

                    ConvertTrackCommonFields(oldTrack, newTrack, true, isMeta);

                    newTrack.keys = new List <Key>();
                    foreach (AMAudioKey oldKey in oldTrack.keys)
                    {
                        var newKey = new AudioKey();

                        ConvertKeyCommonFields(oldKey, newKey);

                        newKey.audioClip = oldKey.audioClip;
                        newKey.loop      = oldKey.loop;
                        newKey.oneShot   = oldKey.oneShot;

                        newTrack.keys.Add(newKey);
                    }
                }
                else if (oldTrack is AMCameraSwitcherTrack)
                {
                    newTrack = new CameraSwitcherTrack();

                    ConvertTrackCommonFields(oldTrack, newTrack, true, isMeta);

                    newTrack.keys = new List <Key>();
                    for (int i = 0; i < oldTrack.keys.Count; i++)
                    {
                        var oldKey = (AMCameraSwitcherKey)oldTrack.keys[i];
                        var newKey = new CameraSwitcherKey();

                        ConvertKeyCommonFields(oldKey, newKey);

                        newKey.type                 = oldKey.type;
                        newKey.typeEnd              = oldKey.typeEnd;
                        newKey.color                = oldKey.color;
                        newKey.colorEnd             = oldKey.colorEnd;
                        newKey.cameraFadeType       = oldKey.cameraFadeType;
                        newKey.cameraFadeParameters = new List <float>(oldKey.cameraFadeParameters);
                        newKey.irisShape            = oldKey.irisShape;
                        newKey.still                = oldKey.still;
                        newKey.endFrame             = oldKey.endFrame;

                        if (isMeta)
                        {
                            newKey.SetCameraDirect(null, oldKey.cameraTargetPath);
                            newKey.SetCameraEndDirect(null, oldKey.cameraEndTargetPath);
                        }
                        else
                        {
                            newKey.SetCameraDirect(oldKey.getCamera(null), "");
                            newKey.SetCameraDirect(oldKey.getCameraEnd(null), "");
                        }

                        newTrack.keys.Add(newKey);
                    }
                }
                else if (oldTrack is AMEventTrack)
                {
                    var newEventTrack = new EventTrack();
                    newTrack = newEventTrack;

                    ConvertTrackCommonFields(oldTrack, newTrack, false, isMeta);

                    newTrack.keys = new List <Key>();

                    string eventCompName = null;

                    //TODO: create new tracks per different components from keys
                    //for now we only allow conversion of one component, so the first key will be used.
                    foreach (AMEventKey oldKey in oldTrack.keys)
                    {
                        string keyCompName = oldKey.getComponentName();

                        if (string.IsNullOrEmpty(eventCompName))
                        {
                            if (!string.IsNullOrEmpty(keyCompName))
                            {
                                eventCompName = keyCompName;

                                AddMessage("   - EventTrack using component: " + eventCompName);

                                if (isMeta)
                                {
                                    newEventTrack.SetTargetAsComponentDirect(oldTrack.targetPath, null, eventCompName);
                                }
                                else
                                {
                                    newEventTrack.SetTargetAsComponentDirect("", oldKey.getComponentRef(), eventCompName);
                                }
                            }
                        }

                        //only add if component matched
                        if (string.IsNullOrEmpty(eventCompName) || keyCompName != eventCompName)
                        {
                            AddMessage("   - Cannot add EventKey with Component: " + eventCompName, Color.yellow);
                            continue;
                        }

                        var newKey = new EventKey();

                        ConvertKeyCommonFields(oldKey, newKey);

                        newKey.useSendMessage = oldKey.useSendMessage;
                        newKey.methodName     = oldKey.methodName;

                        newKey.parameters = new List <EventParameter>(oldKey.parameters.Count);
                        for (int i = 0; i < oldKey.parameters.Count; i++)
                        {
                            var oldParm = oldKey.parameters[i];
                            var newParm = new EventParameter();

                            ConvertEventParameter(oldParm, newParm);

                            newKey.parameters.Add(newParm);
                        }

                        newTrack.keys.Add(newKey);
                    }
                }
                else if (oldTrack is AMGOSetActiveTrack)
                {
                    var oldGOTrack = (AMGOSetActiveTrack)oldTrack;
                    var newGOTrack = new GOSetActiveTrack();

                    newTrack = newGOTrack;

                    ConvertTrackCommonFields(oldTrack, newTrack, true, isMeta);

                    newGOTrack.startActive = oldGOTrack.startActive;

                    newTrack.keys = new List <Key>();
                    foreach (AMGOSetActiveKey oldKey in oldTrack.keys)
                    {
                        var newKey = new GOSetActiveKey();

                        ConvertKeyCommonFields(oldKey, newKey);

                        newKey.setActive = oldKey.setActive;
                        newKey.endFrame  = oldKey.endFrame;

                        newTrack.keys.Add(newKey);
                    }
                }
                else if (oldTrack is AMMaterialTrack)
                {
                    var oldMatTrack = (AMMaterialTrack)oldTrack;
                    var newMatTrack = new MaterialTrack();

                    newTrack = newMatTrack;

                    ConvertTrackCommonFields(oldTrack, newTrack, true, isMeta);

                    newMatTrack.materialIndex = oldMatTrack.materialIndex;
                    newMatTrack.property      = oldMatTrack.property;
                    newMatTrack.propertyType  = (MaterialTrack.ValueType)oldMatTrack.propertyType;

                    newTrack.keys = new List <Key>();
                    foreach (AMMaterialKey oldKey in oldTrack.keys)
                    {
                        var newKey = new MaterialKey();

                        ConvertKeyCommonFields(oldKey, newKey);

                        newKey.endFrame = oldKey.endFrame;
                        newKey.texture  = oldKey.texture;
                        newKey.vector   = oldKey.vector;

                        newTrack.keys.Add(newKey);
                    }
                }
                else if (oldTrack is AMOrientationTrack)
                {
                    newTrack = new OrientationTrack();

                    ConvertTrackCommonFields(oldTrack, newTrack, true, isMeta);

                    newTrack.keys = new List <Key>();
                    foreach (AMOrientationKey oldKey in oldTrack.keys)
                    {
                        var newKey = new OrientationKey();

                        ConvertKeyCommonFields(oldKey, newKey);

                        if (isMeta)
                        {
                            newKey.SetTargetDirect(null, oldKey.GetTargetPath());
                        }
                        else
                        {
                            newKey.SetTargetDirect(oldKey.GetTarget(null), "");
                        }

                        newKey.endFrame = oldKey.endFrame;

                        newTrack.keys.Add(newKey);
                    }
                }
                else if (oldTrack is AMPropertyTrack)
                {
                    var oldPropTrack = (AMPropertyTrack)oldTrack;
                    var newPropTrack = new PropertyTrack();

                    newTrack = newPropTrack;

                    ConvertTrackCommonFields(oldTrack, newTrack, true, isMeta);

                    newPropTrack.valueType = (PropertyTrack.ValueType)oldPropTrack.valueType;

                    if (oldPropTrack.isPropertySet())
                    {
                        Component comp      = oldPropTrack.GetTargetComp(null);
                        string    compName  = oldPropTrack.getComponentName();
                        bool      isField   = oldPropTrack.isField;
                        string    fieldName = oldPropTrack.getMemberName();

                        if (isMeta)
                        {
                            newPropTrack.SetTargetCompDirect(null, compName, isField, fieldName);
                        }
                        else
                        {
                            newPropTrack.SetTargetCompDirect(comp, compName, isField, fieldName);
                        }
                    }

                    newTrack.keys = new List <Key>();
                    foreach (AMPropertyKey oldKey in oldTrack.keys)
                    {
                        var newKey = new PropertyKey();

                        ConvertKeyCommonFields(oldKey, newKey);

                        newKey.endFrame  = oldKey.endFrame;
                        newKey.val       = oldKey.val;
                        newKey.valString = oldKey.valString;
                        newKey.valObj    = oldKey.valObj;
                        newKey.vect4     = oldKey.vect4;

                        newTrack.keys.Add(newKey);
                    }
                }
                else if (oldTrack is AMRotationEulerTrack)
                {
                    var oldRotEulerTrack = (AMRotationEulerTrack)oldTrack;
                    var newRotEulerTrack = new RotationEulerTrack();

                    newTrack = newRotEulerTrack;

                    ConvertTrackCommonFields(oldTrack, newTrack, true, isMeta);

                    newRotEulerTrack.axis = (AxisFlags)oldRotEulerTrack.axis;

                    newTrack.keys = new List <Key>();
                    foreach (AMRotationEulerKey oldKey in oldTrack.keys)
                    {
                        var newKey = new RotationEulerKey();

                        ConvertKeyCommonFields(oldKey, newKey);

                        newKey.rotation = oldKey.rotation;
                        newKey.endFrame = oldKey.endFrame;

                        newTrack.keys.Add(newKey);
                    }
                }
                else if (oldTrack is AMRotationTrack)
                {
                    newTrack = new RotationTrack();

                    ConvertTrackCommonFields(oldTrack, newTrack, true, isMeta);

                    newTrack.keys = new List <Key>();
                    foreach (AMRotationKey oldKey in oldTrack.keys)
                    {
                        var newKey = new RotationKey();

                        ConvertKeyCommonFields(oldKey, newKey);

                        newKey.rotation = oldKey.rotation;
                        newKey.endFrame = oldKey.endFrame;

                        newTrack.keys.Add(newKey);
                    }
                }
                else if (oldTrack is AMTranslationTrack)
                {
                    var oldTransTrack = (AMTranslationTrack)oldTrack;
                    var newTransTrack = new TranslationTrack();

                    newTrack = newTransTrack;

                    ConvertTrackCommonFields(oldTrack, newTrack, true, isMeta);

                    newTransTrack.pixelPerUnit = oldTransTrack.pixelPerUnit;
                    newTransTrack.pixelSnap    = oldTransTrack.pixelSnap;

                    newTrack.keys = new List <Key>();
                    foreach (AMTranslationKey oldKey in oldTrack.keys)
                    {
                        var newKey = new TranslationKey();

                        ConvertKeyCommonFields(oldKey, newKey);

                        newKey.position     = oldKey.position;
                        newKey.endFrame     = oldKey.endFrame;
                        newKey.isConstSpeed = oldKey.isConstSpeed;

                        newKey.path = new Vector3[oldKey.path.Length];
                        System.Array.Copy(oldKey.path, newKey.path, newKey.path.Length);

                        newTrack.keys.Add(newKey);
                    }
                }
                else if (oldTrack is AMTriggerTrack)  //convert TriggerTrack to EventTrack with TriggerSignal
                {
                    var newTriggerTrack = new EventTrack();

                    newTrack = newTriggerTrack;

                    ConvertTrackCommonFields(oldTrack, newTrack, false, isMeta);

                    //grab/create signal for this trigger
                    string signalPath = GetTriggerSignalPath(assetPath);

                    TriggerSignal triggerSignal;
                    if (!mTriggerSignalLookup.TryGetValue(signalPath, out triggerSignal))
                    {
                        //try to load it if it exists
                        triggerSignal = AssetDatabase.LoadAssetAtPath <TriggerSignal>(signalPath);
                        if (!triggerSignal)
                        {
                            AddMessage("  - Creating Trigger Signal: " + signalPath);

                            triggerSignal = ScriptableObject.CreateInstance <TriggerSignal>();
                            AssetDatabase.CreateAsset(triggerSignal, signalPath);
                            AssetDatabase.SaveAssets();

                            yield return(new WaitForFixedUpdate());
                        }

                        mTriggerSignalLookup.Add(signalPath, triggerSignal);
                    }

                    newTriggerTrack.SetTargetAsObject(triggerSignal);

                    newTrack.keys = new List <Key>();
                    foreach (AMTriggerKey oldKey in oldTrack.keys)
                    {
                        var newKey = new EventKey();

                        ConvertKeyCommonFields(oldKey, newKey);

                        newKey.useSendMessage = false;
                        newKey.methodName     = "Invoke";

                        newKey.parameters = new List <EventParameter>(3);
                        newKey.parameters.Add(new EventParameter()
                        {
                            valueType = EventData.ValueType.String, val_string = oldKey.valueString
                        });
                        newKey.parameters.Add(new EventParameter()
                        {
                            valueType = EventData.ValueType.Integer, val_int = oldKey.valueInt
                        });
                        newKey.parameters.Add(new EventParameter()
                        {
                            valueType = EventData.ValueType.Float, val_float = oldKey.valueFloat
                        });

                        newTrack.keys.Add(newKey);
                    }
                }

                newTake.trackValues.Add(newTrack);

                yield return(new WaitForFixedUpdate());
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Create a PropertyTrack
 /// </summary>
 /// <param name="track"> PropertyTrack to edit</param>
 public PropertyTrackBar(PropertyTrack <V> track)
     : base(track)
 {
     _PropertyTrack = track;
 }