Exemplo n.º 1
0
        void CreateResources()
        {
            if (refreshIcon == null)
            {
                refreshIcon           = EditorGUIUtility.LoadIcon("Refresh");
                refreshIcon.hideFlags = HideFlags.HideAndDontSave;
                refreshIcon.name      = "RefreshIcon";
            }

            if (header == null)
            {
                header = "OL Title";
            }

            CreateStaticResources();

            if (s_ToolbarButtonsWidth == 0f)
            {
                s_ToolbarButtonsWidth  = EditorStyles.toolbarButton.CalcSize(EditorGUIUtility.TrTextContent("Incoming (xx)")).x;
                s_ToolbarButtonsWidth += EditorStyles.toolbarButton.CalcSize(EditorGUIUtility.TrTextContent("Outgoing")).x;
                s_ToolbarButtonsWidth += EditorStyles.toolbarButton.CalcSize(new GUIContent(refreshIcon)).x;

                s_SettingsButtonWidth         = EditorStyles.toolbarButton.CalcSize(EditorGUIUtility.TrTextContent("Settings")).x;
                s_DeleteChangesetsButtonWidth = EditorStyles.toolbarButton.CalcSize(EditorGUIUtility.TrTextContent("Delete Empty Changesets")).x;
            }
        }
Exemplo n.º 2
0
 private void CreateResources()
 {
     if ((UnityEngine.Object) this.blueTex == (UnityEngine.Object)null)
     {
         this.blueTex = new Texture2D(1, 1);
         this.blueTex.SetPixel(0, 0, new Color(0.23f, 0.35f, 0.55f));
         this.blueTex.hideFlags = HideFlags.HideAndDontSave;
         this.blueTex.name      = "BlueTex";
         this.blueTex.Apply();
     }
     if ((UnityEngine.Object) this.greyTex == (UnityEngine.Object)null)
     {
         this.greyTex = new Texture2D(1, 1);
         this.greyTex.SetPixel(0, 0, new Color(0.3f, 0.3f, 0.3f));
         this.greyTex.hideFlags = HideFlags.HideAndDontSave;
         this.greyTex.name      = "GrayTex";
         this.greyTex.Apply();
     }
     if ((UnityEngine.Object) this.yellowTex == (UnityEngine.Object)null)
     {
         this.yellowTex = new Texture2D(1, 1);
         this.yellowTex.SetPixel(0, 0, new Color(0.5f, 0.5f, 0.2f));
         this.yellowTex.name      = "YellowTex";
         this.yellowTex.hideFlags = HideFlags.HideAndDontSave;
         this.yellowTex.Apply();
     }
     if (!((UnityEngine.Object) this.defaultIcon == (UnityEngine.Object)null))
     {
         return;
     }
     this.defaultIcon           = EditorGUIUtility.LoadIcon("vcs_document");
     this.defaultIcon.hideFlags = HideFlags.HideAndDontSave;
 }
Exemplo n.º 3
0
        // Late resource creation
        void CreateResources()
        {
            if (blueTex == null)
            {
                blueTex = new Texture2D(1, 1);
                blueTex.SetPixel(0, 0, new Color(0.23f, 0.35f, 0.55f));
                blueTex.hideFlags = HideFlags.HideAndDontSave;
                blueTex.name      = "BlueTex";
                blueTex.Apply();
            }

            if (greyTex == null)
            {
                greyTex = new Texture2D(1, 1);
                greyTex.SetPixel(0, 0, new Color(0.3f, 0.3f, 0.3f));
                greyTex.hideFlags = HideFlags.HideAndDontSave;
                greyTex.name      = "GrayTex";
                greyTex.Apply();
            }

            if (yellowTex == null)
            {
                yellowTex = new Texture2D(1, 1);
                yellowTex.SetPixel(0, 0, new Color(0.5f, 0.5f, 0.2f));
                yellowTex.name      = "YellowTex";
                yellowTex.hideFlags = HideFlags.HideAndDontSave;
                yellowTex.Apply();
            }

            if (defaultIcon == null)
            {
                defaultIcon           = EditorGUIUtility.LoadIcon("vcs_document");
                defaultIcon.hideFlags = HideFlags.HideAndDontSave;
            }
        }
