コード例 #1
0
 private void DrawRequest()
 {
     if (isFoldoutRequestSet == null || isFoldoutRequestSet.Length != dictRequestSet.Count)
     {
         isFoldoutRequestSet = new bool[dictRequestSet.Count];
     }
     EditorUtilityEx.DrawDictionary <ResourceRequestSet> (
         "Request", dictRequestSet, ref isFoldoutRequest,
         (int count, string key, ResourceRequestSet value) => {
         isFoldoutRequestSet [count] = EditorGUILayout.Foldout(isFoldoutRequestSet [count], key);
         if (isFoldoutRequestSet [count] == true)
         {
             EditorGUI.indentLevel++;
             EditorGUILayout.Toggle("IsComplete", value.IsComplete());
             bool dammy = true;
             EditorUtilityEx.DrawList("List", new List <ResourceRequestItem> (value.GetList()), ref dammy,
                                      (int index, ResourceRequestItem item) => {
                 EditorGUILayout.EnumPopup("Type", item.type);
                 EditorGUILayout.TextField("Url", item.url);
             }
                                      );
             EditorGUI.indentLevel--;
         }
     }
         );
 }
コード例 #2
0
        private void CopyToNew(MachineConfig config)
        {
            string dir      = EditorUtilityEx.GetSelectDirectory();
            string filePath = EditorUtilityEx.ValidFilePath(Path.Combine(dir, "MachineConfig.bytes"));
            string data     = DataUtility.ToJson(config);

            File.WriteAllText(filePath, data);
            AssetDatabase.Refresh();

            Debug.Log($"配置已拷贝到 : {filePath}");
        }
コード例 #3
0
        private void CreateNew()
        {
            string dir      = EditorUtilityEx.GetSelectDirectory();
            string filePath = EditorUtilityEx.ValidFilePath(Path.Combine(dir, "MachineConfig.bytes"));
            string data     = DataUtility.ToJson(new MachineConfig());

            File.WriteAllText(filePath, data);
            Debug.Log($"配置已创建到 : {filePath}");
            AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
            win.configAsset = AssetDatabase.LoadAssetAtPath <TextAsset>(filePath);
            win.UpdateConfig(win.configAsset);
        }
コード例 #4
0
        /// /////////////////////////////////////////////////////////////////////



        /// <summary>
        /// Locks the root game object.
        /// </summary>
        /// <param name="lockGameObject">If set to <c>true</c> lock root game object.</param>
        static void LockRootGameObject(bool lockGameObject)
        {
            EditorClipBinding[] clipBindings = clipBindingsSerialized.value as EditorClipBinding[];
            Array.ForEach(clipBindings, (itm) => {
                if (itm.gameObject != null)
                {
                    if (lockGameObject)
                    {
                        EditorUtilityEx.Lock(itm.gameObject);
                    }
                    else
                    {
                        EditorUtilityEx.Unlock(itm.gameObject);
                    }
                }
            });
        }
コード例 #5
0
        //!!! Don't Create staics in Editor (Editor is recreated on every selection)
        //Have problems with static GenericMenu losing instances

        /// <summary>
        /// Raises the enable event on every selection of Blackboard GameObject and creates new instance of BlackboardEditor
        /// </summary>
        private void OnEnable()
        {
            //on every selection
            //Debug.Log ("OnEnable BlackBoard");

            variableListSerialized = serializedObject.FindProperty("variablesList");

            ((Blackboard)target).variablesList.ForEach(var => {
                if (var != null && var.serializedProperty == null)
                {
                    var.serializedProperty = EditorUtilityEx.SerializeObject(var);
                    EditorUtilityEx.UpdateSerializedProperty(var);
                }
            });


            __variablesReordableList = new ReorderableList(serializedObject, variableListSerialized,
                                                           true, true, true, true);
            __variablesReordableList.drawElementCallback = onDrawElement;

            __variablesReordableList.onAddDropdownCallback = onAddDropdownCallback;

            __variablesReordableList.drawHeaderCallback = onDrawHeaderElement;

            __variablesReordableList.onRemoveCallback = onRemoveCallback;

            __variablesReordableList.onSelectCallback = onSelectCallback;

            __variablesReordableList.elementHeight = 32f;


            _typesCustom = ((Blackboard)target).typesCustom as List <Type>;

            if (_typesCustom == null)
            {
                _typesCustom = new List <Type> ();
            }



            CreateGenericMenu();
        }
