private UnityEngine.Texture GetSourceIcon(WireListData wireListData)
        {
            Texture2D icon = null;

            switch (wireListData.Source)
            {
            case SwitchSource.Playfield:
            {
                if (_switches.ContainsKey(wireListData.SourcePlayfieldItem.ToLower()))
                {
                    icon = Icons.ByComponent(_switches[wireListData.SourcePlayfieldItem.ToLower()], IconSize.Small);
                }
                break;
            }

            case SwitchSource.Constant:
                icon = Icons.Switch(wireListData.SourceConstant == SwitchConstant.NormallyClosed, IconSize.Small);
                break;

            case SwitchSource.InputSystem:
                icon = Icons.Key(IconSize.Small);
                break;

            case SwitchSource.Device:
                if (_switchDevices.ContainsKey(wireListData.SourceDevice.ToLower()))
                {
                    icon = Icons.ByComponent(_switchDevices[wireListData.SourceDevice.ToLower()], IconSize.Small);
                }
                break;
            }

            return(icon);
        }
示例#2
0
        private UnityEngine.Texture GetIcon(SwitchListData switchListData)
        {
            Texture2D icon = null;

            switch (switchListData.Source)
            {
            case SwitchSource.Playfield: {
                if (_switchables.ContainsKey(switchListData.PlayfieldItem.ToLower()))
                {
                    icon = Icons.ByComponent(_switchables[switchListData.PlayfieldItem.ToLower()], size: IconSize.Small);
                }
                break;
            }

            case SwitchSource.Constant:
                icon = Icons.Switch(switchListData.Constant == SwitchConstant.NormallyClosed, size: IconSize.Small);
                break;

            case SwitchSource.InputSystem:
                icon = Icons.Key(IconSize.Small);
                break;
            }

            return(icon);
        }
示例#3
0
        protected override Texture GetIcon(SwitchListData switchListData)
        {
            Texture2D icon = null;

            switch (switchListData.Source)
            {
            case SwitchSource.Playfield: {
                if (switchListData.Device != null)
                {
                    icon = Icons.ByComponent(switchListData.Device, IconSize.Small);
                }
                break;
            }

            case SwitchSource.Constant:
                icon = Icons.Switch(switchListData.Constant == SwitchConstant.Closed, IconSize.Small);
                break;

            case SwitchSource.InputSystem:
                icon = Icons.Key(IconSize.Small);
                break;
            }

            return(icon);
        }
示例#4
0
 public ElementDropdownItem(UnityEngine.Object element) : base(element == null ? "None" : element.name)
 {
     if (element != null)
     {
         Item = element;
         icon = Icons.ByComponent(element, color: IconColor.Gray, size: IconSize.Small);
     }
 }
        public void Render(Rect pos, T currentObj, Action <T> onUpdated, Func <T, bool> filter = null)
        {
            // render content
            var content = currentObj == null
                                ? new GUIContent("None")
                                : _showIcon
                                        ? new GUIContent(currentObj.name, Icons.ByComponent(currentObj, IconSize.Small, IconColor))
                                        : new GUIContent(currentObj.name);

            // render drawer
            var id = GUIUtility.GetControlID(FocusType.Keyboard, pos);
            var objectFieldButton = GUI.skin.GetStyle("ObjectFieldButton");
            var suffixButtonPos   = new Rect(pos.xMax - 19f, pos.y + 1, 19f, pos.height - 2);

            EditorGUIUtility.SetIconSize(new Vector2(12f, 12f));

            // handle click
            if (Event.current.type == EventType.MouseDown && pos.Contains(Event.current.mousePosition))
            {
                if (currentObj != null && !suffixButtonPos.Contains(Event.current.mousePosition))
                {
                    // click on ping
                    var mb = currentObj as MonoBehaviour;
                    if (mb)
                    {
                        EditorGUIUtility.PingObject(mb.gameObject);
                    }
                }
                else
                {
                    // click on picker
                    _itemPickDropdownState ??= new AdvancedDropdownState();
                    var dropdown = new ItemSearchableDropdown <T>(
                        _itemPickDropdownState,
                        _tableComp,
                        _pickerTitle,
                        onUpdated,
                        filter
                        );
                    dropdown.Show(pos);
                }
            }

            if (Event.current.type == EventType.Repaint)
            {
                EditorStyles.objectField.Draw(pos, content, id, DragAndDrop.activeControlID == id, pos.Contains(Event.current.mousePosition));
                objectFieldButton.Draw(suffixButtonPos, GUIContent.none, id, DragAndDrop.activeControlID == id, suffixButtonPos.Contains(Event.current.mousePosition));
            }
        }
