Пример #1
0
        private void NewUnit(Vector2 unitPosition, UnitOptionTree options, Action <IUnit> then = null)
        {
            delayCall += () =>
            {
                var activatorPosition = new Rect(e.mousePosition, new Vector2(200, 1));

                var context = this.context;

                LudiqGUI.FuzzyDropdown
                (
                    activatorPosition,
                    options,
                    null,
                    delegate(object _option)
                {
                    context.BeginEdit();

                    var option = (IUnitOption)_option;
                    var unit   = option.InstantiateUnit();
                    AddUnit(unit, unitPosition);
                    option.PreconfigureUnit(unit);
                    then?.Invoke(unit);
                    GUI.changed = true;

                    context.EndEdit();
                }
                );
            };
        }
Пример #2
0
        private UnitOptionTree GetNewUnitOptions(UnitOptionFilter filter)
        {
            var options = new UnitOptionTree(new GUIContent("Unit"));

            options.filter    = filter;
            options.reference = reference;

            if (filter.CompatibleOutputType == typeof(object))
            {
                options.surfaceCommonTypeLiterals = true;
            }

            return(options);
        }
Пример #3
0
        private void ReplaceUnit()
        {
            var oldUnit      = unit;
            var unitPosition = oldUnit.position;
            var preservation = UnitPreservation.Preserve(oldUnit);

            var options = new UnitOptionTree(new GUIContent("Unit"));

            options.reference = reference;

            var activatorPosition = new Rect(e.mousePosition, new Vector2(200, 1));

            var context = this.context;

            LudiqGUI.FuzzyDropdown
            (
                activatorPosition,
                options,
                null,
                delegate(object _option)
            {
                var option = (IUnitOption)_option;

                context.BeginEdit();
                UndoUtility.RecordEditedObject("Replace Unit");
                var graph = oldUnit.graph;
                oldUnit.graph.units.Remove(oldUnit);
                var newUnit      = option.InstantiateUnit();
                newUnit.guid     = Guid.NewGuid();
                newUnit.position = unitPosition;
                graph.units.Add(newUnit);
                preservation.RestoreTo(newUnit);
                option.PreconfigureUnit(newUnit);
                selection.Select(newUnit);
                GUI.changed = true;
                context.EndEdit();
            }
            );
        }
Пример #4
0
 public Favorites(UnitOptionTree tree)
 {
     this.tree = tree;
 }