コード例 #6
0
 private void DrawSceneNodeSet()
 {
     if (isSceneNodeFoldout == null || isSceneNodeFoldout.Length != sceneNodeSet.nodeList.ToArray().Length)
     {
         isSceneNodeFoldout = new bool[sceneNodeSet.nodeList.ToArray().Length];
     }
     EditorUtilityEx.DrawList <SceneNode> ("SceneNodeSet", new List <SceneNode> (sceneNodeSet.nodeList), ref isFoldout_2,
                                           (int index, SceneNode node) => {
         isSceneNodeFoldout [index] = EditorGUILayout.Foldout(isSceneNodeFoldout [index], node.name);
         if (isSceneNodeFoldout [index] == true)
         {
             EditorGUI.indentLevel++;
             EditorGUILayout.EnumPopup("Type", node.sceneType);
             EditorGUILayout.EnumPopup("State", node.state);
             EditorGUILayout.Toggle("isActive", node.isActive);
             EditorGUILayout.Toggle("isVisible", node.isVisibled);
             EditorGUI.indentLevel--;
         }
     });
 }
コード例 #7
0
 private void DrawTexture()
 {
     if (isFoldoutTextureSet == null || isFoldoutTextureSet.Length != dictResourceTexture.Count)
     {
         isFoldoutTextureSet = new bool[dictResourceTexture.Count];
     }
     EditorUtilityEx.DrawDictionary <ResourceItem> (
         "Texture", dictResourceTexture, ref isFoldoutTexture,
         (int count, string key, ResourceItem resourceItem) => {
         isFoldoutTextureSet [count] = EditorGUILayout.Foldout(isFoldoutTextureSet [count], key);
         if (isFoldoutTextureSet [count] == true)
         {
             EditorGUI.indentLevel++;
             EditorGUILayout.IntField("referenctCount", resourceItem.referenceCount);
             EditorGUILayout.ObjectField("resource", resourceItem.resource, typeof(Object), true);
             EditorGUI.indentLevel--;
         }
     }
         );
 }
コード例 #8
0
        private void SaveConfigToSelect(MachineConfig config)
        {
            string filePath = EditorUtilityEx.GetSelectFile(".bytes");

            if (string.IsNullOrEmpty(filePath))
            {
                Debug.LogWarning("选择的文件无效,写入失败");
                return;
            }

            if (!EditorUtility.DisplayDialog("提示", $"是否将当前配置覆盖到选择文件?\n{filePath}", "是", "否"))
            {
                return;
            }

            string data = DataUtility.ToJson(config);

            File.WriteAllText(filePath, data);
            AssetDatabase.Refresh();

            Debug.Log($"配置已覆盖到 : {filePath}");
        }
コード例 #9
0
        void OnGUI()
        {
            if (__variable != null)
            {
                PropertyDrawer drawer;



                if (__variable.ValueType == typeof(UnityEvent))
                {
                    if (__variable.drawer == null)
                    {
                        __variable.drawer = new UnityEventDrawer();
                    }

                    drawer = __variable.drawer as PropertyDrawer;
                }
                else
                {
                    drawer = EditorUtilityEx.GetDrawer(__variable.ValueType);
                }


                Rect pos = new Rect(16, 16, Screen.width - 32, Screen.height - 32);

                if (drawer != null && __variable.serializedProperty != null)
                {
                    EditorGUI.BeginChangeCheck();
                    drawer.OnGUI(pos, __variable.serializedProperty as SerializedProperty, new GUIContent(__variable.name));

                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorUtilityEx.ApplySerializedPropertyChangeTo(__variable);
                    }
                }
            }
        }