示例#6
0
        private UnityEngine.Texture GetIcon(CoilListData coilListData)
        {
            Texture2D icon = null;

            switch (coilListData.Destination)
            {
            case CoilDestination.Playfield:
            {
                if (_coils.ContainsKey(coilListData.PlayfieldItem.ToLower()))
                {
                    icon = Icons.ByComponent(_coils[coilListData.PlayfieldItem.ToLower()], size: IconSize.Small);
                }
                break;
            }
            }

            return(icon);
        }
        protected override Texture GetIcon(CoilListData coilListData)
        {
            Texture2D icon = null;

            switch (coilListData.Destination)
            {
            case CoilDestination.Playfield:
                if (coilListData.Device != null)
                {
                    icon = Icons.ByComponent(coilListData.Device, IconSize.Small);
                }
                break;

            case CoilDestination.Lamp:
                icon = Icons.Light(IconSize.Small);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(icon);
        }
        private UnityEngine.Texture GetDestinationIcon(WireListData wireListData)
        {
            Texture2D icon = null;

            switch (wireListData.Destination)
            {
            case CoilDestination.Playfield:
                if (_coils.ContainsKey(wireListData.DestinationPlayfieldItem.ToLower()))
                {
                    icon = Icons.ByComponent(_coils[wireListData.DestinationPlayfieldItem.ToLower()], size: IconSize.Small);
                }
                break;

            case CoilDestination.Device:
                if (_coilDevices.ContainsKey(wireListData.DestinationDevice.ToLower()))
                {
                    icon = Icons.ByComponent(_coilDevices[wireListData.DestinationDevice.ToLower()], IconSize.Small);
                }
                break;
            }

            return(icon);
        }
示例#9
0
        private void DevicePicker(Rect pos, SerializedProperty property, TypeRestrictionAttribute attrib, Component comp, UnityEngine.Object field, TableComponent ta)
        {
            // retrieve selected reference
            MonoBehaviour obj = null;

            if (_component == null)
            {
                if (field != null)
                {
                    obj = ta.GetComponentsInChildren(attrib.Type, true)
                          .FirstOrDefault(s => s == field) as MonoBehaviour;
                    _component = obj;
                }
            }
            else
            {
                obj = _component;
            }

            // render content
            var content = obj == null
                                ? new GUIContent(attrib.NoneLabel)
                                : new GUIContent(obj.name, Icons.ByComponent(obj, IconSize.Small, IconColor.Orange));

            // render drawer
            var id = GUIUtility.GetControlID(FocusType.Keyboard, pos);
            var objectFieldButton = GUI.skin.GetStyle("ObjectFieldButton");
            var suffixButtonPos   = new Rect(pos.xMax - 19f, pos.y + 1, 19f, pos.height - 2);

            EditorGUIUtility.SetIconSize(new Vector2(12f, 12f));

            // handle click
            if (Event.current.type == EventType.MouseDown && pos.Contains(Event.current.mousePosition))
            {
                // click on ping
                if (obj != null && !suffixButtonPos.Contains(Event.current.mousePosition))
                {
                    EditorGUIUtility.PingObject(obj.gameObject);

                    // click on picker
                }
                else
                {
                    _itemPickDropdownState ??= new AdvancedDropdownState();

                    var dropdown = new ItemSearchableDropdownUntyped(
                        attrib.Type,
                        _itemPickDropdownState,
                        ta,
                        attrib.PickerLabel,
                        item => {
                        switch (item)
                        {
                        case null:
                            _component = null;
                            property.objectReferenceValue = null;
                            break;

                        case MonoBehaviour mb:
                            _component = mb;
                            property.objectReferenceValue = mb;
                            break;
                        }
                        property.serializedObject.ApplyModifiedProperties();
                        if (comp is IMainRenderableComponent renderable)
                        {
                            if (attrib.RebuildMeshes)
                            {
                                renderable.RebuildMeshes();
                            }
                            if (attrib.UpdateTransforms)
                            {
                                renderable.UpdateTransforms();
                            }
                        }
                    }
                        );
                    dropdown.Show(pos);
                }
            }
            if (Event.current.type == EventType.Repaint)
            {
                EditorStyles.objectField.Draw(pos, content, id, DragAndDrop.activeControlID == id, pos.Contains(Event.current.mousePosition));
                objectFieldButton.Draw(suffixButtonPos, GUIContent.none, id, DragAndDrop.activeControlID == id, suffixButtonPos.Contains(Event.current.mousePosition));
            }
        }
 protected override Texture GetIcon(LampListData lampListData)
 {
     return(lampListData.Device != null
                         ? Icons.ByComponent(lampListData.Device, IconSize.Small)
                         : null);
 }
示例#11
0
 public ElementDropdownItem(TItem element) : base(element.Name)
 {
     Item = element;
     icon = Icons.ByComponent(element, color: IconColor.Gray, size: IconSize.Small);
 }