Esempio n. 1
0
 /// <summary>
 /// Draws the enum type selector.
 /// </summary>
 /// <returns><c>true</c>, if enum type is changed, <c>false</c> otherwise.</returns>
 /// <param name="type">Type.</param>
 public bool DrawEnumTypeSelector(out Type type)
 {
     if (Length == 0)
     {
         type = enumTypeSelector.type;
         return(false);
     }
     if (enumTypeSelector == null)
     {
         type = null;
         Assert.Fail(null, "Call InitTypeSelector() first");
         return(false);
     }
     else
     {
         bool changed = enumTypeSelector.DrawSelector(ref typeName);
         type = enumTypeSelector.type;
         if (changed && enumTypeFieldName != null)
         {
             if (type != null)
             {
                 obj.SetFieldValue(enumTypeFieldName, type.FullName);
             }
             else
             {
                 obj.SetFieldValue(enumTypeFieldName, string.Empty);
             }
             SetDirty();
         }
         return(false);
     }
 }
Esempio n. 2
0
 public override void OnHeaderGUI(List <Object> found)
 {
     EditorGUILayout.BeginHorizontal();
     selector.DrawSelector();
     if (GUILayout.Button("Search", EditorStyles.miniButton))
     {
         Search();
     }
     EditorGUILayout.EndHorizontal();
 }
Esempio n. 3
0
        public override void OnHeaderGUI()
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.BeginVertical();
            bool changed = false;

            changed |= EditorGUILayoutEx.Toggle("Apply On Selection", ref applyOnSelection);
            if (!applyOnSelection)
            {
                changed |= EditorGUILayoutEx.ObjectField <Transform>("Root", ref root, true);
            }
            changed |= typeSelector.DrawSelector();
            Type type = typeSelector.type;

            if (typeSelector.GetType() != null)
            {
                if (fieldInspector.DrawFieldPopup(type, ref field))
                {
                    changed  = true;
                    property = null;
                }
                if (fieldInspector.DrawPropertyPopup(type, ref property))
                {
                    changed = true;
                    field   = null;
                }
            }
            EditorGUILayout.EndVertical();
            if (type != null && changed)
            {
                if (applyOnSelection)
                {
                    if (Selection.gameObjects.Length > 0)
                    {
                        targets.Clear();
                        foreach (GameObject o in Selection.gameObjects)
                        {
                            foreach (Component c in o.GetComponentsInChildren(type, true))
                            {
                                targets.Add(type, c);
                            }
                        }
                    }
                    else if (Selection.objects.Length > 0)
                    {
                        targets.Clear();
                        foreach (Object o in Selection.objects)
                        {
                            if (o is Component)
                            {
                                targets.Add(o.GetType(), o as Component);
                            }
                        }
                    }
                }
                else if (!applyOnSelection && root != null)
                {
                    targets.Clear();
                    foreach (Component c in root.GetComponentsInChildren(type, true))
                    {
                        targets.Add(type, c);
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
        }