コード例 #10
0
        public Rect DrawVariables(Rect position, SerializedProperty property)
        {
            UnityVariable currentVariable;



            currentVariable = (UnityVariable)property.objectReferenceValue;



            if (currentVariable != null)
            {
                Type type = currentVariable.ValueType;

                if (currentVariable.serializedProperty == null)
                {
                    currentVariable.Value = UnityVariable.Default(type);
                }


                //if UnityVariable isn't of type of known unityTypes or it is UnityEvent or have custom Drawer
                if (Array.IndexOf(EditorGUILayoutEx.unityTypes, type) < 0 ||
                    type == typeof(UnityEvent) || (currentVariable.drawer != null))
                {
                    //!!! this part is for Any UnityVariable with UnityTypes wiht UniUnityVariablePropertyDrawer (experimental)
                    if (currentVariable.ValueType != typeof(UnityEvent) && currentVariable.drawer != null)
                    {
                        variableNameTextFieldPos.y = position.y;
                        variableNameTextFieldPos.x = position.x;

                        EditorGUI.BeginChangeCheck();
                        currentVariable.name = EditorGUI.TextField(variableNameTextFieldPos, currentVariable.name);
                        if (EditorGUI.EndChangeCheck())
                        {
                            property.serializedObject.ApplyModifiedProperties();

                            //EditorUtility.SetDirty (currentVariable);
                        }

                        position.xMin = variableNameTextFieldPos.xMax + 10;


                        (currentVariable.drawer as PropertyDrawer).OnGUI(position, property, null);
                    }
                    else
                    {
                        currentVariable.name = EditorGUI.TextField(position, currentVariable.name);
                    }
                }
                else
                {
                    PropertyDrawer drawer;


                    drawer = EditorUtilityEx.GetDrawer(type);

                    if (drawer == null)
                    {
                        drawer = EditorUtilityEx.GetDefaultDrawer();
                    }


                    variableNameTextFieldPos.y = position.y;
                    variableNameTextFieldPos.x = position.x;

                    currentVariable.name = EditorGUI.TextField(variableNameTextFieldPos, currentVariable.name);
                    position.xMin        = variableNameTextFieldPos.xMax + 10;
                    //position.width =position.width- variableNameTextFieldPos.width;

                    EditorGUI.BeginChangeCheck();

                    if (currentVariable.serializedProperty == null)
                    {
                        currentVariable.serializedProperty = EditorUtilityEx.SerializeObject(currentVariable);
                    }

                    drawer.OnGUI(position, currentVariable.serializedProperty as SerializedProperty, new GUIContent(""));

                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorUtilityEx.ApplySerializedPropertyChangeTo(currentVariable);


                        EditorUtility.SetDirty(currentVariable);
                    }
                }
            }



            return(position);
        }