Exemplo n.º 4
0
 public PresetListArea(ObjectListAreaState state, PresetSelector owner)
     : base(state, owner, true)
 {
     if (noneItem != null)
     {
         noneItem.m_Icon = EditorGUIUtility.LoadIcon("Preset.Current");
     }
 }
 public static Texture2D GetIconCurve()
 {
     if (iconCurve == null)
     {
         iconCurve = EditorGUIUtility.LoadIcon("animationanimated");
     }
     return(iconCurve);
 }
 public static Texture2D GetIconKey()
 {
     if (iconKey == null)
     {
         iconKey = EditorGUIUtility.LoadIcon("animationkeyframe");
     }
     return(iconKey);
 }
 public HistoryProgressSpinner()
 {
     m_StatusWheelTextures = new Texture2D[12];
     for (int i = 0; i < 12; i++)
     {
         m_StatusWheelTextures[i] = EditorGUIUtility.LoadIcon("WaitSpin" + i.ToString("00"));
     }
     image        = m_StatusWheelTextures[0];
     style.width  = m_StatusWheelTextures[0].width;
     style.height = m_StatusWheelTextures[0].height;
     visible      = false;
 }
 public HistoryProgressSpinner()
 {
     this.m_StatusWheelTextures = new Texture2D[12];
     for (int i = 0; i < 12; i++)
     {
         this.m_StatusWheelTextures[i] = EditorGUIUtility.LoadIcon("WaitSpin" + i.ToString("00"));
     }
     base.image        = this.m_StatusWheelTextures[0];
     base.style.width  = (float)this.m_StatusWheelTextures[0].width;
     base.style.height = (float)this.m_StatusWheelTextures[0].height;
     base.visible      = false;
 }
        private Image GetIconElement(string action, string fileName, bool isFolder)
        {
            string str  = (!isFolder) ? "File" : "Folder";
            string text = action.First <char>().ToString().ToUpper() + action.Substring(1);

            text = ((!text.Equals("Renamed")) ? text : "Moved");
            return(new Image
            {
                name = "FileIcon",
                image = EditorGUIUtility.LoadIcon("Icons/Collab." + str + text + ".png")
            });
        }
Exemplo n.º 10
0
 private static void CreateStaticResources()
 {
     if (Overlay.s_BlueLeftParan == null)
     {
         Overlay.s_BlueLeftParan            = EditorGUIUtility.LoadIcon("P4_BlueLeftParenthesis");
         Overlay.s_BlueLeftParan.hideFlags  = HideFlags.HideAndDontSave;
         Overlay.s_BlueRightParan           = EditorGUIUtility.LoadIcon("P4_BlueRightParenthesis");
         Overlay.s_BlueRightParan.hideFlags = HideFlags.HideAndDontSave;
         Overlay.s_RedLeftParan             = EditorGUIUtility.LoadIcon("P4_RedLeftParenthesis");
         Overlay.s_RedLeftParan.hideFlags   = HideFlags.HideAndDontSave;
         Overlay.s_RedRightParan            = EditorGUIUtility.LoadIcon("P4_RedRightParenthesis");
         Overlay.s_RedRightParan.hideFlags  = HideFlags.HideAndDontSave;
     }
 }
Exemplo n.º 11
0
 void CreateStaticResources()
 {
     if (syncIcon == null)
     {
         syncIcon           = EditorGUIUtility.LoadIcon("VersionControl/Incoming Icon");
         syncIcon.hideFlags = HideFlags.HideAndDontSave;
         syncIcon.name      = "SyncIcon";
     }
     if (changeIcon == null)
     {
         changeIcon           = EditorGUIUtility.LoadIcon("VersionControl/Outgoing Icon");
         changeIcon.hideFlags = HideFlags.HideAndDontSave;
         changeIcon.name      = "ChangeIcon";
     }
 }
