/// <summary>
        /// Recreates all the GUI elements used by this inspector.
        /// </summary>
        private void BuildGUI()
        {
            Layout.Clear();

            Bone bone = InspectedObject as Bone;

            if (bone == null)
            {
                return;
            }

            string[] boneNames = GetBoneNames(bone);
            if (boneNames == null)
            {
                boneNames = new string[0];
            }

            boneField = new GUIListBoxField(boneNames, false, new LocEdString("Bone"));

            Layout.AddElement(boneField);

            boneField.OnSelectionChanged += x =>
            {
                selectedBoneName = boneNames[x];
                bone.Name        = selectedBoneName;

                MarkAsModified();
                ConfirmModify();
            };
        }
Beispiel #2
0
        private void OnInitialize()
        {
            GUILayoutY mainLayout = GUI.AddLayoutY();

            string[] aspectRatioTitles = new string[aspectRatios.Length + 1];
            aspectRatioTitles[0] = "Free";

            for (int i = 0; i < aspectRatios.Length; i++)
            {
                aspectRatioTitles[i + 1] = aspectRatios[i].width + ":" + aspectRatios[i].height;
            }

            GUIListBoxField aspectField = new GUIListBoxField(aspectRatioTitles, new LocEdString("Aspect ratio"));

            aspectField.OnSelectionChanged += OnAspectRatioChanged;

            GUILayoutY buttonLayoutVert = mainLayout.AddLayoutY();
            GUILayoutX buttonLayout     = buttonLayoutVert.AddLayoutX();

            buttonLayout.AddElement(aspectField);
            buttonLayout.AddFlexibleSpace();
            buttonLayoutVert.AddFlexibleSpace();

            renderTextureGUI = new GUIRenderTexture(null);
            renderTextureBg  = new GUITexture(Builtin.WhiteTexture);
            renderTextureBg.SetTint(BG_COLOR);

            noCameraLabel = new GUILabel(new LocEdString("(No main camera in scene)"));

            GUIPanel rtPanel = mainLayout.AddPanel();

            rtPanel.AddElement(renderTextureGUI);

            GUIPanel bgPanel = rtPanel.AddPanel(1);

            bgPanel.AddElement(renderTextureBg);

            GUILayoutY alignLayoutY = rtPanel.AddLayoutY();

            alignLayoutY.AddFlexibleSpace();
            GUILayoutX alignLayoutX = alignLayoutY.AddLayoutX();

            alignLayoutX.AddFlexibleSpace();
            alignLayoutX.AddElement(noCameraLabel);
            alignLayoutX.AddFlexibleSpace();
            alignLayoutY.AddFlexibleSpace();

            UpdateRenderTexture(Width, Height);

            bool hasMainCamera = Scene.Camera != null;

            renderTextureGUI.Active = hasMainCamera;
            noCameraLabel.Active    = !hasMainCamera;
        }
        /// <summary>
        /// Recreates all the GUI elements used by this inspector.
        /// </summary>
        private void BuildGUI()
        {
            Layout.Clear();

            Renderable renderable = InspectedObject as Renderable;

            if (renderable == null)
            {
                return;
            }

            meshField   = new GUIResourceField(typeof(Mesh), new LocEdString("Mesh"));
            layersField = new GUIListBoxField(Layers.Names, true, new LocEdString("Layers"));

            Layout.AddElement(meshField);
            Layout.AddElement(layersField);

            layersValue    = 0;
            materials      = renderable.Materials;
            materialsField = GUIArrayField <Material, MaterialArrayRow> .Create(new LocEdString("Materials"), materials, Layout);

            materialsField.OnChanged += x => { materials = x; };
            materialsField.IsExpanded = Persistent.GetBool("materialsField_Expanded");
            materialsField.OnExpand  += x => Persistent.SetBool("materialsField_Expanded", x);

            meshField.OnChanged += x =>
            {
                Mesh mesh = Resources.Load <Mesh>(x);
                renderable.Mesh = mesh;

                MarkAsModified();
                ConfirmModify();
            };

            layersField.OnSelectionChanged += x =>
            {
                ulong  layers = 0;
                bool[] states = layersField.States;
                for (int i = 0; i < states.Length; i++)
                {
                    layers |= states[i] ? Layers.Values[i] : 0;
                }

                layersValue       = layers;
                renderable.Layers = layers;

                MarkAsModified();
                ConfirmModify();
            };

            materialsLayout = Layout.AddLayoutY();
            BuildMaterialsGUI();
        }
