Exemplo n.º 1
0
 private void OnMouseUpParameter(ReorderableList list)
 {
     if (!this.m_Host.liveLink && this.m_HadKeyFocusAtMouseDown && list.index == this.m_LastSelectedIndex && Event.current.button == 0)
     {
         ParameterControllerView.Element element = list.list[list.index] as ParameterControllerView.Element;
         this.renameOverlay.BeginRename(element.name, list.index, 0.1f);
     }
     this.m_LastSelectedIndex = list.index;
 }
Exemplo n.º 2
0
        private void OnRemoveParameter(int index)
        {
            if (this.m_Host.liveLink)
            {
                return;
            }
            if (this.m_ParameterList.list.Count <= 0)
            {
                return;
            }
            ParameterControllerView.Element element = this.m_ParameterList.list[index] as ParameterControllerView.Element;
            List <UnityEngine.Object>       list    = this.m_Host.animatorController.CollectObjectsUsingParameter(element.name).ToList <UnityEngine.Object>();
            bool flag = false;

            if (list.Count > 0)
            {
                string title = "Delete parameter " + element.name + "?";
                string text  = "It is used by : \n";
                foreach (UnityEngine.Object current in list)
                {
                    AnimatorTransitionBase animatorTransitionBase = current as AnimatorTransitionBase;
                    if (animatorTransitionBase != null && animatorTransitionBase.destinationState != null)
                    {
                        text = text + "Transition to " + animatorTransitionBase.destinationState.name + "\n";
                    }
                    else if (animatorTransitionBase != null && animatorTransitionBase.destinationStateMachine != null)
                    {
                        text = text + "Transition to " + animatorTransitionBase.destinationStateMachine.name + "\n";
                    }
                    else
                    {
                        text = text + current.name + "\n";
                    }
                }
                if (EditorUtility.DisplayDialog(title, text, "Delete", "Cancel"))
                {
                    flag = true;
                }
            }
            else
            {
                flag = true;
            }
            if (flag)
            {
                this.ResetTextFields();
                list.Add(this.m_Host.animatorController);
                Undo.RegisterCompleteObjectUndo(list.ToArray(), "Parameter removed");
                this.m_Host.animatorController.RemoveParameter(element.m_Parameter);
                this.RebuildList();
                this.m_ParameterList.GrabKeyboardFocus();
            }
        }
Exemplo n.º 3
0
 private void OnReorderParameter(ReorderableList reorderablelist)
 {
     ParameterControllerView.Element[] array = new ParameterControllerView.Element[reorderablelist.list.Count];
     reorderablelist.list.CopyTo(array, 0);
     UnityEngine.AnimatorControllerParameter[] array2 = new UnityEngine.AnimatorControllerParameter[array.Length];
     for (int i = 0; i < array.Length; i++)
     {
         if (array[i] == null || array[i].m_Parameter == null)
         {
             return;
         }
         array2[i] = array[i].m_Parameter;
     }
     Undo.RegisterCompleteObjectUndo(this.m_Host.animatorController, "Parameter reordering");
     this.m_Host.animatorController.parameters = array2;
     this.RebuildList();
 }
Exemplo n.º 4
0
        private void OnDrawParameter(Rect rect, int index, bool selected, bool focused)
        {
            Event current = Event.current;

            if (current.type == EventType.MouseUp && current.button == 1 && rect.Contains(current.mousePosition))
            {
                GenericMenu genericMenu = new GenericMenu();
                genericMenu.AddItem(new GUIContent("Delete"), false, new GenericMenu.MenuFunction(this.DeleteParameter));
                genericMenu.ShowAsContext();
                Event.current.Use();
            }
            if (index >= this.m_ParameterList.list.Count)
            {
                return;
            }
            ParameterControllerView.Element element = this.m_ParameterList.list[index] as ParameterControllerView.Element;
            rect.yMin += 2f;
            rect.yMax -= 3f;
            element.OnGUI(rect, index);
        }
Exemplo n.º 5
0
 protected void RenameEnd()
 {
     if (this.renameOverlay.userAcceptedRename)
     {
         string text = (!string.IsNullOrEmpty(this.renameOverlay.name)) ? this.renameOverlay.name : this.renameOverlay.originalName;
         if (text != this.renameOverlay.originalName)
         {
             int userData = this.renameOverlay.userData;
             ParameterControllerView.Element element = this.m_ParameterList.list[userData] as ParameterControllerView.Element;
             text = this.m_Host.animatorController.MakeUniqueParameterName(text);
             Undo.RegisterCompleteObjectUndo(this.m_Host.animatorController, "Parameter renamed");
             this.m_Host.animatorController.RenameParameter(element.name, text);
             element.name = text;
             UnityEngine.AnimatorControllerParameter[] parameters = this.m_Host.animatorController.parameters;
             parameters[userData] = element.m_Parameter;
             this.m_Host.animatorController.parameters = parameters;
         }
     }
     this.m_ParameterList.GrabKeyboardFocus();
     this.renameOverlay.Clear();
 }
Exemplo n.º 6
0
        protected void CreateSearchParameterList(string newSearch, int searchMode)
        {
            string[] array = newSearch.ToLower().Split(new char[]
            {
                ' '
            });
            List <ParameterControllerView.Element> list  = new List <ParameterControllerView.Element>();
            List <ParameterControllerView.Element> list2 = new List <ParameterControllerView.Element>();

            ParameterControllerView.Element[] tree = this.m_Tree;
            int i = 0;

            while (i < tree.Length)
            {
                ParameterControllerView.Element element = tree[i];
                if (searchMode == 0)
                {
                    goto IL_76;
                }
                string a = element.m_Parameter.type.ToString();
                if (!(a != ((ParameterControllerView.SearchMode)searchMode).ToString()))
                {
                    goto IL_76;
                }
IL_10E:
                i++;
                continue;
IL_76:
                string text = element.name;
                text        = text.ToLower().Replace(" ", string.Empty);
                bool flag  = true;
                bool flag2 = false;
                for (int j = 0; j < array.Length; j++)
                {
                    string value = array[j];
                    if (!text.Contains(value))
                    {
                        flag = false;
                        break;
                    }
                    if (j == 0 && text.StartsWith(value))
                    {
                        flag2 = true;
                    }
                }
                if (!flag)
                {
                    goto IL_10E;
                }
                if (flag2)
                {
                    list.Add(element);
                    goto IL_10E;
                }
                list2.Add(element);
                goto IL_10E;
            }
            list.Sort();
            list2.Sort();
            List <ParameterControllerView.Element> list3 = new List <ParameterControllerView.Element>();

            list3.AddRange(list);
            list3.AddRange(list2);
            this.m_SearchTree = list3.ToArray();
        }