protected void Init(O data, T newValue, MethodInfo getter, MethodInfo setter, bool updateTree, bool updatePanel, VoidCall changed)
        {
            this.data        = data;
            this.newValue    = newValue;
            this.updatePanel = updatePanel;
            this.updateTree  = updateTree;

            this.get     = (Func <T>)Delegate.CreateDelegate(typeof(Func <T>), data, getter);
            this.set     = (Action <T>)Delegate.CreateDelegate(typeof(Action <T>), data, setter);
            this.changed = changed;
        }
        // ----------------------
        // Constructor
        // ---------------------
        public QRScannerEffectEditor()
        {
            effect    = new QRScannerEffect();
            effectIds = new List <string>();

            listTypeNames = Enum.GetValues(typeof(QRScannerEffect.ListType))
                            .Cast <QRScannerEffect.ListType>()
                            .Select(v => TC.get("QR.QRScannerEffect.ListType." + v.ToString()))
                            .ToArray();

            Action <ReorderableList> listChangedCallback = (r) =>
            {
                Controller.Instance.AddTool(new ChangeValueTool <QRScannerEffect, List <string> >(effect, effectIds.ToList(), "ValidIds"));
            };

            GenericMenu.MenuFunction2 toAddSelected = (s) =>
            {
                effectIds.Add((string)s);
                listChangedCallback(qrIdReorderableList);
            };

            qrIdReorderableList = new ReorderableList(effectIds, typeof(string))
            {
                drawElementCallback = (rect, index, isActive, isFocused) =>
                {
                    EditorGUI.LabelField(rect, (string)qrIdReorderableList.list[index]);
                },
                onAddDropdownCallback = (rect, list) =>
                {
                    var genericMenu = new GenericMenu();
                    foreach (var qr in qrIds)
                    {
                        genericMenu.AddItem(new GUIContent(qr), false, toAddSelected, qr);
                    }
                    genericMenu.ShowAsContext();
                },
                onRemoveCallback = (r) =>
                {
                    effectIds.RemoveAt(r.index);
                    listChangedCallback(r);
                },
                onReorderCallback = (r) => listChangedCallback(r)
            };
        }
Ejemplo n.º 3
0
 public ProgressCallback(int todo, Action <int, ProgressController, bool> callback)
 {
     this.progressController = new ProgressController(todo);
     this.callback           = callback;
 }