Inheritance: MonoBehaviour
Ejemplo n.º 1
0
        void OnEnable()
        {
            this.handler              = target as ToggleHandler;
            toggleInspector           = new ArrayDrawer <GameObject>(handler, "toggleObj");
            toggleInspector.onInsert += OnItemAdd;

            // convert OnClick -> OnButtonClick
            for (int i = 0; i < toggleInspector.Count; ++i)
            {
                GameObject o = toggleInspector[i] as GameObject;
                if (o != null)
                {
                    UIToggle b = o.GetComponent <UIToggle>();
                    foreach (EventDelegate d in b.onChange)
                    {
                        if (d.target == handler && d.methodName == "OnToggleChange")
                        {
                            EventDelegate.Parameter[] p = d.parameters;
                            d.methodName = "OnToggleChange";
                            if (d.isValid)
                            {
                                d.parameters[0] = p[0];
                            }
                            EditorUtil.SetDirty(o);
                        }
                    }
                }
                else
                {
                    Debug.LogWarning(handler.name + ".ToggleHandler has null arguments");
                }
            }
        }
Ejemplo n.º 2
0
    protected override bool OnInspectorGUI(FontChangeData data, int i)
    {
        bool changed = false;

        EditorGUILayout.BeginVertical();
        if (EditorGUIUtil.ObjectField <Font>("DynamicFont", ref data.font, false))
        {
            changed = true;
            if (data.font != null)
            {
                data.uiFont = null;
            }
        }
        if (EditorGUIUtil.ObjectField <UIFont>("Reference Font", ref data.uiFont, false))
        {
            changed = true;
            if (data.uiFont != null)
            {
                data.font = null;
            }
        }
        ArrayDrawer <UIFont> arr = null;

        if (!arrMap.TryGetValue(data, out arr))
        {
            arr = new ArrayDrawer <UIFont>(data, "references");
            arr.allowSceneObject = false;
            arrMap[data]         = arr;
        }
        arr.OnInspectorGUI();
        EditorGUILayout.EndVertical();
        return(changed);
    }
Ejemplo n.º 3
0
        public override void OnInspectorGUI()
        {
            varInspector.OnInspectorGUI();
            if (arrDrawer == null && sprite.sprite != null && sprite.sprite.atlas != null)
            {
                string[] sprList = sprite.sprite.atlas.GetListOfSprites().ToArray();
                arrDrawer = new ArrayDrawer <SpriteAnimInfo>(sprite, "anim", new SpriteAnimInfoItemDrawer(sprList));
                arrDrawer.createDefaultValue = () => new SpriteAnimInfo();
                arrDrawer.addSelected        = false;
            }
            if (arrDrawer == null)
            {
                return;
            }
            if (arrDrawer.Draw(ReorderableListFlags.ShowIndices))
            {
                EditorUtil.SetDirty(target);
            }

            if (sprite.anim != null && sprite.anim.Length == 1 && GUILayout.Button("Add all"))
            {
                string firstName = sprite.anim[0].name;
                string baseName  = firstName.DetachSuffix();
                string separator = firstName.Length == baseName.Length? "": firstName[baseName.Length].ToString();
                if (char.IsDigit(separator[0]))
                {
                    separator = "";
                }
                int          i    = 1;
                string       name = baseName.AddSuffix(separator, i);
                UISpriteData s    = sprite.sprite.atlas.GetSprite(name);
                while (s != null)
                {
                    arrDrawer.Add(new SpriteAnimInfo(name, sprite.anim[0].delay));
                    i++;
                    name = baseName.AddSuffix(separator, i);
                    s    = sprite.sprite.atlas.GetSprite(name);
                }
                EditorUtil.SetDirty(sprite);
            }
            if (EditorGUIUtil.FloatField("Global Delay", ref globalDelay))
            {
                foreach (SpriteAnimInfo i in sprite.anim)
                {
                    i.delay = globalDelay;
                }
                EditorUtil.SetDirty(sprite);
            }
        }
Ejemplo n.º 4
0
        public UITabHandlerInspectorImpl(UITabHandler handler)
        {
            this.tabHandler                 = handler;
            tabArrInspector                 = new UITabArrInspector(tabHandler, "tabs", true);
            tabPrefabArrInspector           = new UITabArrInspector(tabHandler, "tabPrefabs", false);
            tabPrefabArrInspector.selectTab = false;
            tabButtonArrInspector           = new ArrayDrawer <UIButton>(tabHandler, "tabButtons");
            bool auto = false;

            if (auto)
            {
                tabArrInspector.AddItemAddCallback(OnTabChanged);
                tabArrInspector.AddItemChangeCallback(OnTabChanged);
                tabArrInspector.AddItemRemoveCallback(OnTabRemoved);
            }
        }