Beispiel #4
0
        /// <inheritdoc/>
        protected internal override void Initialize(int layoutIndex)
        {
            if (property != null)
            {
                guiLayerMaskField = new GUIListBoxField(Layers.Names, true, new GUIContent(title));

                guiLayerMaskField.OnSelectionChanged += x =>
                {
                    ulong  layers = 0;
                    bool[] states = guiLayerMaskField.States;
                    for (int i = 0; i < states.Length; i++)
                    {
                        layers |= states[i] ? Layers.Values[i] : 0;
                    }

                    layersValue = layers;

                    property.SetValue(layers);
                    state |= InspectableState.ModifyInProgress | InspectableState.Modified;
                };

                layout.AddElement(layoutIndex, guiLayerMaskField);
            }
        }
        private void OnInitialize()
        {
            GUIToggle projectFoldout = new GUIToggle(new LocEdString("Project"), EditorStyles.Foldout);
            GUIToggle editorFoldout  = new GUIToggle(new LocEdString("Editor"), EditorStyles.Foldout);

            defaultHandleSizeField            = new GUIFloatField(new LocEdString("Handle size"), 200);
            defaultHandleSizeField.OnChanged += (x) => { EditorSettings.DefaultHandleSize = x; };

            autoLoadLastProjectField            = new GUIToggleField(new LocEdString("Automatically load last project"), 200);
            autoLoadLastProjectField.OnChanged += (x) => { EditorSettings.AutoLoadLastProject = x; };

            CodeEditorType[] availableEditors = CodeEditor.AvailableEditors;
            Array.Resize(ref availableEditors, availableEditors.Length + 1);
            availableEditors[availableEditors.Length - 1] = CodeEditorType.None;

            string[] availableEditorNames = new string[availableEditors.Length];
            for (int i = 0; i < availableEditors.Length; i++)
            {
                availableEditorNames[i] = Enum.GetName(typeof(CodeEditorType), availableEditors[i]);
            }

            codeEditorField = new GUIListBoxField(availableEditorNames, new LocEdString("Code editor"), 200);
            codeEditorField.OnSelectionChanged += x =>
            {
                EditorSettings.SetInt(ActiveCodeEditorKey, (int)availableEditors[x]);
                CodeEditor.ActiveEditor = availableEditors[x];
            };

            fpsLimitField              = new GUIIntField(new LocEdString("FPS limit"), 200);
            fpsLimitField.OnConfirmed += () => EditorSettings.FPSLimit = fpsLimitField.Value;
            fpsLimitField.OnFocusLost += () => EditorSettings.FPSLimit = fpsLimitField.Value;

            mouseSensitivityField            = new GUISliderField(0.2f, 2.0f, new LocEdString("Mouse sensitivity"));
            mouseSensitivityField.OnChanged += (x) => EditorSettings.MouseSensitivity = x;

            GUILayout mainLayout = GUI.AddLayoutY();

            mainLayout.AddElement(projectFoldout);
            GUILayout projectLayoutOuterY = mainLayout.AddLayoutY();

            projectLayoutOuterY.AddSpace(5);
            GUILayout projectLayoutOuterX = projectLayoutOuterY.AddLayoutX();

            projectLayoutOuterX.AddSpace(5);
            GUILayout projectLayout = projectLayoutOuterX.AddLayoutY();

            projectLayoutOuterX.AddSpace(5);
            projectLayoutOuterY.AddSpace(5);

            mainLayout.AddElement(editorFoldout);
            GUILayout editorLayoutOuterY = mainLayout.AddLayoutY();

            editorLayoutOuterY.AddSpace(5);
            GUILayout editorLayoutOuterX = editorLayoutOuterY.AddLayoutX();

            editorLayoutOuterX.AddSpace(5);
            GUILayout editorLayout = editorLayoutOuterX.AddLayoutY();

            editorLayoutOuterX.AddSpace(5);
            editorLayoutOuterY.AddSpace(5);

            mainLayout.AddFlexibleSpace();

            editorLayout.AddElement(defaultHandleSizeField);
            editorLayout.AddElement(autoLoadLastProjectField);
            editorLayout.AddElement(codeEditorField);
            editorLayout.AddElement(fpsLimitField);
            editorLayout.AddElement(mouseSensitivityField);

            projectFoldout.Value = true;
            editorFoldout.Value  = true;

            projectFoldout.OnToggled += (x) => projectLayout.Active = x;
            editorFoldout.OnToggled  += (x) => editorLayout.Active = x;
        }