コード例 #11
0
        public override void OnInspectorGUI()
        {
            //serializedObject.Update ();

            sequence = sequenceSerialziedProperty.objectReferenceValue as Sequence;

            EditorGUI.BeginChangeCheck();

            if (sequence != null)
            {
                wrapSerializedProperty.enumValueIndex = (int)sequence.wrap;
                EditorGUILayout.PropertyField(wrapSerializedProperty, wrapCurrentGUIContent);
                sequence.wrap = (Sequence.SequenceWrap)wrapSerializedProperty.enumValueIndex;
            }
            EditorGUILayout.PropertyField(playOnStartSerializedProperty, playOnStartGUIContent);



            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.PropertyField(sequenceSerialziedProperty, sequenceGUIContent);

            if (GUILayout.Button(cloneSequenceGUIContent))
            {
                if (sequence != null)
                {
                    Sequence sequenceNew = ScriptableObject.CreateInstance <Sequence>();



                    EditorUtilityEx.CreateAssetFromInstance(sequenceNew);

                    foreach (SequenceChannel channel in sequence.channels)
                    {
                        SequenceChannel channelClone = UnityEngine.Object.Instantiate <SequenceChannel>(channel);
                        channelClone.nodes.Clear();
                        sequenceNew.channels.Add(channelClone);
                        channelClone.sequence = sequenceNew;
                        AssetDatabase.AddObjectToAsset(channelClone, sequenceNew);

                        foreach (SequenceNode node in channel.nodes)
                        {
                            SequenceNode nodeClone = UnityEngine.Object.Instantiate <SequenceNode>(node);
                            nodeClone.channel = channelClone;
                            channelClone.nodes.Add(nodeClone);
                            AssetDatabase.AddObjectToAsset(nodeClone, channelClone);

                            EditorClipBinding clipBindingClone = UnityEngine.Object.Instantiate <EditorClipBinding>(node.clipBinding);
                            nodeClone.clipBinding = clipBindingClone;
                            AssetDatabase.AddObjectToAsset(clipBindingClone, nodeClone);
                        }
                    }
                }
            }
            EditorGUILayout.EndHorizontal();



            if (sequence != null)
            {
                timeCurrentSerializedProperty.floatValue = (float)sequence.timeCurrent;
                timeCurrentSerializedProperty.serializedObject.ApplyModifiedProperties();

                EditorGUILayout.Slider(timeCurrentSerializedProperty, (float)sequence.timeStart, (float)sequence.timeEnd);

                sequence.timeCurrent = timeCurrentSerializedProperty.floatValue;



                EditorGUILayout.BeginHorizontal();

                if (GUILayout.Button("Goto"))
                {
                    sequence.GoTo(timeCurrentSerializedProperty.floatValue);
                }


                if (GUILayout.Button(!Application.isPlaying ? (sequence.isPlaying ? "Pause" : "Play Forward") : "Play Forward"))
                {
                    if (Application.isPlaying)
                    {
                        sequence.Play(sequence.timeCurrent);
                    }
                    else
                    {
                        SequenceEditorWindow.Play();
                    }
                }

                if (GUILayout.Button("Play Backward"))
                {
                    if (Application.isPlaying)
                    {
                        sequence.Play(sequence.timeCurrent, false);
                    }
                    else
                    {
                        SequenceEditorWindow.Play(false);
                    }
                }

                if (GUILayout.Button("Stop"))
                {
                    if (Application.isPlaying)
                    {
                        sequence.Stop();
                    }
                    else
                    {
                        SequenceEditorWindow.Stop();
                    }
                }

                if (Application.isPlaying)
                {
                    if (GUILayout.Button("Pause"))
                    {
                        Debug.LogWarning("Not yet tested, not finished");

                        sequence.Pause();
                    }
                }

                if (Application.isPlaying)
                {
                    if (GUILayout.Button("UnPause"))
                    {
                        Debug.LogWarning("Not yet tested, not finished");
                        sequence.UnPause();
                    }
                }

                if (!Application.isPlaying)
                {
                    if (GUILayout.Button("Open Editor"))
                    {
                        SequenceEditorWindow.ShowWindow();
                    }
                }

                EditorGUILayout.EndHorizontal();


                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();

                    SequenceEditorWindow.window.Repaint();
                }

                //EditorUtilityEx.GetDrawer(typeof(UnityEngine.Events.UnityEventBase)).


                ///// DRAW SELECTED NODE (inside SequenceEditor) ////////
                SequenceNode selectedNode = sequence.nodeSelected;
                if (selectedNode != null)
                {
                    if (selectedNode != selectedNodePrev)
                    {
                        EditorGUILayout.Space();
                        EditorGUILayout.LabelField("Selected Node");
                        EditorGUILayout.Space();
                        nodeEditor = Editor.CreateEditor(selectedNode, typeof(SequenceNodeEditor)) as SequenceNodeEditor;
                        EditorGUILayout.Space();
                    }


                    nodeEditor.OnInspectorGUI();
                }
                else
                {
                    EditorGUILayout.LabelField("No Node selected");
                }

                selectedNodePrev = selectedNode;
            }
        }
コード例 #12
0
 private void DrawCollectionIgnoreObjectName()
 {
     EditorUtilityEx.DrawList <string> ("CollectionIgnoreObjectName", listCollectionIgnoreObjectName, ref isFoldout_1);
 }