Ejemplo n.º 5
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        ViewConf data = property.objectReferenceValue as ViewConf;

        if (data != null)
        {
            label = new GUIContent(data._viewType + "_" + (data._prefab == null ? "" : data._prefab.name));
        }
        ArrayDrawer.AddArrayTools(position, property);
        Rect rc = position;

        if (!property.isExpanded)
        {
            rc.width -= ArrayDrawer.widthBt * 4;
        }
        EditorGUI.PropertyField(rc, property, label, true);
    }
        void OnEnable()
        {
            this.handler            = target as ButtonHandler;
            this.drawer             = new ArrayDrawer <GameObject>(handler, "buttons");
            drawer.onInsert        += OnInsert;
            drawer.allowSceneObject = true;
            drawer.allowSelection   = false;

            // check validation
            Action <GameObject> callback = handler.OnButtonClick;
            string callbackName          = callback.Method.Name;
            bool   changed = false;

            foreach (GameObject o in handler.buttons)
            {
                if (o == null)
                {
                    Debug.LogWarning("There is null element in " + handler.transform.GetScenePath(), handler);
                }
                else
                {
                    UIButton button = o.GetComponent <UIButton>();
                    if (button == null ||
                        button.onClick.IsEmpty() ||
                        button.onClick[0].methodName != callbackName ||
                        button.onClick[0].parameters.IsEmpty() ||
                        button.onClick[0].parameters[0].obj != button.gameObject)
                    {
                        EventDelegateUtil.SetCallback(button.onClick, callback, button.gameObject);
                        EditorUtil.SetDirty(button.gameObject);
                        changed = true;
                        //              EditorGUILayout.HelpBox(o.name+" is invalid", MessageType.Error);
                    }
                }
            }
            if (changed)
            {
                AssetDatabase.SaveAssets();
            }
        }
Ejemplo n.º 7
0
        public override void OnGUILayout()
        {
            EGUILayout.DrawBoxHeader(Label, GUILayout.ExpandWidth(true));
            if (operater == null)
            {
                operater                 = ItemDrawer.Value as Operater;
                listDrawer               = new ArrayDrawer(operater.rules);
                listDrawer.Header        = "Operation Rules";
                listDrawer.IsShowBox     = true;
                listDrawer.IsShowInherit = false;

                listDrawer.CreateNewItem = () =>
                {
                    ShowMenuToCreateOperationRule((rule) =>
                    {
                        operater.rules.Add(rule);
                        listDrawer.Refresh();
                    });
                };
                listDrawer.ClearAllItem = () =>
                {
                    operater.rules.Clear();
                    listDrawer.Refresh();
                };
                listDrawer.DeleteItemAt = (index) =>
                {
                    operater.rules.RemoveAt(index);
                    listDrawer.Refresh();
                };
            }
            EGUI.BeginIndent();
            {
                operater.enable = EditorGUILayout.Toggle("enable", operater.enable);
                listDrawer.OnGUILayout();
            }
            EGUI.EndIndent();
        }
Ejemplo n.º 8
0
        public override void OnGUILayout()
        {
            EGUILayout.DrawBoxHeader(Label, GUILayout.ExpandWidth(true));
            if (matcher == null)
            {
                matcher                  = ItemDrawer.Value as Matcher;
                listDrawer               = new ArrayDrawer(matcher.filters);
                listDrawer.Header        = "Filters";
                listDrawer.IsShowBox     = true;
                listDrawer.IsShowInherit = false;

                listDrawer.CreateNewItem = () =>
                {
                    ShowMenuToCreateMatchFilter((filter) =>
                    {
                        matcher.filters.Add(filter);
                        listDrawer.Refresh();
                    });
                };
                listDrawer.ClearAllItem = () =>
                {
                    matcher.filters.Clear();
                    listDrawer.Refresh();
                };
                listDrawer.DeleteItemAt = (index) =>
                {
                    matcher.filters.RemoveAt(index);
                    listDrawer.Refresh();
                };
            }
            EGUI.BeginIndent();
            {
                matcher.enable = EditorGUILayout.Toggle("enable", matcher.enable);
                listDrawer.OnGUILayout();
            }
            EGUI.EndIndent();
        }
Ejemplo n.º 9
0
 public ArrayDrawerAdapter(ArrayDrawer arrayDrawer)
 {
     this.arrayDrawer = arrayDrawer;
 }