Exemplo n.º 12
0
 private void CreateStaticResources()
 {
     if (this.syncIcon == null)
     {
         this.syncIcon           = EditorGUIUtility.LoadIcon("vcs_incoming");
         this.syncIcon.hideFlags = HideFlags.HideAndDontSave;
         this.syncIcon.name      = "SyncIcon";
     }
     if (WindowPending.changeIcon == null)
     {
         WindowPending.changeIcon           = EditorGUIUtility.LoadIcon("vcs_change");
         WindowPending.changeIcon.hideFlags = HideFlags.HideAndDontSave;
         WindowPending.changeIcon.name      = "ChangeIcon";
     }
 }
Exemplo n.º 13
0
 void CreateStaticResources()
 {
     if (syncIcon == null)
     {
         syncIcon           = EditorGUIUtility.LoadIcon("vcs_incoming");
         syncIcon.hideFlags = HideFlags.HideAndDontSave;
         syncIcon.name      = "SyncIcon";
     }
     if (changeIcon == null)
     {
         changeIcon           = EditorGUIUtility.LoadIcon("vcs_change");
         changeIcon.hideFlags = HideFlags.HideAndDontSave;
         changeIcon.name      = "ChangeIcon";
     }
 }
        private Image GetIconElement(string action, string fileName, bool isFolder)
        {
            var prefix     = isFolder ? "Folder" : "File";
            var actionName = action.First().ToString().ToUpper() + action.Substring(1);

            // Use the same icon for renamed and moved files
            actionName = actionName.Equals("Renamed") ? "Moved" : actionName;
            var iconElement = new Image
            {
                name  = "FileIcon",
                image = EditorGUIUtility.LoadIcon("Icons/Collab." + prefix + actionName + ".png")
            };

            return(iconElement);
        }
Exemplo n.º 15
0
 private void CreateStaticResources()
 {
     if ((UnityEngine.Object) this.syncIcon == (UnityEngine.Object)null)
     {
         this.syncIcon           = EditorGUIUtility.LoadIcon("vcs_incoming");
         this.syncIcon.hideFlags = HideFlags.HideAndDontSave;
         this.syncIcon.name      = "SyncIcon";
     }
     if (!((UnityEngine.Object)WindowPending.changeIcon == (UnityEngine.Object)null))
     {
         return;
     }
     WindowPending.changeIcon           = EditorGUIUtility.LoadIcon("vcs_change");
     WindowPending.changeIcon.hideFlags = HideFlags.HideAndDontSave;
     WindowPending.changeIcon.name      = "ChangeIcon";
 }
        private static void ShowError(string error)
        {
            if (SpriteShapeRendererInspector.s_WarningIcon == null)
            {
                SpriteShapeRendererInspector.s_WarningIcon = EditorGUIUtility.LoadIcon("console.warnicon");
            }
            GUIContent content = new GUIContent(error)
            {
                image = SpriteShapeRendererInspector.s_WarningIcon
            };

            GUILayout.Space(5f);
            GUILayout.BeginVertical(EditorStyles.helpBox, new GUILayoutOption[0]);
            GUILayout.Label(content, EditorStyles.wordWrappedMiniLabel, new GUILayoutOption[0]);
            GUILayout.EndVertical();
        }
Exemplo n.º 17
0
        void CreateVCSImageIfNeeded()
        {
            if (m_VCSStatusImage == null)
            {
                m_VCSStatusImage = new Image();
                m_VCSStatusImage.style.position  = PositionType.Absolute;
                m_VCSStatusImage.style.left      = 12;
                m_VCSStatusImage.style.top       = 12;
                m_VCSStatusImage.style.width     = 14;
                m_VCSStatusImage.style.height    = 14;
                m_VCSStatusImage.style.alignSelf = Align.Center;
                m_VCSStatusImage.image           = EditorGUIUtility.LoadIcon(EditorResources.iconsPath + "VersionControl/P4_OutOfSync.png");

                m_AddButton.Add(m_VCSStatusImage);
            }
        }
        private static void ShowError(string error)
        {
            if (s_WarningIcon == null)
            {
                s_WarningIcon = EditorGUIUtility.LoadIcon("console.warnicon");
            }

            var c = new GUIContent(error)
            {
                image = s_WarningIcon
            };

            GUILayout.Space(5);
            GUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Label(c, EditorStyles.wordWrappedMiniLabel);
            GUILayout.EndVertical();
        }