Beispiel #6
0
        private void OnInitialize()
        {
            GUILayoutY mainLayout = GUI.AddLayoutY();

            string[] aspectRatioTitles = new string[aspectRatios.Length + 1];
            aspectRatioTitles[0] = "Free";

            for (int i = 0; i < aspectRatios.Length; i++)
                aspectRatioTitles[i + 1] = aspectRatios[i].width + ":" + aspectRatios[i].height;

            GUIListBoxField aspectField = new GUIListBoxField(aspectRatioTitles, new LocEdString("Aspect ratio"));
            aspectField.OnSelectionChanged += OnAspectRatioChanged;

            GUILayoutY buttonLayoutVert = mainLayout.AddLayoutY();
            GUILayoutX buttonLayout = buttonLayoutVert.AddLayoutX();
            buttonLayout.AddElement(aspectField);
            buttonLayout.AddFlexibleSpace();
            buttonLayoutVert.AddFlexibleSpace();

            renderTextureGUI = new GUIRenderTexture(null);
            renderTextureBg = new GUITexture(Builtin.WhiteTexture);
            renderTextureBg.SetTint(BG_COLOR);

            noCameraLabel = new GUILabel(new LocEdString("(No main camera in scene)"));

            GUIPanel rtPanel = mainLayout.AddPanel();
            rtPanel.AddElement(renderTextureGUI);

            GUIPanel bgPanel = rtPanel.AddPanel(1);
            bgPanel.AddElement(renderTextureBg);

            GUILayoutY alignLayoutY = rtPanel.AddLayoutY();
            alignLayoutY.AddFlexibleSpace();
            GUILayoutX alignLayoutX = alignLayoutY.AddLayoutX();
            alignLayoutX.AddFlexibleSpace();
            alignLayoutX.AddElement(noCameraLabel);
            alignLayoutX.AddFlexibleSpace();
            alignLayoutY.AddFlexibleSpace();

            UpdateRenderTexture(Width, Height);

            bool hasMainCamera = Scene.Camera != null;

            renderTextureGUI.Active = hasMainCamera;
            noCameraLabel.Active = !hasMainCamera;
        }
Beispiel #7
0
 private static extern void Internal_CreateInstance(GUIListBoxField instance, LocString[] entries, bool multiselect,
                                                    GUIContent title, int titleWidth, string style, GUIOption[] options, bool withTitle);
