Esempio n. 1
0
 public static bool HasGotoRef(this eCollection options)
 {
     return((options & eCollection.GotoRef) != 0);
 }
Esempio n. 2
0
 public static bool HasVerticalTools(this eCollection options)
 {
     return((options & eCollection.VerticalTools) != 0);
 }
Esempio n. 3
0
 public static bool HasDelete(this eCollection options)
 {
     return((options & eCollection.Delete) != 0);
 }
Esempio n. 4
0
 public static bool HasSingleLine(this eCollection options)
 {
     return((options & eCollection.SingleLine) != 0);
 }
Esempio n. 5
0
 public static bool HasReorder(this eCollection options)
 {
     return((options & eCollection.Reorder) != 0);
 }
Esempio n. 6
0
 public static bool HasDestroyRef(this eCollection options)
 {
     return((options & eCollection.DestroyRef) != 0);
 }
Esempio n. 7
0
        public static void PropCollection <T>(SerializedProperty items_prop, ref T[] items, Action <T, SerializedProperty, int> onDrawItem, eCollection options)
        {
            for (var i = 0; i < items.Length; i++)
            {
                GUI.backgroundColor = i % 2 == 0 ? new Color(0.7f, 0.7f, 0.7f) : new Color(1, 1, 1);
                var item = items[i];

                if (!options.HasSingleLine())
                {
                    LineDelimiter();
                }
                GUILayout.BeginHorizontal();
                if (!options.HasSingleLine())
                {
                    GUILayout.BeginVertical();
                }

                if (i < items_prop.arraySize)
                {
                    onDrawItem(item, items_prop == null ? null : items_prop.GetArrayElementAtIndex(i), i);
                }

                if (!options.HasSingleLine() || options.HasVerticalTools())
                {
                    if (!options.HasSingleLine())
                    {
                        GUILayout.EndVertical();
                    }
                    GUILayout.BeginVertical(GUILayout.Width(MINI_BUTTON_WIDTH));
                }

                if (options.HasGotoRef() && item is Object && ButtonMini("≡", "Goto This Item", cyanLt, MINI_BUTTON_WIDTH))
                {
                    Selection.activeObject = item as Object;
                }

                if (options.HasReorder())
                {
                    if (i > 0)
                    {
                        if (ButtonMini("▲", "Move Up", azureLt, MINI_BUTTON_WIDTH))
                        {
                            items.MoveBack(item);
                        }
                    }
                    else
                    {
                        ButtonMini("▲", "Move Up (Not Allowed)", Color.clear, MINI_BUTTON_WIDTH); // placeholder
                    }
                }

                if (options.HasReorder())
                {
                    if (i < items.Length - 1)
                    {
                        if (ButtonMini("▼", "Move Down", azureLt, MINI_BUTTON_WIDTH))
                        {
                            items.MoveForw(item);
                        }
                    }
                    else
                    {
                        ButtonMini("▼", "Move Down (Not Allowed)", Color.clear, MINI_BUTTON_WIDTH); // placeholder
                    }
                }

                if (options.HasDelete() && ButtonMini(eIcons.Get("d_winbtn_win_close"), "Delete Item", redLt, MINI_BUTTON_WIDTH))
                {
                    items = items.Remove(item);
                    if (options.HasDestroyRef())
                    {
                        if (item is Component)
                        {
                            Object.DestroyImmediate((item as Component).gameObject);
                        }
                        else if (item is GameObject)
                        {
                            Object.DestroyImmediate(item as GameObject);
                        }
                    }
                    return;
                }
                if (!options.HasSingleLine() || options.HasVerticalTools())
                {
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();
            }
            GUI.backgroundColor = background;
        }
Esempio n. 8
0
        public static void Collection <T>(ref T[] items, Action <T, int> onDrawItem, eCollection options)
        {
            for (var i = 0; i < items.Length; i++)
            {
                var item = items[i];
                GUILayout.BeginHorizontal();
                if (!options.HasSingleLine())
                {
                    GUILayout.BeginVertical();
                }

                onDrawItem(item, i);

                if (!options.HasSingleLine())
                {
                    GUILayout.EndVertical();
                    GUILayout.BeginVertical(GUILayout.Width(MINI_BUTTON_WIDTH));
                }

                if (options.HasGotoRef() && item is Object && ButtonMini("≡", "Goto This Item", cyanLt, MINI_BUTTON_WIDTH))
                {
                    Selection.activeObject = item as Object;
                }

                if (options.HasReorder())
                {
                    if (i > 0)
                    {
                        if (ButtonMini("▲", "Move Up", azureLt, MINI_BUTTON_WIDTH))
                        {
                            items.MoveBack(item);
                        }
                    }
                    else
                    {
                        ButtonMini("▲", "Move Up (Not Allowed)", Color.clear, MINI_BUTTON_WIDTH); // placeholder
                    }
                }

                if (options.HasReorder())
                {
                    if (i < items.Length - 1)
                    {
                        if (ButtonMini("▼", "Move Down", azureLt, MINI_BUTTON_WIDTH))
                        {
                            items.MoveForw(item);
                        }
                    }
                    else
                    {
                        ButtonMini("▼", "Move Down (Not Allowed)", Color.clear, MINI_BUTTON_WIDTH); // placeholder
                    }
                }

                if (options.HasDelete() && ButtonMini(eIcons.Get("d_winbtn_win_close"), "Delete Item", redLt, MINI_BUTTON_WIDTH))
                {
                    items = items.Remove(item);
                    if (options.HasDestroyRef())
                    {
                        if (item is Component)
                        {
                            Object.DestroyImmediate((item as Component).gameObject);
                        }
                        else if (item is GameObject)
                        {
                            Object.DestroyImmediate(item as GameObject);
                        }
                    }
                    return;
                }
                if (!options.HasSingleLine())
                {
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();
                if (!options.HasSingleLine())
                {
                    LineDelimiter();
                }
            }
        }