Exemplo n.º 19
0
        static Styles()
        {
            if (!isDarkTheme)
            {
                selectedItemLabel.normal.textColor       = Color.white;
                selectedItemDescription.normal.textColor = Color.white;
            }

            statusWheel = new GUIContent[12];
            for (int i = 0; i < 12; i++)
            {
                statusWheel[i] = EditorGUIUtility.IconContent("WaitSpin" + i.ToString("00"));
            }

            var syncShortcut = ShortcutManager.instance.GetShortcutBinding(QuickSearch.k_TogleSyncShortcutName);
            var tooltip      = $"Synchronize search fields ({syncShortcut})";

            syncSearchButtonContent   = new GUIContent(string.Empty, EditorGUIUtility.LoadIcon("QuickSearch/SyncSearch"), tooltip);
            syncSearchOnButtonContent = new GUIContent(string.Empty, EditorGUIUtility.LoadIcon("QuickSearch/SyncSearch On"), tooltip);
        }
Exemplo n.º 20
0
        private static void CreateStaticResources()
        {
            if (s_BlueLeftParan == null)
            {
                s_BlueLeftParan           = EditorGUIUtility.LoadIcon("VersionControl/P4_BlueLeftParenthesis");
                s_BlueLeftParan.hideFlags = HideFlags.HideAndDontSave;

                s_BlueRightParan           = EditorGUIUtility.LoadIcon("VersionControl/P4_BlueRightParenthesis");
                s_BlueRightParan.hideFlags = HideFlags.HideAndDontSave;

                s_RedLeftParan           = EditorGUIUtility.LoadIcon("VersionControl/P4_RedLeftParenthesis");
                s_RedLeftParan.hideFlags = HideFlags.HideAndDontSave;

                s_RedRightParan           = EditorGUIUtility.LoadIcon("VersionControl/P4_RedRightParenthesis");
                s_RedRightParan.hideFlags = HideFlags.HideAndDontSave;

                s_DisconnectedIcon           = EditorGUIUtility.LoadIcon("VersionControl/P4_Offline");
                s_DisconnectedIcon.hideFlags = HideFlags.HideAndDontSave;
            }
        }