Beispiel #8
0
 private static extern void Internal_CreateInstance(GUIListBoxField instance, LocString[] entries, bool multiselect,
     GUIContent title, int titleWidth, string style, GUIOption[] options, bool withTitle);
        /// <summary>
        /// Recreates all the GUI elements used by this inspector.
        /// </summary>
        private void BuildGUI()
        {
            Layout.Clear();

            Renderable renderable = InspectedObject as Renderable;
            if (renderable == null)
                return;

            meshField = new GUIResourceField(typeof(Mesh), new LocEdString("Mesh"));
            layersField = new GUIListBoxField(Layers.Names, false, new LocEdString("Layer"));

            Layout.AddElement(meshField);
            Layout.AddElement(layersField);

            layersValue = 0;
            materials = renderable.Materials;
            materialsField = GUIArrayField<Material, MaterialArrayRow>.Create(new LocEdString("Materials"), materials, Layout);
            materialsField.OnChanged += x => { materials = x; };
            materialsField.IsExpanded = Persistent.GetBool("materialsField_Expanded");
            materialsField.OnExpand += x => Persistent.SetBool("materialsField_Expanded", x);

            meshField.OnChanged += x =>
            {
                Mesh mesh = Resources.Load<Mesh>(x);
                renderable.Mesh = mesh;

                MarkAsModified();
                ConfirmModify();
            };

            layersField.OnSelectionChanged += x =>
            {
                ulong layers = 0;
                bool[] states = layersField.States;
                for (int i = 0; i < states.Length; i++)
                    layers |= states[i] ? Layers.Values[i] : 0;

                layersValue = layers;
                renderable.Layers = layers;

                MarkAsModified();
                ConfirmModify();
            };

            materialsLayout = Layout.AddLayoutY();
            BuildMaterialsGUI();
        }