Ejemplo n.º 10
0
 void OnEnable()
 {
     this.group      = target as ButtonGroup;
     buttonInspector = new ArrayDrawer <UIButton>(group, "buttons");
 }
        public void Test()
        {
            _inputData = new Vector2[(int)InputDataLength];
            for (int i = 0; i < _inputData.Length; i++)
            {
                _inputData[i] = new Vector2(i);
            }

            var arrayDrawer = new ArrayDrawer();
            var plotSize    = arrayDrawer.MeasurePlotSize(PlotHeight, _inputData.Length);

            _testOutput = new Bitmap(plotSize.Width * 2, plotSize.Height * 4);
            var g = Graphics.FromImage(_testOutput);

            g.SmoothingMode     = SmoothingMode.HighQuality;
            g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
            g.FillRectangle(Brushes.White, 0, 0, _testOutput.Width, _testOutput.Height);

            var app            = Singleton.Get <OpenClApplication>();
            var computeBuffer1 = new ComputeBuffer <Vector2>(app.ComputeContext, ComputeMemoryFlags.None, _inputData);
            var computeBuffer2 = new ComputeBuffer <Vector2>(app.ComputeContext, ComputeMemoryFlags.None, _inputData.Length);

            int n = _inputData.Length;
            int m = Fourier.OddDenominator(n);
            int l = n / m;
            int t = Fourier.PowerOfTwo(l);

            app.Queue.WriteToBuffer(_inputData, computeBuffer1, true, null);
            app.ExecuteKernel("splitFftA", _inputData.Length, 1, computeBuffer1, computeBuffer2, n, m, l, t);
            var splittedArray = new Vector2[_inputData.Length];

            app.Queue.ReadFromBuffer(computeBuffer2, ref splittedArray, true, null);

            var expectedSplitStepResult   = TestCpuFourier.Split(_inputData.ToComplex()).ToVector2();
            var expectedSplitAndFftResult = TestCpuFourier.SplitAndFft(_inputData.ToComplex()).ToVector2();

            //app.Queue.WriteToBuffer(expectedSplitStepResult, computeBuffer2, true, null);
            Fft(computeBuffer2, l, m);
            var fftResultArray = new Vector2[_inputData.Length];

            app.Queue.ReadFromBuffer(computeBuffer2, ref fftResultArray, true, null);

            app.ExecuteKernel("mergeFftStep1A", _inputData.Length, 1, computeBuffer2, computeBuffer1, n, m, l);
            var mergedArray = new Vector2[_inputData.Length];

            app.Queue.ReadFromBuffer(computeBuffer1, ref mergedArray, true, null);


            var expectedBpfStep1Result     = TestCpuFourier.BPF_Step1(_inputData.ToComplex());
            var expectedBpfStep1ResultVec2 = expectedBpfStep1Result.ToVector2();
            var expectedBpfStep2ResultVec2 = TestCpuFourier.BPF_Step2(expectedBpfStep1Result).ToVector2();

            int y = arrayDrawer.Draw(_testOutput, splittedArray, "Split Result", PlotHeight, g: g).Y;

            arrayDrawer.Draw(_testOutput, expectedSplitStepResult, "Expected Split Result", PlotHeight, 0, _testOutput.Width / 2, g);

            arrayDrawer.Draw(_testOutput, expectedSplitAndFftResult, "Expected FFT Result", PlotHeight, y, _testOutput.Width / 2, g);
            y = arrayDrawer.Draw(_testOutput, fftResultArray, "FFT Result", PlotHeight, y, g: g).Y;

            arrayDrawer.Draw(_testOutput, expectedBpfStep1ResultVec2, "Expected Merge FFT Step 1", PlotHeight, y, _testOutput.Width / 2, g);
            y = arrayDrawer.Draw(_testOutput, mergedArray, "Merge FFT Step 1 (Merge Arrays)", PlotHeight, top: y, g: g).Y;

            // step2 test
            //app.Queue.WriteToBuffer(expectedBpfStep1ResultVec2, computeBuffer1, true, null);
            app.ExecuteKernel("mergeFftStep2A", n, 1, computeBuffer1, computeBuffer2, n, m, l);
            var step2Result = new Vector2[_inputData.Length];

            app.Queue.ReadFromBuffer(computeBuffer2, ref step2Result, true, null);

            arrayDrawer.Draw(_testOutput, expectedBpfStep2ResultVec2, "Expected Merge FFT Step2 Result", PlotHeight, y, _testOutput.Width / 2, g);
            y = arrayDrawer.Draw(_testOutput, step2Result, "Actual Merge FFT Step2 Result", PlotHeight, top: y, g: g).Y;

            Output = ImageHandler.FromBitmap(_testOutput);
            Output.UploadToComputingDevice();
            Update();
            OnUpdated();
        }