Exemplo n.º 21
0
 private void CreateResources()
 {
     if (this.refreshIcon == null)
     {
         this.refreshIcon           = EditorGUIUtility.LoadIcon("Refresh");
         this.refreshIcon.hideFlags = HideFlags.HideAndDontSave;
         this.refreshIcon.name      = "RefreshIcon";
     }
     if (this.header == null)
     {
         this.header = "OL Title";
     }
     this.CreateStaticResources();
     if (this.s_ToolbarButtonsWidth == 0f)
     {
         this.s_ToolbarButtonsWidth  = EditorStyles.toolbarButton.CalcSize(new GUIContent("Incoming (xx)")).x;
         this.s_ToolbarButtonsWidth += EditorStyles.toolbarButton.CalcSize(new GUIContent("Outgoing")).x;
         this.s_ToolbarButtonsWidth += EditorStyles.toolbarButton.CalcSize(new GUIContent("Settings")).x;
         this.s_ToolbarButtonsWidth += EditorStyles.toolbarButton.CalcSize(new GUIContent(this.refreshIcon)).x;
     }
 }
        public BuilderInspectorHeader(BuilderInspector inspector)
        {
            m_Inspector       = inspector;
            m_Selection       = inspector.selection;
            m_Header          = m_Inspector.Q <VisualElement>("header-container");
            m_StatusIndicator = m_Header.Q <FieldStatusIndicator>("header-field-status-indicator");
            m_StatusIndicator.populateMenuItems = (menu) =>
            {
                BuildNameFieldContextualMenu(menu, m_TextField);
            };

            m_InnerHeader = m_Inspector.Q <VisualElement>("header-container-minor");
            m_Icon        = m_Inspector.Q <VisualElement>("header-icon");

            m_Pill = m_Inspector.Q <Label>("header-selected-pill");
            m_Pill.AddToClassList("unity-builder-tag-pill");

            m_TextField             = m_Inspector.Q <TextField>("header-selected-text-field");
            m_TextField.isDelayed   = true;
            m_TextField.tooltip     = "name";
            m_TextField.bindingPath = "name";

            m_EditorWarningHelpBox      = m_Inspector.Q <UnityEngine.UIElements.HelpBox>("header-editor-warning-help-box");
            m_EditorWarningHelpBox.text = BuilderConstants.HeaderSectionHelpBoxMessage;
            m_ErrorIcon = m_Inspector.Q <VisualElement>("header-error-icon");

            // Warning must be hidden at first
            m_ErrorIcon.style.backgroundImage = EditorGUIUtility.LoadIcon("console.erroricon");
            AdjustBottomPadding(false);

            // Store callbacks to reduce delegate allocations
            m_ElementNameChangeCallback    = new EventCallback <ChangeEvent <string> >(OnNameAttributeChange);
            m_SelectorNameChangeCallback   = new EventCallback <ChangeEvent <string> >(OnStyleSelectorNameChange);
            m_SelectorEnterKeyDownCallback = new EventCallback <KeyDownEvent>(OnEnterStyleSelectorNameChange);

            m_TextField.RegisterValueChangedCallback(m_ElementNameChangeCallback);
            m_RightClickManipulator = new ContextualMenuManipulator(BuildNameFieldContextualMenu);
        }
Exemplo n.º 23
0
 private void CreateResources()
 {
     if ((UnityEngine.Object) this.refreshIcon == (UnityEngine.Object)null)
     {
         this.refreshIcon           = EditorGUIUtility.LoadIcon("Refresh");
         this.refreshIcon.hideFlags = HideFlags.HideAndDontSave;
         this.refreshIcon.name      = "RefreshIcon";
     }
     if (this.header == null)
     {
         this.header = (GUIStyle)"OL Title";
     }
     this.CreateStaticResources();
     if ((double)this.s_ToolbarButtonsWidth != 0.0)
     {
         return;
     }
     this.s_ToolbarButtonsWidth         = EditorStyles.toolbarButton.CalcSize(new GUIContent("Incoming (xx)")).x;
     this.s_ToolbarButtonsWidth        += EditorStyles.toolbarButton.CalcSize(new GUIContent("Outgoing")).x;
     this.s_ToolbarButtonsWidth        += EditorStyles.toolbarButton.CalcSize(new GUIContent((Texture)this.refreshIcon)).x;
     this.s_SettingsButtonWidth         = EditorStyles.toolbarButton.CalcSize(new GUIContent("Settings")).x;
     this.s_DeleteChangesetsButtonWidth = EditorStyles.toolbarButton.CalcSize(new GUIContent("Delete Empty Changesets")).x;
 }