Beispiel #10
0
        /// <summary>
        /// Initializes the drop down window by creating the necessary GUI. Must be called after construction and before
        /// use.
        /// </summary>
        /// <param name="animEvent">Event whose properties to edit.</param>
        /// <param name="componentNames">List of component names that the user can select from.</param>
        /// <param name="updateCallback">Callback triggered when event values change.</param>
        internal void Initialize(AnimationEvent animEvent, string[] componentNames, Action updateCallback)
        {
            int    selectedIndex = -1;
            string methodName    = "";

            if (!string.IsNullOrEmpty(animEvent.Name))
            {
                string[] nameEntries = animEvent.Name.Split('/');
                if (nameEntries.Length > 1)
                {
                    string typeName = nameEntries[0];
                    for (int i = 0; i < componentNames.Length; i++)
                    {
                        if (componentNames[i] == typeName)
                        {
                            selectedIndex = i;
                            break;
                        }
                    }

                    methodName = nameEntries[nameEntries.Length - 1];
                }
            }

            GUIFloatField timeField = new GUIFloatField(new LocEdString("Time"), 40, "");

            timeField.Value      = animEvent.Time;
            timeField.OnChanged += x => { animEvent.Time = x; updateCallback(); }; // TODO UNDOREDO

            GUIListBoxField componentField = new GUIListBoxField(componentNames, new LocEdString("Component"), 40);

            if (selectedIndex != -1)
            {
                componentField.Index = selectedIndex;
            }

            componentField.OnSelectionChanged += x =>
            {
                string compName = "";
                if (x != -1)
                {
                    compName = componentNames[x] + "/";
                }

                animEvent.Name = compName + x;
                updateCallback();
            };// TODO UNDOREDO

            GUITextField methodField = new GUITextField(new LocEdString("Method"), 40, false, "", GUIOption.FixedWidth(190));

            methodField.Value      = methodName;
            methodField.OnChanged += x =>
            {
                string compName = "";
                if (componentField.Index != -1)
                {
                    compName = componentNames[componentField.Index] + "/";
                }

                animEvent.Name = compName + x;
                updateCallback();
            }; // TODO UNDOREDO

            GUILayoutY vertLayout = GUI.AddLayoutY();

            vertLayout.AddFlexibleSpace();
            GUILayoutX horzLayout = vertLayout.AddLayoutX();

            horzLayout.AddFlexibleSpace();
            GUILayout contentLayout = horzLayout.AddLayoutY();
            GUILayout timeLayout    = contentLayout.AddLayoutX();

            timeLayout.AddSpace(5);
            timeLayout.AddElement(timeField);
            timeLayout.AddFlexibleSpace();
            GUILayout componentLayout = contentLayout.AddLayoutX();

            componentLayout.AddSpace(5);
            componentLayout.AddElement(componentField);
            componentLayout.AddFlexibleSpace();
            GUILayout methodLayout = contentLayout.AddLayoutX();

            methodLayout.AddSpace(5);
            methodLayout.AddElement(methodField);
            methodLayout.AddFlexibleSpace();
            horzLayout.AddFlexibleSpace();
            vertLayout.AddFlexibleSpace();
        }
        /// <summary>
        /// Initializes the drop down window by creating the necessary GUI. Must be called after construction and before
        /// use.
        /// </summary>
        /// <param name="animEvent">Event whose properties to edit.</param>
        /// <param name="componentNames">List of component names that the user can select from.</param>
        /// <param name="updateCallback">Callback triggered when event values change.</param>
        /// <param name="closeCallback">Callback triggered just before the window closes.</param>
        internal void Initialize(AnimationEvent animEvent, string[] componentNames, Action updateCallback, 
            Action<bool> closeCallback)
        {
            int selectedIndex = -1;
            string methodName = "";
            if (!string.IsNullOrEmpty(animEvent.Name))
            {
                string[] nameEntries = animEvent.Name.Split('/');
                if (nameEntries.Length > 1)
                {
                    string typeName = nameEntries[0];
                    for (int i = 0; i < componentNames.Length; i++)
                    {
                        if (componentNames[i] == typeName)
                        {
                            selectedIndex = i;
                            break;
                        }
                    }

                    methodName = nameEntries[nameEntries.Length - 1];
                }
            }

            GUIFloatField timeField = new GUIFloatField(new LocEdString("Time"), 40, "");
            timeField.Value = animEvent.Time;
            timeField.OnChanged += x => { animEvent.Time = x; changesMade = true; updateCallback(); };

            GUIListBoxField componentField = new GUIListBoxField(componentNames, new LocEdString("Component"), 40);
            if (selectedIndex != -1)
                componentField.Index = selectedIndex;

            componentField.OnSelectionChanged += x =>
            {
                string compName = "";
                if (x != -1)
                    compName = componentNames[x] + "/";

                animEvent.Name = compName + x;

                changesMade = true;
                updateCallback();
            };

            GUITextField methodField = new GUITextField(new LocEdString("Method"), 40, false, "", GUIOption.FixedWidth(190));
            methodField.Value = methodName;
            methodField.OnChanged += x =>
            {
                string compName = "";
                if(componentField.Index != -1)
                    compName = componentNames[componentField.Index] + "/";

                animEvent.Name = compName + x;

                changesMade = true;
                updateCallback();
            };

            GUILayoutY vertLayout = GUI.AddLayoutY();

            vertLayout.AddFlexibleSpace();
            GUILayoutX horzLayout = vertLayout.AddLayoutX();
            horzLayout.AddFlexibleSpace();
            GUILayout contentLayout = horzLayout.AddLayoutY();
            GUILayout timeLayout = contentLayout.AddLayoutX();
            timeLayout.AddSpace(5);
            timeLayout.AddElement(timeField);
            timeLayout.AddFlexibleSpace();
            GUILayout componentLayout = contentLayout.AddLayoutX();
            componentLayout.AddSpace(5);
            componentLayout.AddElement(componentField);
            componentLayout.AddFlexibleSpace();
            GUILayout methodLayout = contentLayout.AddLayoutX();
            methodLayout.AddSpace(5);
            methodLayout.AddElement(methodField);
            methodLayout.AddFlexibleSpace();
            horzLayout.AddFlexibleSpace();
            vertLayout.AddFlexibleSpace();

            this.closeCallback = closeCallback;
        }