コード例 #13
0
        /// <summary>
        /// The custom inspector.
        /// </summary>
        public override void OnInspectorGUI()
        {
            int i = 0;



            //////  RESTORE SAVED  //////
            //restore and delete clipboard


            mecanimNode = target as MecanimNode;

            if (mecanimNode != null)
            {
                Motion motion = null;



                //////////////////////////////////////////////////////////////
                ///                         PRESEVE RESTORE					//
                if (EditorApplication.isPlaying || EditorApplication.isPaused)
                {
                    if (GUILayout.Button("Preserve"))
                    {
                        serializedNode.ApplyModifiedProperties();

                        UnityVariable.SetDirty(mecanimNode.blendX);

                        UnityVariable.SetDirty(mecanimNode.blendY);
                        UnityVariable.SetDirty(mecanimNode.motionOverride);

//												if (variablesBindedToCurves != null) {
//														UnityVariable[] varArray = variablesBindedToCurves;
//
//														int varNumber = varArray.Length;
//														for (int varCurrent=0; varCurrent<varNumber; varCurrent++) {
//																varArray [varCurrent].OnBeforeSerialize ();
//
//														}
//												}


                        EditorUtilityEx.Clipboard.preserve(mecanimNode.instanceID, mecanimNode, mecanimNode.GetType().GetFields());
                    }
                }
                else
                {
                    if (EditorUtilityEx.Clipboard.HasBeenPreseved(mecanimNode.instanceID) && GUILayout.Button("Apply Playmode Changes"))
                    {
                        EditorUtilityEx.Clipboard.restore(mecanimNode.instanceID, mecanimNode);

                        animatorStateSerialized = null;
                        NodePropertyIterator iterator = serializedNode.GetIterator();



                        while (iterator.Next(true))
                        {
                            if (iterator.current.value is UnityVariable)
                            {
                                //Debug.Log("OnBeforeDeserialize:"+((UnityVariable)iterator.current.value).Value);
                                ((UnityVariable)iterator.current.value).OnAfterDeserialize();

                                //Debug.Log("OnAfterDeserialize:"+((UnityVariable)iterator.current.value).Value);
                            }
                            else if (iterator.current.value is UnityVariable[])
                            {
                                UnityVariable[] varArray  = (UnityVariable[])iterator.current.value;
                                int             varNumber = varArray.Length;
                                for (int varCurrent = 0; varCurrent < varNumber; varCurrent++)
                                {
                                    varArray [varCurrent].OnAfterDeserialize();
                                }
                            }


                            iterator.current.ValueChanged();

                            this.serializedNode.Update();

                            iterator.current.ApplyModifiedValue();
                        }
                    }
                }
                //////////////////////


                if (Event.current.type == EventType.Layout)
                {
                    this.serializedNode.Update();
                }



                DrawDefaultInspector();

//
//				if (EditorGUILayoutEx.ANIMATION_STYLES == null)
//					EditorGUILayoutEx.ANIMATION_STYLES = new EditorGUILayoutEx.AnimationStyles ();



                /////////////////////////////// ANIMATOR STATE /////////////////////////////////

                if (animatorStateSerialized == null)
                {
                    NodePropertyIterator iterator = this.serializedNode.GetIterator();
                    if (iterator.Find("animatorStateSelected"))
                    {
                        animatorStateSerialized = iterator.current;
                    }


                    if (iterator.Find("motionOverride"))
                    {
                        motionOverrideSerialized = iterator.current;
                    }
                }



                //////////  MOTION OVERRIDE HANDLING  //////////
                if (animatorStateSerialized.value != null)
                {
                    UnityVariable motionOverridVariable = (UnityVariable)motionOverrideSerialized.value;

                    //if there are no override use motion of selected AnimationState
                    //Debug.Log(((UnityEngine.Object)mecanimNode.motionOverride.Value).);
                    if (motionOverridVariable == null || motionOverridVariable.Value == null || motionOverridVariable.ValueType != typeof(AnimationClip))
                    {
                        motion = ((ws.winx.unity.AnimatorState)animatorStateSerialized.value).motion;
                    }
                    else                                                             //
                    {
                        motion = (Motion)motionOverridVariable.Value;
                    }



                    if (motionOverridVariable != null && motionOverridVariable.Value != null && ((ws.winx.unity.AnimatorState)animatorStateSerialized.value).motion == null)
                    {
                        Debug.LogError("Can't override state that doesn't contain motion");
                    }
                }
                ///////////////////////////////////////////////////

                if (GUILayout.Button("BindEditor") && motion != null)
                {
                    MecanimNodeEditorWindow.Show(mecanimNode.self, motion as AnimationClip, this.serializedNode, null);
                }

                /////////////   TIME CONTROL OF ANIMATION (SLIDER) /////////
                if (Application.isPlaying)
                {
                    if (animatorStateRuntimeControlEnabledSerialized == null)
                    {
                        NodePropertyIterator iterator = this.serializedNode.GetIterator();

                        if (iterator.Find("animationRunTimeControlEnabled"))
                        {
                            animatorStateRuntimeControlEnabledSerialized = iterator.current;
                        }

                        if (iterator.Find("animatorStateRunTimeControl"))
                        {
                            animatorStateRunTimeControlSerialized = iterator.current;
                        }
                    }



                    if (animatorStateRuntimeControlEnabledSerialized != null && animatorStateRunTimeControlSerialized != null && (bool)animatorStateRuntimeControlEnabledSerialized.value)
                    {
                        Rect timeControlRect = GUILayoutUtility.GetRect(Screen.width - 16f, 26f);
                        timeControlRect.xMin += 38f;
                        timeControlRect.xMax -= 70f;
                        animatorStateRunTimeControlSerialized.value = EditorGUILayoutEx.CustomHSlider(timeControlRect, (float)animatorStateRunTimeControlSerialized.value, 0f, 1f, EditorGUILayoutEx.ANIMATION_STYLES.timeScrubber);
                    }
                }
                ///////////////////////////////////////////////////////////////


                /////////// AVATAR Preview GUI ////////////


                if (!Application.isPlaying && motion != null)
                {
                    //This makes layout to work (Reserving space)
                    Rect avatarRect = GUILayoutUtility.GetRect(Screen.width - 16f, 200);
                    avatarRect.width -= 70f;
                    avatarRect.xMin  += 6f;


                    if (avatarPreview == null)
                    {
                        avatarPreview = new AvatarPreviewW(null, motion);
                    }
                    else
                    {
                        avatarPreview.SetPreviewMotion(motion);
                    }



                    EditorGUILayout.BeginHorizontal();



                    if (eventTimeValues != null && Event.current.type == EventType.Repaint)
                    {
                        //find first selected if exist
                        int eventTimeValueSelectedIndex = Array.IndexOf(eventTimeValuesSelected, true);



                        if (eventTimeValueSelectedIndex > -1)
                        {
                            avatarPreview.SetTimeAt(eventTimeValues [eventTimeValueSelectedIndex]);
                        }
                        else
                        {
                            //!!! changing
                            //avatarPreview.timeControl.startTime
                            // start/stop makes AvatarPreview to play from start to stop
                            // and the rest of animation isn't visible in Timeline so not good for selecting range
                            // but its not offer good usability of resized animation


                            if (avatarPreview.timeControl.playing)
                            {
                                //restrict animation into this range
                                if (avatarPreview.timeControl.normalizedTime < mecanimNode.range.rangeStart || avatarPreview.timeControl.normalizedTime > mecanimNode.range.rangeEnd)
                                {
                                    avatarPreview.timeControl.nextCurrentTime = avatarPreview.timeControl.startTime * (1f - mecanimNode.range.rangeStart) + avatarPreview.timeControl.stopTime * mecanimNode.range.rangeStart;
                                }
                            }
                            else
                            {
                                //set AvatarPreview animation time range depending of drag of range control handles
                                if (Math.Abs(mecanimNode.range.rangeStart - timeNormalizedStartPrev) > 0.01f)
                                {
                                    timeNormalizedStartPrev = mecanimNode.range.rangeStart;

                                    avatarPreview.SetTimeAt(timeNormalizedStartPrev);
                                }
                                else
                                if (Math.Abs(mecanimNode.range.rangeEnd - timeNormalizedEndPrev) > 0.01f)
                                {
                                    timeNormalizedEndPrev = mecanimNode.range.rangeEnd;
                                    avatarPreview.SetTimeAt(timeNormalizedEndPrev);
                                }
                            }
                        }
                    }



                    avatarPreview.timeControl.playbackSpeed = mecanimNode.speed;



                    avatarPreview.DoAvatarPreview(avatarRect, GUIStyle.none);



                    //Debug.Log(avatarPreview.timeControl.currentTime+" "+);
                    EditorGUILayout.EndHorizontal();



                    ////////// Events Timeline GUI //////////

                    if (!eventTimeLineInitalized)
                    {
                        //TODO calculate PopupRect

                        eventTimeLineValuePopUpRect = new Rect((Screen.width - 250) * 0.5f, (Screen.height - 150) * 0.5f, 250, 150);


                        //select the time values from nodes
                        //eventTimeValues = mecanimNode.children.Select ((val) => (float)((SendEventNormalized)val).timeNormalized.Value).ToArray ();


                        eventTimeValues = mecanimNode.children.Select((val) => (float)(((SendEventNormalizedNode)val).timeNormalized.serializedProperty as SerializedProperty).floatValue).ToArray();


                        eventDisplayNames       = mecanimNode.children.Select((val) => ((SendEventNormalizedNode)val).name).ToArray();
                        eventTimeValuesSelected = new bool[eventTimeValues.Length];

                        playButtonStyle = "TimeScrubberButton";

                        if (playButtonStyle != null)
                        {
                            playButtonSize = playButtonStyle.CalcSize(new GUIContent());
                        }

                        eventTimeLineInitalized = true;
                    }



                    Rect timeLineRect = GUILayoutUtility.GetRect(Screen.width - 16f, 50f);
                    //Rect timeLineRect = GUILayoutUtility.GetLastRect ();


                    Texture eventMarkerTexture = EditorGUILayoutEx.ANIMATION_STYLES.eventMarker.image;
                    timeLineRect.xMin += playButtonSize.x - eventMarkerTexture.width * 0.5f;
                    timeLineRect.xMax -= eventMarkerTexture.width * 0.5f;
                    //timeLineRect.height = EditorGUILayoutEx.eventMarkerTexture.height * 3 * 0.66f + playButtonSize.y;
                    timeLineRect.width -= 66f;
                    EditorGUILayoutEx.CustomTimeLine(ref timeLineRect, new GUIContent(eventMarkerTexture), ref eventTimeValues, ref eventTimeValuesPrev, ref eventDisplayNames, ref eventTimeValuesSelected, avatarPreview.timeControl.normalizedTime,
                                                     onMecanimEventAdd, onMecanimEventDelete, onMecanimEventClose, onMecanimEventEdit, onMecanimEventDragEnd
                                                     );

                    EditorGUILayout.LabelField("Events Timeline");

                    SendEventNormalizedNode ev;



                    //update time values
                    int eventTimeValuesNumber = mecanimNode.children.Length;
                    for (i = 0; i < eventTimeValuesNumber; i++)
                    {
                        ev = ((SendEventNormalizedNode)mecanimNode.children [i]);
                        //ev.timeNormalized.Value = eventTimeValues [i];
                        ev.timeNormalized.Value = eventTimeValues [i];

                        //if changes have been made in pop editor or SendEventNormailized inspector
                        if (ev.name != eventDisplayNames [i])
                        {
                            eventDisplayNames [i] = ((SendEventNormalizedNode)mecanimNode.children [i]).name;
                        }

                        EditorUtilityEx.ApplySerializedPropertyChangeTo(ev.timeNormalized);
                        //ev.timeNormalized.ApplyModifiedProperties ();
                    }



                    // Restore the indent level
                    //EditorGUI.indentLevel = indentLevel;

                    // Apply modified properties
                    this.serializedNode.ApplyModifiedProperties();
                }
            }
        }