Exemplo n.º 24
0
        protected DropDownButtonBase(
            VFXView view,
            string uxmlSource,
            string mainButtonLabel,
            string mainButtonName,
            string iconPath,
            bool hasSeparatorBefore = false,
            bool hasSeparatorAfter  = false)
        {
            m_VFXView           = view;
            style.flexDirection = new StyleEnum <FlexDirection>(FlexDirection.Row);

            if (hasSeparatorBefore)
            {
                m_HasLeftSeparator = true;
                var divider = new VisualElement();
                divider.AddToClassList("separator");
                Add(divider);
            }

            m_MainButton = new Button(OnMainButton)
            {
                name = mainButtonName
            };
            m_MainButton.AddToClassList("dropdown-button");
            m_MainButton.AddToClassList("unity-toolbar-toggle");
            if (!string.IsNullOrEmpty(iconPath))
            {
                var icon = new Image {
                    image = EditorGUIUtility.LoadIcon(iconPath)
                };
                m_MainButton.Add(icon);
                m_MainButton.tooltip = mainButtonLabel;
            }
            else
            {
                m_MainButton.text = mainButtonLabel;
            }
            Add(m_MainButton);

            var separator = new VisualElement();

            separator.AddToClassList("dropdown-separator");
            Add(separator);

            var dropDownButton = new Button(OnTogglePopup);

            dropDownButton.AddToClassList("dropdown-arrow");
            dropDownButton.AddToClassList("unity-toolbar-toggle");
            dropDownButton.Add(new VisualElement());
            Add(dropDownButton);

            if (hasSeparatorAfter)
            {
                var divider = new VisualElement();
                divider.AddToClassList("separator");
                Add(divider);
            }

            m_PopupContent = new VisualElement();
            var tpl = VFXView.LoadUXML(uxmlSource);

            tpl.CloneTree(m_PopupContent);
            contentContainer.AddStyleSheetPath("VFXToolbar");
        }
 private void OnEnable()
 {
     m_HelpIcon = EditorGUIUtility.LoadIcon("Icons/_Help.png");
     UpdateSceneTemplateAsset();
 }
Exemplo n.º 26
0
        public VFXComponentBoard(VFXView view)
        {
            m_View = view;
            var tpl = VFXView.LoadUXML("VFXComponentBoard");

            tpl.CloneTree(contentContainer);

            contentContainer.AddStyleSheetPath("VFXComponentBoard");

            m_RootElement        = this.Query <VisualElement>("component-container");
            m_SubtitleIcon       = this.Query <Image>("subTitle-icon");
            m_Subtitle           = this.Query <Label>("subTitleLabel");
            m_SubtitleIcon.image = EditorGUIUtility.LoadIcon(EditorResources.iconsPath + "console.warnicon.sml.png");

            m_Stop = this.Query <Button>("stop");
            m_Stop.clickable.clicked += EffectStop;
            m_Play = this.Query <Button>("play");
            m_Play.clickable.clicked += EffectPlay;
            m_Step = this.Query <Button>("step");
            m_Step.clickable.clicked += EffectStep;
            m_Restart = this.Query <Button>("restart");
            m_Restart.clickable.clicked += EffectRestart;

            m_PlayRateSlider           = this.Query <Slider>("play-rate-slider");
            m_PlayRateSlider.lowValue  = Mathf.Pow(VisualEffectControl.minSlider, 1 / VisualEffectControl.sliderPower);
            m_PlayRateSlider.highValue = Mathf.Pow(VisualEffectControl.maxSlider, 1 / VisualEffectControl.sliderPower);
            m_PlayRateSlider.RegisterValueChangedCallback(evt => OnEffectSlider(evt.newValue));
            m_PlayRateField = this.Query <IntegerField>("play-rate-field");
            m_PlayRateField.RegisterCallback <ChangeEvent <int> >(OnPlayRateField);

            m_PlayRateMenu = this.Query <Button>("play-rate-menu");
            m_PlayRateMenu.AddStyleSheetPathWithSkinVariant("VFXControls");

            m_PlayRateMenu.clickable.clicked += OnPlayRateMenu;

            m_ParticleCount = this.Query <Label>("particle-count");

            Button button = this.Query <Button>("on-play-button");

            button.clickable.clicked += () => SendEvent(VisualEffectAsset.PlayEventName);
            button = this.Query <Button>("on-stop-button");
            button.clickable.clicked += () => SendEvent(VisualEffectAsset.StopEventName);

            m_EventsContainer = this.Query("events-container");

            m_DebugModes = this.Query <Button>("debug-modes");
            m_DebugModes.clickable.clicked += OnDebugModes;

            m_RecordIcon         = VFXView.LoadImage("d_Record");
            m_RecordBoundsButton = this.Query <Button>("record");
            m_RecordBoundsImage  = m_RecordBoundsButton.Query <Image>("record-icon");
            m_RecordBoundsImage.style.backgroundImage = m_RecordIcon;
            m_RecordBoundsButton.clickable.clicked   += OnRecordBoundsButton;
            m_BoundsActionLabel      = this.Query <Label>("bounds-label");
            m_BoundsToolContainer    = this.Query("bounds-tool-container");
            m_BackgroundDefaultColor = m_BoundsToolContainer.style.backgroundColor;
            m_SystemBoundsContainer  = this.Query <VFXBoundsSelector>("system-bounds-container");
            m_SystemBoundsContainer.RegisterCallback <MouseDownEvent>(OnMouseClickBoundsContainer);

            m_ApplyBoundsButton = this.Query <Button>("apply-bounds-button");
            m_ApplyBoundsButton.clickable.clicked += ApplyCurrentBounds;

            Detach();
            this.AddManipulator(new Dragger {
                clampToParentEdges = true
            });

            capabilities |= Capabilities.Movable;

            RegisterCallback <MouseDownEvent>(OnMouseClick);

            style.position = PositionType.Absolute;

            SetPosition(BoardPreferenceHelper.LoadPosition(BoardPreferenceHelper.Board.componentBoard, defaultRect));
        }
