Exemplo n.º 1
0
        internal static bool ShowAtPosition(Rect buttonRect, IsoSwitches switches = null)
        {
            long num = DateTime.Now.Ticks / 10000L;

            if (num >= SwitchesMenu.s_LastClosedTime + 50L)
            {
                if (Event.current != null)
                {
                    Event.current.Use();
                }
                if (SwitchesMenu.s_DrawerParametersMenu == null)
                {
                    SwitchesMenu.s_DrawerParametersMenu = ScriptableObject.CreateInstance <SwitchesMenu>();
                }
                SwitchesMenu.s_DrawerParametersMenu.Init(buttonRect, switches);
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        public void OnEnable()
        {
            if (target == null)
            {
                return;
            }

            isoSwitches = target as IsoSwitches;

            switchList = new ReorderableList(isoSwitches.switches, typeof(ISwitch), true, false, true, true);

            switchList.elementHeight = 35;

            switchList.drawElementCallback += (rect, index, isActive, isFocused) =>
            {
                var isw = switchList.list[index] as ISwitch;

                EditorGUI.BeginChangeCheck();
                isw.id    = EditorGUI.TextField(new Rect(rect.x, rect.y, rect.width, rect.height / 2f - 2f), "ID ", isw.id);
                isw.State = ParamEditor.editorFor(new Rect(rect.x, rect.y + rect.height / 2f, rect.width, rect.height / 2f - 2f), isw.State);
                if (EditorGUI.EndChangeCheck())
                {
                    EditorUtility.SetDirty(isw);
                }
            };

            switchList.onRemoveCallback += (list) =>
            {
                isoSwitches.removeSwitch(isoSwitches.switches[list.index]);
            };

            switchList.onAddCallback += (list) =>
            {
                var isw = isoSwitches.addSwitch();
                isw.id = search;
            };
        }