Exemplo n.º 27
0
 public SceneScreenshotToolsStrip() : base(TakeScenePreview)
 {
     name    = "ScenePreviewScreenshot";
     icon    = EditorGUIUtility.LoadIcon("CameraPreview");
     tooltip = L10n.Tr("Take scene preview screenshot");
 }
        void SetupLayout()
        {
            m_Root = rootVisualElement;
            m_Root.AddStyleSheetPath(k_UIElementsEditorWindowCreatorStyleSheetPath);

            var           visualTree = EditorGUIUtility.Load(k_UIElementsEditorWindowCreatorUxmlPath) as VisualTreeAsset;
            VisualElement uxmlLayout = visualTree.Instantiate();

            m_Root.Add(uxmlLayout);

            m_ErrorMessageBox = m_Root.Q("errorMessageBox");

            var cSharpTextField = m_Root.Q <TextField>(k_CSharpTextFieldName);

            cSharpTextField.RegisterCallback <ChangeEvent <string> >(OnCSharpValueChanged);

            var cSharpTextInput = cSharpTextField.Q(TextField.textInputUssName);

            cSharpTextInput.RegisterCallback <KeyDownEvent>(OnReturnKey, TrickleDown.TrickleDown);
            cSharpTextInput.RegisterCallback <FocusEvent>(e => HideErrorMessage(), TrickleDown.TrickleDown);

            m_Root.schedule.Execute(() => cSharpTextField.Focus());

            var uxmlTextField = m_Root.Q <TextField>(k_UXMLTextFieldName);

            uxmlTextField.RegisterCallback <ChangeEvent <string> >(e =>
            {
                m_ErrorMessageBox.style.visibility = Visibility.Hidden;
                m_UxmlName = e.newValue;
            });

            var uxmlTextInput = uxmlTextField.Q(TextField.textInputUssName);

            uxmlTextInput.RegisterCallback <KeyDownEvent>(OnReturnKey, TrickleDown.TrickleDown);
            uxmlTextInput.RegisterCallback <FocusEvent>(e => HideErrorMessage(), TrickleDown.TrickleDown);

            m_Root.Q <Toggle>(k_UXMLToggleName).RegisterValueChangedCallback((evt) =>
            {
                m_IsUxmlEnable = evt.newValue;
                if (!m_IsUxmlEnable)
                {
                    uxmlTextField.value = "";
                    m_UxmlName          = "";
                }

                uxmlTextInput.SetEnabled(m_IsUxmlEnable);

                UpdateActionChoices();
            });

            var ussTextField = m_Root.Q <TextField>(k_USSTextFieldName);

            ussTextField.RegisterCallback <ChangeEvent <string> >(e =>
            {
                m_ErrorMessageBox.style.visibility = Visibility.Hidden;
                m_UssName = e.newValue;
            });

            var ussTextInput = ussTextField.Q(TextField.textInputUssName);

            ussTextInput.RegisterCallback <KeyDownEvent>(OnReturnKey, TrickleDown.TrickleDown);
            ussTextInput.RegisterCallback <FocusEvent>(e => HideErrorMessage(), TrickleDown.TrickleDown);

            m_Root.Q <Toggle>(k_USSToggleName).RegisterValueChangedCallback((evt) =>
            {
                m_IsUssEnable = evt.newValue;
                if (!m_IsUssEnable)
                {
                    ussTextField.value = "";
                    m_UssName          = "";
                }

                ussTextInput.SetEnabled(m_IsUssEnable);
            });

            var actionsDropdown = m_Root.Q <DropdownField>(k_ActionsDropdownName);

            actionsDropdown.RegisterValueChangedCallback((evt) =>
            {
                m_ActionSelected = evt.newValue;
            });
            actionsDropdown.value = string.IsNullOrEmpty(m_ActionSelected) ? k_JustCreateFilesOption : m_ActionSelected;

            UpdateActionChoices();

            var pathIcon = m_Root.Q <VisualElement>(k_PathIconName);

            pathIcon.style.backgroundImage = EditorGUIUtility.LoadIcon("FolderOpened Icon");

            var chooseFolderButton = m_Root.Q <Button>(k_ChooseFolderButtonName);

            chooseFolderButton.clicked += OnChooseFolderClicked;

            m_Root.Q <Button>("confirmButton").clickable.clicked += CreateNewTemplatesFiles;
            m_ErrorMessageBox.Q <Image>("warningIcon").image      = EditorGUIUtility.GetHelpIcon(MessageType.Warning);
            HideErrorMessage();
        }
Exemplo n.º 29
0
        void GenerateInternalEditor()
        {
            if (m_InternalEditor == null)
            {
                Object[] objs = new Object[targets.Length];
                for (var index = 0; index < targets.Length; index++)
                {
                    var            p         = (Preset)targets[index];
                    ReferenceCount reference = null;
                    if (!s_References.TryGetValue(p.GetInstanceID(), out reference))
                    {
                        reference = new ReferenceCount()
                        {
                            count     = 0,
                            reference = p.GetReferenceObject()
                        };
                        if (reference.reference == null)
                        {
                            // fast exit on NULL targets as we do not support their inspector in Preset.
                            m_NotSupportedEditorName = p.GetTargetTypeName();
                            m_UnsupportedIcon        = EditorGUIUtility.LoadIcon(m_NotSupportedEditorName.Replace('.', '/') + " Icon");
                            if (m_UnsupportedIcon == null)
                            {
                                m_UnsupportedIcon = AssetPreview.GetMiniTypeThumbnailFromType((serializedObject.FindProperty("m_TargetType.m_ManagedTypePPtr").objectReferenceValue as MonoScript)?.GetClass());
                                if (m_UnsupportedIcon == null)
                                {
                                    m_UnsupportedIcon = AssetPreview.GetMiniTypeThumbnailFromClassID(serializedObject.FindProperty("m_TargetType.m_NativeTypeID").intValue);
                                    if (m_UnsupportedIcon == null)
                                    {
                                        m_UnsupportedIcon = AssetPreview.GetMiniTypeThumbnail(typeof(Object));
                                    }
                                }
                            }
                            return;
                        }

                        reference.reference.name = p.name;
                        s_References.Add(p.GetInstanceID(), reference);
                        m_PresetsInstanceIds.Add(p.GetInstanceID());
                    }
                    reference.count++;
                    objs[index] = reference.reference;
                }
                m_InternalEditor = CreateEditor(objs);
            }
            else
            {
                //Coming back from an assembly reload... our references are probably broken and we need to fix them.
                for (var index = 0; index < targets.Length; index++)
                {
                    var            instanceID = targets[index].GetInstanceID();
                    ReferenceCount reference  = null;
                    if (!s_References.TryGetValue(instanceID, out reference))
                    {
                        reference = new ReferenceCount()
                        {
                            count     = 0,
                            reference = m_InternalEditor.targets[index]
                        };
                        s_References.Add(instanceID, reference);
                    }
                    reference.count++;
                }
            }

            m_InternalEditor.firstInspectedEditor = true;
        }