private void BuildGUI() { progressBar = new GUIProgressBar(); messageLabel = new GUILabel("", EditorStyles.MultiLineLabelCentered, GUIOption.FixedHeight(60)); cancelImport = new GUIButton(new LocEdString("Cancel import")); cancelImport.OnClick += () => { ProjectLibrary.CancelImport(); cancelImport.Disabled = true; }; GUILayoutY layoutY = GUI.AddLayoutY(); layoutY.AddFlexibleSpace(); GUILayoutX messageLayout = layoutY.AddLayoutX(); messageLayout.AddSpace(15); messageLayout.AddElement(messageLabel); messageLayout.AddSpace(15); layoutY.AddSpace(10); GUILayoutX barLayout = layoutY.AddLayoutX(); barLayout.AddSpace(30); barLayout.AddElement(progressBar); barLayout.AddSpace(30); layoutY.AddSpace(20); GUILayoutX buttonLayout = layoutY.AddLayoutX(); buttonLayout.AddFlexibleSpace(); buttonLayout.AddElement(cancelImport); buttonLayout.AddFlexibleSpace(); layoutY.AddFlexibleSpace(); messageLabel.SetContent(new LocEdString("Resource import is still in progress. You can wait until it " + "finishes or cancel import. \n\nNote that even when cancelling you will need to wait for active import threads to finish.")); }
private void OnInitialize() { guiColor = new GUIColorField("", GUIOption.FixedWidth(100)); guiSlider2DTex = new GUITexture(null, GUIOption.FixedHeight(ColorBoxHeight), GUIOption.FixedWidth(ColorBoxWidth)); guiSliderVertTex = new GUITexture(null, GUIOption.FixedHeight(SliderSideHeight), GUIOption.FixedWidth(SliderSideWidth)); guiSliderRHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight)); guiSliderGHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight)); guiSliderBHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight)); guiSliderAHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight)); guiColorBoxBtn = new GUIButton(colorBoxMode.ToString()); guiColorModeBtn = new GUIButton(sliderMode.ToString()); guiSliderVert = new GUISliderV(EditorStylesInternal.ColorSliderVert); guiSliderRHorz = new GUISliderH(EditorStylesInternal.ColorSliderHorz); guiSliderGHorz = new GUISliderH(EditorStylesInternal.ColorSliderHorz); guiSliderBHorz = new GUISliderH(EditorStylesInternal.ColorSliderHorz); guiSliderAHorz = new GUISliderH(EditorStylesInternal.ColorSliderHorz); guiSlider2DHandle = new GUITexture(null, EditorStylesInternal.ColorSlider2DHandle); guiLabelR = new GUILabel(new LocEdString("R")); guiLabelG = new GUILabel(new LocEdString("G")); guiLabelB = new GUILabel(new LocEdString("B")); guiLabelA = new GUILabel(new LocEdString("A")); guiInputR = new GUIIntField(); guiInputG = new GUIIntField(); guiInputB = new GUIIntField(); guiInputA = new GUIIntField(); guiOK = new GUIButton(new LocEdString("OK")); guiCancel = new GUIButton(new LocEdString("Cancel")); guiColorBoxBtn.OnClick += OnColorBoxModeChanged; guiColorModeBtn.OnClick += OnSliderModeChanged; guiSliderVert.OnChanged += OnSliderVertChanged; guiSliderRHorz.OnChanged += OnSliderRHorzChanged; guiSliderGHorz.OnChanged += OnSliderGHorzChanged; guiSliderBHorz.OnChanged += OnSliderBHorzChanged; guiSliderAHorz.OnChanged += OnSliderAHorzChanged; guiInputR.OnChanged += OnInputRChanged; guiInputG.OnChanged += OnInputGChanged; guiInputB.OnChanged += OnInputBChanged; guiInputA.OnChanged += OnInputAChanged; guiOK.OnClick += OnOK; guiCancel.OnClick += OnCancel; GUIPanel mainPanel = GUI.AddPanel(0); GUILayout v0 = mainPanel.AddLayoutY(); v0.AddSpace(5); GUILayout h0 = v0.AddLayoutX(); h0.AddSpace(10); h0.AddElement(guiColor); h0.AddFlexibleSpace(); h0.AddElement(guiColorBoxBtn); h0.AddElement(guiColorModeBtn); h0.AddSpace(10); v0.AddSpace(10); GUILayout h1 = v0.AddLayoutX(); h1.AddSpace(10); h1.AddElement(guiSlider2DTex); h1.AddFlexibleSpace(); h1.AddElement(guiSliderVertTex); h1.AddSpace(10); v0.AddSpace(10); GUILayout h2 = v0.AddLayoutX(); h2.AddSpace(10); h2.AddElement(guiLabelR); h2.AddFlexibleSpace(); h2.AddElement(guiSliderRHorzTex); h2.AddFlexibleSpace(); h2.AddElement(guiInputR); h2.AddSpace(10); v0.AddSpace(5); GUILayout h3 = v0.AddLayoutX(); h3.AddSpace(10); h3.AddElement(guiLabelG); h3.AddFlexibleSpace(); h3.AddElement(guiSliderGHorzTex); h3.AddFlexibleSpace(); h3.AddElement(guiInputG); h3.AddSpace(10); v0.AddSpace(5); GUILayout h4 = v0.AddLayoutX(); h4.AddSpace(10); h4.AddElement(guiLabelB); h4.AddFlexibleSpace(); h4.AddElement(guiSliderBHorzTex); h4.AddFlexibleSpace(); h4.AddElement(guiInputB); h4.AddSpace(10); v0.AddSpace(5); GUILayout h5 = v0.AddLayoutX(); h5.AddSpace(10); h5.AddElement(guiLabelA); h5.AddFlexibleSpace(); h5.AddElement(guiSliderAHorzTex); h5.AddFlexibleSpace(); h5.AddElement(guiInputA); h5.AddSpace(10); v0.AddSpace(10); GUILayout h6 = v0.AddLayoutX(); h6.AddFlexibleSpace(); h6.AddElement(guiOK); h6.AddSpace(10); h6.AddElement(guiCancel); h6.AddFlexibleSpace(); v0.AddSpace(5); GUIPanel overlay = GUI.AddPanel(-1); overlay.SetWidth(Width); overlay.SetHeight(Height); overlay.AddElement(guiSliderVert); overlay.AddElement(guiSliderRHorz); overlay.AddElement(guiSliderGHorz); overlay.AddElement(guiSliderBHorz); overlay.AddElement(guiSliderAHorz); overlay.AddElement(guiSlider2DHandle); colorBox = new ColorSlider2D(guiSlider2DTex, guiSlider2DHandle, ColorBoxWidth, ColorBoxHeight); sideSlider = new ColorSlider1DVert(guiSliderVertTex, guiSliderVert, SliderSideWidth, SliderSideHeight); sliderR = new ColorSlider1DHorz(guiSliderRHorzTex, guiSliderRHorz, SliderIndividualWidth, SliderIndividualHeight); sliderG = new ColorSlider1DHorz(guiSliderGHorzTex, guiSliderGHorz, SliderIndividualWidth, SliderIndividualHeight); sliderB = new ColorSlider1DHorz(guiSliderBHorzTex, guiSliderBHorz, SliderIndividualWidth, SliderIndividualHeight); sliderA = new ColorSlider1DHorz(guiSliderAHorzTex, guiSliderAHorz, SliderIndividualWidth, SliderIndividualHeight); colorBox.OnValueChanged += OnColorBoxValueChanged; Color startA = new Color(0, 0, 0, 1); Color stepA = new Color(1, 1, 1, 0); sliderA.UpdateTexture(startA, stepA, false); guiInputA.SetRange(0, 255); guiInputA.Value = 255; guiSliderAHorz.Percent = 1.0f; guiColor.Value = SelectedColor; UpdateInputBoxValues(); Update2DSliderValues(); Update1DSliderValues(); UpdateSliderMode(); Update2DSliderTextures(); Update1DSliderTextures(); }
/// <inheritdoc/> public override void BuildGUI() { main = Layout.AddPanel(0, 1, 1, GUIOption.FixedHeight(ENTRY_HEIGHT)); overlay = main.AddPanel(-1, 0, 0, GUIOption.FixedHeight(ENTRY_HEIGHT)); underlay = main.AddPanel(1, 0, 0, GUIOption.FixedHeight(ENTRY_HEIGHT)); GUILayoutX mainLayout = main.AddLayoutX(); GUILayoutY overlayLayout = overlay.AddLayoutY(); GUILayoutY underlayLayout = underlay.AddLayoutY(); icon = new GUITexture(null, GUIOption.FixedWidth(32), GUIOption.FixedHeight(32)); messageLabel = new GUILabel(new LocEdString(""), EditorStyles.MultiLineLabel, GUIOption.FixedHeight(MESSAGE_HEIGHT)); functionLabel = new GUILabel(new LocEdString(""), GUIOption.FixedHeight(CALLER_LABEL_HEIGHT)); mainLayout.AddSpace(PADDING); GUILayoutY iconLayout = mainLayout.AddLayoutY(); iconLayout.AddFlexibleSpace(); iconLayout.AddElement(icon); iconLayout.AddFlexibleSpace(); mainLayout.AddSpace(PADDING); GUILayoutY messageLayout = mainLayout.AddLayoutY(); messageLayout.AddSpace(PADDING); messageLayout.AddElement(messageLabel); messageLayout.AddElement(functionLabel); messageLayout.AddSpace(PADDING); mainLayout.AddFlexibleSpace(); mainLayout.AddSpace(PADDING); background = new GUITexture(Builtin.WhiteTexture, GUIOption.FixedHeight(ENTRY_HEIGHT)); underlayLayout.AddElement(background); GUIButton button = new GUIButton(new LocEdString(""), EditorStyles.Blank, GUIOption.FixedHeight(ENTRY_HEIGHT)); overlayLayout.AddElement(button); button.OnClick += OnClicked; button.OnDoubleClick += OnDoubleClicked; }
/// <summary> /// Sets a scene object whose GUI is to be displayed in the inspector. Clears any previous contents of the window. /// </summary> /// <param name="so">Scene object to inspect.</param> private void SetObjectToInspect(SceneObject so) { if (so == null) { return; } currentType = InspectorType.SceneObject; activeSO = so; inspectorScrollArea = new GUIScrollArea(ScrollBarType.ShowIfDoesntFit, ScrollBarType.NeverShow); scrollAreaHighlight = new GUITexture(Builtin.WhiteTexture); scrollAreaHighlight.SetTint(HIGHLIGHT_COLOR); scrollAreaHighlight.Active = false; GUI.AddElement(inspectorScrollArea); GUIPanel inspectorPanel = inspectorScrollArea.Layout.AddPanel(); inspectorLayout = inspectorPanel.AddLayoutY(); highlightPanel = inspectorPanel.AddPanel(-1); highlightPanel.AddElement(scrollAreaHighlight); // SceneObject fields CreateSceneObjectFields(); RefreshSceneObjectFields(true); // Components Component[] allComponents = so.GetComponents(); for (int i = 0; i < allComponents.Length; i++) { inspectorLayout.AddSpace(COMPONENT_SPACING); InspectorComponent data = new InspectorComponent(); data.instanceId = allComponents[i].InstanceId; data.folded = false; data.foldout = new GUIToggle(allComponents[i].GetType().Name, EditorStyles.Foldout); data.foldout.AcceptsKeyFocus = false; SpriteTexture xBtnIcon = EditorBuiltin.GetEditorIcon(EditorIcon.X); data.removeBtn = new GUIButton(new GUIContent(xBtnIcon), GUIOption.FixedWidth(30)); data.title = inspectorLayout.AddLayoutX(); data.title.AddElement(data.foldout); data.title.AddElement(data.removeBtn); data.panel = inspectorLayout.AddPanel(); var persistentProperties = persistentData.GetProperties(allComponents[i].InstanceId); data.inspector = InspectorUtility.GetInspector(allComponents[i].GetType()); data.inspector.Initialize(data.panel, allComponents[i], persistentProperties); bool isExpanded = data.inspector.Persistent.GetBool(data.instanceId + "_Expanded", true); data.foldout.Value = isExpanded; if (!isExpanded) { data.inspector.SetVisible(false); } Type curComponentType = allComponents[i].GetType(); data.foldout.OnToggled += (bool expanded) => OnComponentFoldoutToggled(data, expanded); data.removeBtn.OnClick += () => OnComponentRemoveClicked(curComponentType); inspectorComponents.Add(data); } inspectorLayout.AddFlexibleSpace(); UpdateDropAreas(); }
private void OnInitialize() { EditorApplication.OnProjectSave += SaveSettings; SceneWindow sceneWindow = SceneWindow.GetWindow <SceneWindow>(); if (sceneWindow != null) { viewSettings = sceneWindow.Camera.ViewSettings; moveSettings = sceneWindow.Camera.MoveSettings; renderSettings = sceneWindow.Camera.RenderSettings; gizmoSettings = sceneWindow.GizmoDrawSettings; } else { viewSettings = ProjectSettings.GetObject <SceneCameraViewSettings>(SceneCamera.ViewSettingsKey); moveSettings = ProjectSettings.GetObject <SceneCameraMoveSettings>(SceneCamera.MoveSettingsKey); renderSettings = ProjectSettings.GetObject <RenderSettings>(SceneCamera.RenderSettingsKey); if (ProjectSettings.HasKey(SceneWindow.GizmoDrawSettingsKey)) { gizmoSettings = ProjectSettings.GetObject <GizmoDrawSettings>(SceneWindow.GizmoDrawSettingsKey); } else { gizmoSettings = GizmoDrawSettings.Default(); } } expandStates = ProjectSettings.GetObject <SerializableProperties>(ExpandStatesKey); InspectableContext inspectableContext = new InspectableContext(expandStates); GUILayout mainLayout = GUI.AddLayoutY(); GUIScrollArea scrollArea = new GUIScrollArea(ScrollBarType.ShowIfDoesntFit, ScrollBarType.NeverShow); mainLayout.AddElement(scrollArea); GUILayoutX horzPadLayout = scrollArea.Layout.AddLayoutX(GUIOption.FlexibleWidth(100, 400)); horzPadLayout.AddSpace(5); GUILayout vertLayout = horzPadLayout.AddLayoutY(); horzPadLayout.AddSpace(5); vertLayout.AddSpace(5); vertLayout.AddElement(new GUILabel(new LocEdString("View Settings"), EditorStyles.LabelBold)); GUILayoutY viewSettingsLayout = vertLayout.AddLayoutY(); vertLayout.AddSpace(10); vertLayout.AddElement(new GUILabel(new LocEdString("Gizmo Settings"), EditorStyles.LabelBold)); GUILayoutY gizmoSettingsLayout = vertLayout.AddLayoutY(); vertLayout.AddSpace(10); vertLayout.AddElement(new GUILabel(new LocEdString("Move Settings"), EditorStyles.LabelBold)); GUILayoutY moveSettingsLayout = vertLayout.AddLayoutY(); vertLayout.AddSpace(10); vertLayout.AddElement(new GUILabel(new LocEdString("Render Settings"), EditorStyles.LabelBold)); GUILayoutY renderSettingsLayout = vertLayout.AddLayoutY(); guiViewSettings = new InspectorFieldDrawer(inspectableContext, viewSettingsLayout); guiGizmoSettings = new InspectorFieldDrawer(inspectableContext, gizmoSettingsLayout); guiMovementSettings = new InspectorFieldDrawer(inspectableContext, moveSettingsLayout); guiRenderSettings = new InspectorFieldDrawer(inspectableContext, renderSettingsLayout); objGizmoSettings = gizmoSettings; guiViewSettings.AddDefault(viewSettings); guiGizmoSettings.AddDefault(objGizmoSettings); guiMovementSettings.AddDefault(moveSettings); guiRenderSettings.AddDefault(renderSettings); mainLayout.AddSpace(5); GUILayout buttonCenterLayout = mainLayout.AddLayoutX(); mainLayout.AddSpace(5); GUIButton resetToDefaultBtn = new GUIButton(new LocEdString("Reset to defaults")); resetToDefaultBtn.OnClick += () => ConfirmResetToDefault(ResetToDefault, null); buttonCenterLayout.AddFlexibleSpace(); buttonCenterLayout.AddElement(resetToDefaultBtn); buttonCenterLayout.AddFlexibleSpace(); }
/// <inheritdoc/> protected override GUILayoutX CreateGUI(GUILayoutY layout) { AnimationSplitInfo rowSplitInfo = GetValue <AnimationSplitInfo>(); if (rowSplitInfo == null) { rowSplitInfo = new AnimationSplitInfo(); SetValue(rowSplitInfo); } GUILayoutX titleLayout = layout.AddLayoutX(); GUILayoutX contentLayout = layout.AddLayoutX(); GUILabel title = new GUILabel(new LocEdString(SeqIndex + ". ")); nameField = new GUITextField(new LocEdString("Name"), 40, false, "", GUIOption.FixedWidth(160)); startFrameField = new GUIIntField(new LocEdString("Start"), 40, "", GUIOption.FixedWidth(80)); endFrameField = new GUIIntField(new LocEdString("End"), 40, "", GUIOption.FixedWidth(80)); isAdditiveField = new GUIToggleField(new LocEdString("Is additive"), 50, "", GUIOption.FixedWidth(80)); startFrameField.SetRange(0, int.MaxValue); endFrameField.SetRange(0, int.MaxValue); titleLayout.AddElement(title); titleLayout.AddElement(nameField); titleLayout.AddFlexibleSpace(); contentLayout.AddSpace(10); contentLayout.AddElement(startFrameField); contentLayout.AddSpace(5); contentLayout.AddElement(endFrameField); contentLayout.AddSpace(5); contentLayout.AddElement(isAdditiveField); nameField.OnChanged += x => { AnimationSplitInfo splitInfo = GetValue <AnimationSplitInfo>(); splitInfo.Name = x; MarkAsModified(); }; nameField.OnFocusLost += ConfirmModify; nameField.OnConfirmed += ConfirmModify; startFrameField.OnChanged += x => { AnimationSplitInfo splitInfo = GetValue <AnimationSplitInfo>(); splitInfo.StartFrame = x; MarkAsModified(); }; startFrameField.OnFocusLost += ConfirmModify; startFrameField.OnConfirmed += ConfirmModify; endFrameField.OnChanged += x => { AnimationSplitInfo splitInfo = GetValue <AnimationSplitInfo>(); splitInfo.EndFrame = x; MarkAsModified(); }; endFrameField.OnFocusLost += ConfirmModify; endFrameField.OnConfirmed += ConfirmModify; isAdditiveField.OnChanged += x => { AnimationSplitInfo splitInfo = GetValue <AnimationSplitInfo>(); splitInfo.IsAdditive = x; MarkAsModified(); ConfirmModify(); }; return(titleLayout); }
/// <summary> /// Rebuilds the GUI dictionary header if needed. /// </summary> protected void UpdateHeaderGUI() { Action BuildEmptyGUI = () => { guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0); guiInternalTitleLayout.AddElement(new GUILabel(title)); guiInternalTitleLayout.AddElement(new GUILabel("Empty", GUIOption.FixedWidth(100))); GUIContent createIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Create), new LocEdString("Create")); GUIButton createBtn = new GUIButton(createIcon, GUIOption.FixedWidth(30)); createBtn.OnClick += OnCreateButtonClicked; guiInternalTitleLayout.AddElement(createBtn); }; Action BuildFilledGUI = () => { guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0); guiFoldout = new GUIToggle(title, EditorStyles.Foldout); guiFoldout.Value = isExpanded; guiFoldout.AcceptsKeyFocus = false; guiFoldout.OnToggled += x => ToggleFoldout(x, false); GUIContent clearIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Clear), new LocEdString("Clear")); GUIButton guiClearBtn = new GUIButton(clearIcon, GUIOption.FixedWidth(30)); guiClearBtn.OnClick += OnClearButtonClicked; GUIContent addIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Add), new LocEdString("Add")); GUIButton guiAddBtn = new GUIButton(addIcon, GUIOption.FixedWidth(30)); guiAddBtn.OnClick += OnAddButtonClicked; guiInternalTitleLayout.AddElement(guiFoldout); guiInternalTitleLayout.AddElement(guiAddBtn); guiInternalTitleLayout.AddElement(guiClearBtn); guiChildLayout = guiLayout.AddLayoutX(); guiChildLayout.AddSpace(IndentAmount); GUIPanel guiContentPanel = guiChildLayout.AddPanel(); GUILayoutX guiIndentLayoutX = guiContentPanel.AddLayoutX(); guiIndentLayoutX.AddSpace(IndentAmount); GUILayoutY guiIndentLayoutY = guiIndentLayoutX.AddLayoutY(); guiIndentLayoutY.AddSpace(IndentAmount); guiContentLayout = guiIndentLayoutY.AddLayoutY(); guiIndentLayoutY.AddSpace(IndentAmount); guiIndentLayoutX.AddSpace(IndentAmount); guiChildLayout.AddSpace(IndentAmount); short backgroundDepth = (short)(Inspector.START_BACKGROUND_DEPTH - depth - 1); string bgPanelStyle = depth % 2 == 0 ? EditorStylesInternal.InspectorContentBgAlternate : EditorStylesInternal.InspectorContentBg; GUIPanel backgroundPanel = guiContentPanel.AddPanel(backgroundDepth); GUITexture inspectorContentBg = new GUITexture(null, bgPanelStyle); backgroundPanel.AddElement(inspectorContentBg); ToggleFoldout(isExpanded, false); }; if (state == State.None) { if (!IsNull()) { BuildFilledGUI(); state = State.Filled; } else { BuildEmptyGUI(); state = State.Empty; } } else if (state == State.Empty) { if (!IsNull()) { guiInternalTitleLayout.Destroy(); BuildFilledGUI(); state = State.Filled; } } else if (state == State.Filled) { if (IsNull()) { guiInternalTitleLayout.Destroy(); guiChildLayout.Destroy(); BuildEmptyGUI(); state = State.Empty; } } }
/// <summary> /// Creates a new rectangle offset GUI. /// </summary> /// <param name="title">Text to display on the title bar.</param> /// <param name="layout">Layout to append the GUI elements to.</param> public RectOffsetGUI(LocString title, GUILayout layout) { GUILayoutX rectLayout = layout.AddLayoutX(); rectLayout.AddElement(new GUILabel(title, GUIOption.FixedWidth(100))); GUILayoutY rectContentLayout = rectLayout.AddLayoutY(); GUILayoutX rectTopRow = rectContentLayout.AddLayoutX(); GUILayoutX rectBotRow = rectContentLayout.AddLayoutX(); offsetLeftField = new GUIIntField(new LocEdString("Left"), 40); offsetRightField = new GUIIntField(new LocEdString("Right"), 40); offsetTopField = new GUIIntField(new LocEdString("Top"), 40); offsetBottomField = new GUIIntField(new LocEdString("Bottom"), 40); rectTopRow.AddElement(offsetLeftField); rectTopRow.AddElement(offsetRightField); rectBotRow.AddElement(offsetTopField); rectBotRow.AddElement(offsetBottomField); offsetLeftField.OnChanged += x => { offset.left = x; if (OnChanged != null) { OnChanged(offset); } }; offsetRightField.OnChanged += x => { offset.right = x; if (OnChanged != null) { OnChanged(offset); } }; offsetTopField.OnChanged += x => { offset.top = x; if (OnChanged != null) { OnChanged(offset); } }; offsetBottomField.OnChanged += x => { offset.bottom = x; if (OnChanged != null) { OnChanged(offset); } }; Action DoOnConfirmed = () => { if (OnConfirmed != null) { OnConfirmed(); } }; offsetLeftField.OnConfirmed += DoOnConfirmed; offsetLeftField.OnFocusLost += DoOnConfirmed; offsetRightField.OnConfirmed += DoOnConfirmed; offsetRightField.OnFocusLost += DoOnConfirmed; offsetTopField.OnConfirmed += DoOnConfirmed; offsetTopField.OnFocusLost += DoOnConfirmed; offsetBottomField.OnConfirmed += DoOnConfirmed; offsetBottomField.OnFocusLost += DoOnConfirmed; }
/// <summary> /// Recreates all the GUI elements used by this inspector. /// </summary> private void BuildGUI() { if (InspectedObject != null) { Camera camera = (Camera)InspectedObject; projectionTypeField.OnSelectionChanged += x => { camera.ProjectionType = (ProjectionType)x; MarkAsModified(); ConfirmModify(); ToggleTypeSpecificFields((ProjectionType)x); }; fieldOfView.OnChanged += x => { camera.FieldOfView = x; MarkAsModified(); }; fieldOfView.OnFocusLost += ConfirmModify; orthoHeight.OnChanged += x => { camera.OrthoHeight = x; MarkAsModified(); }; orthoHeight.OnConfirmed += ConfirmModify; orthoHeight.OnFocusLost += ConfirmModify; aspectField.OnChanged += x => { camera.AspectRatio = x; MarkAsModified(); }; aspectField.OnConfirmed += ConfirmModify; aspectField.OnFocusLost += ConfirmModify; nearPlaneField.OnChanged += x => { camera.NearClipPlane = x; MarkAsModified(); }; nearPlaneField.OnConfirmed += ConfirmModify; nearPlaneField.OnFocusLost += ConfirmModify; farPlaneField.OnChanged += x => { camera.FarClipPlane = x; MarkAsModified(); }; farPlaneField.OnConfirmed += ConfirmModify; farPlaneField.OnFocusLost += ConfirmModify; viewportXField.OnChanged += x => { Rect2 rect = camera.ViewportRect; rect.x = x; camera.ViewportRect = rect; MarkAsModified(); }; viewportXField.OnConfirmed += ConfirmModify; viewportXField.OnFocusLost += ConfirmModify; viewportYField.OnChanged += x => { Rect2 rect = camera.ViewportRect; rect.y = x; camera.ViewportRect = rect; MarkAsModified(); }; viewportYField.OnConfirmed += ConfirmModify; viewportYField.OnFocusLost += ConfirmModify; viewportWidthField.OnChanged += x => { Rect2 rect = camera.ViewportRect; rect.width = x; camera.ViewportRect = rect; MarkAsModified(); }; viewportWidthField.OnConfirmed += ConfirmModify; viewportWidthField.OnFocusLost += ConfirmModify; viewportHeightField.OnChanged += x => { Rect2 rect = camera.ViewportRect; rect.height = x; camera.ViewportRect = rect; MarkAsModified(); }; viewportHeightField.OnConfirmed += ConfirmModify; viewportHeightField.OnFocusLost += ConfirmModify; clearFlagsFields.OnSelectionChanged += x => { camera.ClearFlags = (ClearFlags)x; MarkAsModified(); ConfirmModify(); }; clearStencilField.OnChanged += x => { camera.ClearStencil = (ushort)x; }; clearStencilField.OnConfirmed += ConfirmModify; clearStencilField.OnFocusLost += ConfirmModify; clearDepthField.OnChanged += x => { camera.ClearDepth = x; }; clearDepthField.OnConfirmed += ConfirmModify; clearDepthField.OnFocusLost += ConfirmModify; clearColorField.OnChanged += x => { camera.ClearColor = x; MarkAsModified(); ConfirmModify(); }; priorityField.OnChanged += x => { camera.Priority = x; MarkAsModified(); }; priorityField.OnConfirmed += ConfirmModify; priorityField.OnFocusLost += 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; camera.Layers = layers; MarkAsModified(); ConfirmModify(); }; mainField.OnChanged += x => { camera.Main = x; MarkAsModified(); ConfirmModify(); }; Layout.AddElement(projectionTypeField); Layout.AddElement(fieldOfView); Layout.AddElement(orthoHeight); Layout.AddElement(aspectField); Layout.AddElement(nearPlaneField); Layout.AddElement(farPlaneField); GUILayoutX viewportTopLayout = Layout.AddLayoutX(); viewportTopLayout.AddElement(new GUILabel(new LocEdString("Viewport"), GUIOption.FixedWidth(100))); GUILayoutY viewportContentLayout = viewportTopLayout.AddLayoutY(); GUILayoutX viewportTopRow = viewportContentLayout.AddLayoutX(); viewportTopRow.AddElement(viewportXField); viewportTopRow.AddElement(viewportWidthField); GUILayoutX viewportBotRow = viewportContentLayout.AddLayoutX(); viewportBotRow.AddElement(viewportYField); viewportBotRow.AddElement(viewportHeightField); Layout.AddElement(clearFlagsFields); Layout.AddElement(clearColorField); Layout.AddElement(clearDepthField); Layout.AddElement(clearStencilField); Layout.AddElement(priorityField); Layout.AddElement(layersField); Layout.AddElement(mainField); ToggleTypeSpecificFields(camera.ProjectionType); } }
/// <summary> /// Creates all of the GUI elements required for the specified type of dialog box. /// </summary> private void SetupGUI() { messageLabel = new GUILabel("", EditorStyles.MultiLineLabel, GUIOption.FixedWidth(260), GUIOption.FlexibleHeight(0, 600)); GUILayoutY layoutY = GUI.AddLayoutY(); layoutY.AddSpace(10); GUILayoutX messageLayout = layoutY.AddLayoutX(); messageLayout.AddFlexibleSpace(); messageLayout.AddElement(messageLabel); messageLayout.AddFlexibleSpace(); layoutY.AddSpace(10); GUILayoutX btnLayout = layoutY.AddLayoutX(); btnLayout.AddFlexibleSpace(); switch (type) { case Type.OK: { GUIButton okBtn = new GUIButton(new LocEdString("OK")); okBtn.OnClick += () => ButtonClicked(ResultType.OK); btnLayout.AddElement(okBtn); } break; case Type.OKCancel: { GUIButton okBtn = new GUIButton(new LocEdString("OK")); okBtn.OnClick += () => ButtonClicked(ResultType.OK); GUIButton cancelBtn = new GUIButton(new LocEdString("Cancel")); cancelBtn.OnClick += () => ButtonClicked(ResultType.Cancel); btnLayout.AddElement(okBtn); btnLayout.AddSpace(20); btnLayout.AddElement(cancelBtn); } break; case Type.RetryAbortIgnore: { GUIButton retryBtn = new GUIButton(new LocEdString("Retry")); retryBtn.OnClick += () => ButtonClicked(ResultType.Retry); GUIButton abortBtn = new GUIButton(new LocEdString("Abort")); abortBtn.OnClick += () => ButtonClicked(ResultType.Abort); GUIButton ignoreBtn = new GUIButton(new LocEdString("Ignore")); ignoreBtn.OnClick += () => ButtonClicked(ResultType.Ignore); btnLayout.AddElement(retryBtn); btnLayout.AddSpace(20); btnLayout.AddElement(abortBtn); btnLayout.AddSpace(20); btnLayout.AddElement(ignoreBtn); } break; case Type.RetryCancel: { GUIButton retryBtn = new GUIButton(new LocEdString("Retry")); retryBtn.OnClick += () => ButtonClicked(ResultType.Retry); GUIButton cancelBtn = new GUIButton(new LocEdString("Cancel")); cancelBtn.OnClick += () => ButtonClicked(ResultType.Cancel); btnLayout.AddElement(retryBtn); btnLayout.AddSpace(20); btnLayout.AddElement(cancelBtn); } break; case Type.TryCancelContinue: { GUIButton tryBtn = new GUIButton(new LocEdString("Try")); tryBtn.OnClick += () => ButtonClicked(ResultType.Try); GUIButton cancelBtn = new GUIButton(new LocEdString("Cancel")); cancelBtn.OnClick += () => ButtonClicked(ResultType.Cancel); GUIButton continueBtn = new GUIButton(new LocEdString("Continue")); continueBtn.OnClick += () => ButtonClicked(ResultType.Continue); btnLayout.AddElement(tryBtn); btnLayout.AddSpace(20); btnLayout.AddElement(cancelBtn); btnLayout.AddSpace(20); btnLayout.AddElement(continueBtn); } break; case Type.YesNo: { GUIButton yesBtn = new GUIButton(new LocEdString("Yes")); yesBtn.OnClick += () => ButtonClicked(ResultType.Yes); GUIButton noBtn = new GUIButton(new LocEdString("No")); noBtn.OnClick += () => ButtonClicked(ResultType.No); btnLayout.AddElement(yesBtn); btnLayout.AddSpace(20); btnLayout.AddElement(noBtn); } break; case Type.YesNoCancel: { GUIButton yesBtn = new GUIButton(new LocEdString("Yes")); yesBtn.OnClick += () => ButtonClicked(ResultType.Yes); GUIButton noBtn = new GUIButton(new LocEdString("No")); noBtn.OnClick += () => ButtonClicked(ResultType.No); GUIButton cancelBtn = new GUIButton(new LocEdString("Cancel")); cancelBtn.OnClick += () => ButtonClicked(ResultType.Cancel); btnLayout.AddElement(yesBtn); btnLayout.AddSpace(20); btnLayout.AddElement(noBtn); btnLayout.AddSpace(20); btnLayout.AddElement(cancelBtn); } break; } btnLayout.AddFlexibleSpace(); layoutY.AddFlexibleSpace(); }
private void RebuildGUI() { GUI.Clear(); guiCurveEditor = null; guiFieldDisplay = null; if (selectedSO == null) { GUILabel warningLbl = new GUILabel(new LocEdString("Select an object to animate in the Hierarchy or Scene windows.")); GUILayoutY vertLayout = GUI.AddLayoutY(); vertLayout.AddFlexibleSpace(); GUILayoutX horzLayout = vertLayout.AddLayoutX(); vertLayout.AddFlexibleSpace(); horzLayout.AddFlexibleSpace(); horzLayout.AddElement(warningLbl); horzLayout.AddFlexibleSpace(); return; } // Top button row GUIContent playIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.Play), new LocEdString("Play")); GUIContent recordIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.Record), new LocEdString("Record")); GUIContent prevFrameIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.FrameBack), new LocEdString("Previous frame")); GUIContent nextFrameIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.FrameForward), new LocEdString("Next frame")); GUIContent addKeyframeIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.AddKeyframe), new LocEdString("Add keyframe")); GUIContent addEventIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.AddEvent), new LocEdString("Add event")); GUIContent optionsIcon = new GUIContent(EditorBuiltin.GetLibraryWindowIcon(LibraryWindowIcon.Options), new LocEdString("Options")); playButton = new GUIButton(playIcon); recordButton = new GUIButton(recordIcon); prevFrameButton = new GUIButton(prevFrameIcon); frameInputField = new GUIIntField(); nextFrameButton = new GUIButton(nextFrameIcon); addKeyframeButton = new GUIButton(addKeyframeIcon); addEventButton = new GUIButton(addEventIcon); optionsButton = new GUIButton(optionsIcon); playButton.OnClick += () => { // TODO // - Record current state of the scene object hierarchy // - Evaluate all curves manually and update them // - On end, restore original values of the scene object hierarchy }; recordButton.OnClick += () => { // TODO // - Every frame read back current values of all the current curve's properties and assign it to the current frame }; prevFrameButton.OnClick += () => { SetCurrentFrame(currentFrameIdx - 1); }; frameInputField.OnChanged += SetCurrentFrame; nextFrameButton.OnClick += () => { SetCurrentFrame(currentFrameIdx + 1); }; addKeyframeButton.OnClick += () => { guiCurveEditor.AddKeyFrameAtMarker(); }; addEventButton.OnClick += () => { guiCurveEditor.AddEventAtMarker(); }; optionsButton.OnClick += () => { Vector2I openPosition = ScreenToWindowPos(Input.PointerPosition); AnimationOptions dropDown = DropDownWindow.Open <AnimationOptions>(this, openPosition); dropDown.Initialize(this); }; // Property buttons addPropertyBtn = new GUIButton(new LocEdString("Add property")); delPropertyBtn = new GUIButton(new LocEdString("Delete selected")); addPropertyBtn.OnClick += () => { Action openPropertyWindow = () => { Vector2I windowPos = ScreenToWindowPos(Input.PointerPosition); FieldSelectionWindow fieldSelection = DropDownWindow.Open <FieldSelectionWindow>(this, windowPos); fieldSelection.OnFieldSelected += OnFieldAdded; }; if (clipInfo.clip == null) { LocEdString title = new LocEdString("Warning"); LocEdString message = new LocEdString("Selected object doesn't have an animation clip assigned. Would you like to create" + " a new animation clip?"); DialogBox.Open(title, message, DialogBox.Type.YesNoCancel, type => { if (type == DialogBox.ResultType.Yes) { string clipSavePath; if (BrowseDialog.SaveFile(ProjectLibrary.ResourceFolder, "*.asset", out clipSavePath)) { clipSavePath = Path.ChangeExtension(clipSavePath, ".asset"); AnimationClip newClip = new AnimationClip(); ProjectLibrary.Create(newClip, clipSavePath); LoadAnimClip(newClip); Animation animation = selectedSO.GetComponent <Animation>(); if (animation == null) { animation = selectedSO.AddComponent <Animation>(); } animation.DefaultClip = newClip; EditorApplication.SetSceneDirty(); openPropertyWindow(); } } }); } else { if (clipInfo.isImported) { LocEdString title = new LocEdString("Warning"); LocEdString message = new LocEdString("You cannot add/edit/remove curves from animation clips that" + " are imported from an external file."); DialogBox.Open(title, message, DialogBox.Type.OK); } else { openPropertyWindow(); } } }; delPropertyBtn.OnClick += () => { if (clipInfo.clip == null) { return; } if (clipInfo.isImported) { LocEdString title = new LocEdString("Warning"); LocEdString message = new LocEdString("You cannot add/edit/remove curves from animation clips that" + " are imported from an external file."); DialogBox.Open(title, message, DialogBox.Type.OK); } else { LocEdString title = new LocEdString("Warning"); LocEdString message = new LocEdString("Are you sure you want to remove all selected fields?"); DialogBox.Open(title, message, DialogBox.Type.YesNo, x => { if (x == DialogBox.ResultType.Yes) { RemoveSelectedFields(); } }); } }; GUIPanel mainPanel = GUI.AddPanel(); GUIPanel backgroundPanel = GUI.AddPanel(1); GUILayout mainLayout = mainPanel.AddLayoutY(); buttonLayout = mainLayout.AddLayoutX(); buttonLayout.AddSpace(5); buttonLayout.AddElement(playButton); buttonLayout.AddElement(recordButton); buttonLayout.AddSpace(5); buttonLayout.AddElement(prevFrameButton); buttonLayout.AddElement(frameInputField); buttonLayout.AddElement(nextFrameButton); buttonLayout.AddSpace(5); buttonLayout.AddElement(addKeyframeButton); buttonLayout.AddElement(addEventButton); buttonLayout.AddSpace(5); buttonLayout.AddElement(optionsButton); buttonLayout.AddFlexibleSpace(); buttonLayoutHeight = playButton.Bounds.height; GUITexture buttonBackground = new GUITexture(null, EditorStyles.HeaderBackground); buttonBackground.Bounds = new Rect2I(0, 0, Width, buttonLayoutHeight); backgroundPanel.AddElement(buttonBackground); GUILayout contentLayout = mainLayout.AddLayoutX(); GUILayout fieldDisplayLayout = contentLayout.AddLayoutY(GUIOption.FixedWidth(FIELD_DISPLAY_WIDTH)); guiFieldDisplay = new GUIAnimFieldDisplay(fieldDisplayLayout, FIELD_DISPLAY_WIDTH, Height - buttonLayoutHeight * 2, selectedSO); guiFieldDisplay.OnEntrySelected += OnFieldSelected; GUILayout bottomButtonLayout = fieldDisplayLayout.AddLayoutX(); bottomButtonLayout.AddElement(addPropertyBtn); bottomButtonLayout.AddElement(delPropertyBtn); horzScrollBar = new GUIResizeableScrollBarH(); horzScrollBar.OnScrollOrResize += OnHorzScrollOrResize; vertScrollBar = new GUIResizeableScrollBarV(); vertScrollBar.OnScrollOrResize += OnVertScrollOrResize; GUITexture separator = new GUITexture(null, EditorStyles.Separator, GUIOption.FixedWidth(3)); contentLayout.AddElement(separator); GUILayout curveLayout = contentLayout.AddLayoutY(); GUILayout curveLayoutHorz = curveLayout.AddLayoutX(); GUILayout horzScrollBarLayout = curveLayout.AddLayoutX(); horzScrollBarLayout.AddElement(horzScrollBar); horzScrollBarLayout.AddFlexibleSpace(); editorPanel = curveLayoutHorz.AddPanel(); curveLayoutHorz.AddElement(vertScrollBar); curveLayoutHorz.AddFlexibleSpace(); scrollBarHeight = horzScrollBar.Bounds.height; scrollBarWidth = vertScrollBar.Bounds.width; Vector2I curveEditorSize = GetCurveEditorSize(); guiCurveEditor = new GUICurveEditor(this, editorPanel, curveEditorSize.x, curveEditorSize.y); guiCurveEditor.OnFrameSelected += OnFrameSelected; guiCurveEditor.OnEventAdded += OnEventsChanged; guiCurveEditor.OnEventModified += EditorApplication.SetProjectDirty; guiCurveEditor.OnEventDeleted += OnEventsChanged; guiCurveEditor.OnCurveModified += EditorApplication.SetProjectDirty; guiCurveEditor.Redraw(); horzScrollBar.SetWidth(curveEditorSize.x); vertScrollBar.SetHeight(curveEditorSize.y); UpdateScrollBarSize(); }
/// <summary> /// Updates contents of the scene object specific fields (name, position, rotation, etc.) /// </summary> /// <param name="forceUpdate">If true, the GUI elements will be updated regardless of whether a change was /// detected or not.</param> private void RefreshSceneObjectFields(bool forceUpdate) { if (activeSO == null) { return; } soNameInput.Text = activeSO.Name; soActiveToggle.Value = activeSO.Active; soMobility.Value = (ulong)activeSO.Mobility; SceneObject prefabParent = PrefabUtility.GetPrefabParent(activeSO); // Ignore prefab parent if scene root, we only care for non-root prefab instances bool hasPrefab = prefabParent != null && prefabParent.Parent != null; if (soHasPrefab != hasPrefab || forceUpdate) { int numChildren = soPrefabLayout.ChildCount; for (int i = 0; i < numChildren; i++) { soPrefabLayout.GetChild(0).Destroy(); } GUILabel prefabLabel = new GUILabel(new LocEdString("Prefab"), GUIOption.FixedWidth(50)); soPrefabLayout.AddElement(prefabLabel); if (hasPrefab) { GUIButton btnApplyPrefab = new GUIButton(new LocEdString("Apply"), GUIOption.FixedWidth(60)); GUIButton btnRevertPrefab = new GUIButton(new LocEdString("Revert"), GUIOption.FixedWidth(60)); GUIButton btnBreakPrefab = new GUIButton(new LocEdString("Break"), GUIOption.FixedWidth(60)); btnApplyPrefab.OnClick += () => { PrefabUtility.ApplyPrefab(activeSO); }; btnRevertPrefab.OnClick += () => { UndoRedo.RecordSO(activeSO, true, "Reverting \"" + activeSO.Name + "\" to prefab."); PrefabUtility.RevertPrefab(activeSO); EditorApplication.SetSceneDirty(); }; btnBreakPrefab.OnClick += () => { UndoRedo.BreakPrefab(activeSO, "Breaking prefab link for " + activeSO.Name); EditorApplication.SetSceneDirty(); }; soPrefabLayout.AddElement(btnApplyPrefab); soPrefabLayout.AddElement(btnRevertPrefab); soPrefabLayout.AddElement(btnBreakPrefab); } else { GUILabel noPrefabLabel = new GUILabel("None"); soPrefabLayout.AddElement(noPrefabLabel); } soHasPrefab = hasPrefab; } Vector3 position; Quaternion rotation; if (EditorApplication.ActiveCoordinateMode == HandleCoordinateMode.World) { position = activeSO.Position; rotation = activeSO.Rotation; } else { position = activeSO.LocalPosition; rotation = activeSO.LocalRotation; } Vector3 scale = activeSO.LocalScale; if (!soPos.HasInputFocus) { soPos.Value = position; } // Avoid updating the rotation unless actually changed externally, since switching back and forth between // quaternion and euler angles can cause weird behavior if (!soRot.HasInputFocus && rotation != lastRotation) { soRot.Value = rotation.ToEuler(); lastRotation = rotation; } if (!soScale.HasInputFocus) { soScale.Value = scale; } }
/// <summary> /// Initializes the drop down window by creating the necessary GUI. Must be called after construction and before /// use. /// </summary> /// <param name="parent">Libary window that this drop down window is a part of.</param> internal void Initialize(LibraryWindow parent) { this.parent = parent; GUIToggleGroup group = new GUIToggleGroup(); GUIToggle list16 = new GUIToggle(new LocEdString("16"), group, EditorStyles.Button, GUIOption.FixedWidth(30)); GUIToggle grid32 = new GUIToggle(new LocEdString("32"), group, EditorStyles.Button, GUIOption.FixedWidth(30)); GUIToggle grid48 = new GUIToggle(new LocEdString("48"), group, EditorStyles.Button, GUIOption.FixedWidth(30)); GUIToggle grid64 = new GUIToggle(new LocEdString("64"), group, EditorStyles.Button, GUIOption.FixedWidth(30)); ProjectViewType activeType = parent.ViewType; switch (activeType) { case ProjectViewType.List16: list16.Value = true; break; case ProjectViewType.Grid32: grid32.Value = true; break; case ProjectViewType.Grid48: grid48.Value = true; break; case ProjectViewType.Grid64: grid64.Value = true; break; } list16.OnToggled += (active) => { if (active) { ChangeViewType(ProjectViewType.List16); } }; grid32.OnToggled += (active) => { if (active) { ChangeViewType(ProjectViewType.Grid32); } }; grid48.OnToggled += (active) => { if (active) { ChangeViewType(ProjectViewType.Grid48); } }; grid64.OnToggled += (active) => { if (active) { ChangeViewType(ProjectViewType.Grid64); } }; GUILayoutY vertLayout = GUI.AddLayoutY(); vertLayout.AddFlexibleSpace(); GUILayoutX contentLayout = vertLayout.AddLayoutX(); contentLayout.AddFlexibleSpace(); contentLayout.AddElement(list16); contentLayout.AddElement(grid32); contentLayout.AddElement(grid48); contentLayout.AddElement(grid64); contentLayout.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> 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> /// Constructs a new resource tile entry. /// </summary> /// <param name="owner">Content area this entry is part of.</param> /// <param name="parent">Parent layout to add this entry's GUI elements to.</param> /// <param name="path">Path to the project library entry to display data for.</param> /// <param name="index">Sequential index of the entry in the conent area.</param> /// <param name="width">Width of the GUI entry.</param> /// <param name="height">Maximum allowed height for the label.</param>" /// <param name="type">Type of the entry, which controls its style and/or behaviour.</param> public LibraryGUIEntry(LibraryGUIContent owner, GUILayout parent, string path, int index, int width, int height, LibraryGUIEntryType type) { GUILayout entryLayout; if (owner.GridLayout) { entryLayout = parent.AddLayoutY(); } else { entryLayout = parent.AddLayoutX(); } SpriteTexture iconTexture = GetIcon(path, owner.TileSize); icon = new GUITexture(iconTexture, GUITextureScaleMode.ScaleToFit, true, GUIOption.FixedHeight(owner.TileSize), GUIOption.FixedWidth(owner.TileSize)); label = null; string name = PathEx.GetTail(path); if (owner.GridLayout) { int labelHeight = height - owner.TileSize; label = new GUILabel(name, EditorStyles.MultiLineLabelCentered, GUIOption.FixedWidth(width), GUIOption.FixedHeight(labelHeight)); switch (type) { case LibraryGUIEntryType.Single: break; case LibraryGUIEntryType.MultiFirst: groupUnderlay = new GUITexture(null, LibraryEntryFirstBg); break; case LibraryGUIEntryType.MultiElement: groupUnderlay = new GUITexture(null, LibraryEntryBg); break; case LibraryGUIEntryType.MultiLast: groupUnderlay = new GUITexture(null, LibraryEntryLastBg); break; } } else { label = new GUILabel(name, GUIOption.FixedWidth(width - owner.TileSize), GUIOption.FixedHeight(height)); switch (type) { case LibraryGUIEntryType.Single: break; case LibraryGUIEntryType.MultiFirst: groupUnderlay = new GUITexture(null, LibraryEntryVertFirstBg); break; case LibraryGUIEntryType.MultiElement: groupUnderlay = new GUITexture(null, LibraryEntryVertBg); break; case LibraryGUIEntryType.MultiLast: groupUnderlay = new GUITexture(null, LibraryEntryVertLastBg); break; } } entryLayout.AddElement(icon); entryLayout.AddElement(label); if (groupUnderlay != null) { owner.DeepUnderlay.AddElement(groupUnderlay); } this.owner = owner; this.index = index; this.path = path; this.bounds = new Rect2I(); this.underlay = null; this.type = type; this.width = width; }
private void OnInitialize() { GUILabel title = new GUILabel(new LocEdString("Banshee Engine v0.4"), EditorStyles.TitleLabel); GUILabel subTitle = new GUILabel(new LocEdString("A modern open-source game development toolkit"), EditorStyles.LabelCentered); GUILabel license = new GUILabel(new LocEdString( "This program is licensed under the GNU Lesser General Public License V3"), EditorStyles.LabelCentered); GUILabel copyright = new GUILabel(new LocEdString("Copyright (C) 2015 Marko Pintera. All rights reserved."), EditorStyles.LabelCentered); GUILabel authorLabel = new GUILabel(new LocEdString("Banshee was created, and is being actively developed by Marko Pintera.")); GUILabel emailTitle = new GUILabel(new LocEdString("E-mail"), GUIOption.FixedWidth(150)); emailLabel = new GUITextBox(); GUILabel linkedInTitle = new GUILabel(new LocEdString("LinkedIn"), GUIOption.FixedWidth(150)); GUIButton linkedInBtn = new GUIButton(new LocEdString("Profile")); GUIToggleGroup foldoutGroup = new GUIToggleGroup(true); GUIToggle contactFoldout = new GUIToggle(new LocEdString("Author"), foldoutGroup, EditorStyles.Foldout); GUIToggle thirdPartyFoldout = new GUIToggle(new LocEdString("Used third party libraries"), foldoutGroup, EditorStyles.Foldout); GUIToggle noticesFoldout = new GUIToggle(new LocEdString("Third party notices"), foldoutGroup, EditorStyles.Foldout); GUIToggle collaboratorsFoldout = new GUIToggle(new LocEdString("Collaborators"), foldoutGroup, EditorStyles.Foldout); GUILabel freeTypeNotice = new GUILabel(new LocEdString( "Portions of this software are copyright (C) 2015 The FreeType Project (www.freetype.org). " + "All rights reserved."), EditorStyles.MultiLineLabelCentered, GUIOption.FlexibleHeight(), GUIOption.FixedWidth(380)); GUILabel fbxSdkNotice = new GUILabel(new LocEdString( "This software contains Autodesk(R) FBX(R) code developed by Autodesk, Inc. Copyright 2013 Autodesk, Inc. " + "All rights, reserved. Such code is provided \"as is\" and Autodesk, Inc. disclaims any and all warranties, " + "whether express or implied, including without limitation the implied warranties of merchantability, " + "fitness for a particular purpose or non-infringement of third party rights. In no event shall Autodesk, " + "Inc. be liable for any direct, indirect, incidental, special, exemplary, or consequential damages " + "(including, but not limited to, procurement of substitute goods or services; loss of use, data, or " + "profits; or business interruption) however caused and on any theory of liability, whether in contract, " + "strict liability, or tort (including negligence or otherwise) arising in any way out of such code."), EditorStyles.MultiLineLabelCentered, GUIOption.FlexibleHeight(), GUIOption.FixedWidth(380)); GUILayoutY mainLayout = GUI.AddLayoutY(); mainLayout.AddSpace(10); mainLayout.AddElement(title); mainLayout.AddElement(subTitle); mainLayout.AddSpace(10); mainLayout.AddElement(license); mainLayout.AddElement(copyright); mainLayout.AddSpace(10); mainLayout.AddElement(contactFoldout); GUILayoutY contactLayout = mainLayout.AddLayoutY(); contactLayout.AddSpace(15); GUILayout authorLayout = contactLayout.AddLayoutX(); authorLayout.AddFlexibleSpace(); authorLayout.AddElement(authorLabel); authorLayout.AddFlexibleSpace(); contactLayout.AddSpace(15); GUILayout emailLayout = contactLayout.AddLayoutX(); emailLayout.AddSpace(10); emailLayout.AddElement(emailTitle); emailLayout.AddElement(emailLabel); emailLayout.AddSpace(10); GUILayout linkedInLayout = contactLayout.AddLayoutX(); linkedInLayout.AddSpace(10); linkedInLayout.AddElement(linkedInTitle); linkedInLayout.AddElement(linkedInBtn); linkedInLayout.AddSpace(10); mainLayout.AddSpace(5); mainLayout.AddElement(thirdPartyFoldout); GUILayoutY thirdPartyLayout = mainLayout.AddLayoutY(); CreateThirdPartyGUI(thirdPartyLayout, "Autodesk FBX SDK", "http://usa.autodesk.com/adsk/servlet/pc/item?siteID=123112&id=10775847"); CreateThirdPartyGUI(thirdPartyLayout, "FreeImage", "http://freeimage.sourceforge.net/"); CreateThirdPartyGUI(thirdPartyLayout, "FreeType", "http://www.freetype.org/"); CreateThirdPartyGUI(thirdPartyLayout, "Mono", "http://www.mono-project.com/"); CreateThirdPartyGUI(thirdPartyLayout, "NVIDIA Texture Tools", "https://github.com/castano/nvidia-texture-tools"); CreateThirdPartyGUI(thirdPartyLayout, "libFLAC", "https://xiph.org/flac/"); CreateThirdPartyGUI(thirdPartyLayout, "libOgg", "https://www.xiph.org/ogg/"); CreateThirdPartyGUI(thirdPartyLayout, "libVorbis", "http://www.vorbis.com/"); CreateThirdPartyGUI(thirdPartyLayout, "OpenAL Soft", "http://kcat.strangesoft.net/openal.html"); mainLayout.AddSpace(5); mainLayout.AddElement(noticesFoldout); GUILayout noticesLayout = mainLayout.AddLayoutY(); noticesLayout.AddElement(freeTypeNotice); noticesLayout.AddSpace(10); noticesLayout.AddElement(fbxSdkNotice); mainLayout.AddSpace(5); mainLayout.AddElement(collaboratorsFoldout); GUILayoutY collaboratorsLayout = mainLayout.AddLayoutY(); CreateCollaboratorGUI(collaboratorsLayout, "Danijel Ribic", "Logo, UI icons, 3D models & textures"); CreateCollaboratorGUI(collaboratorsLayout, "Marco Bellan", "Bugfixes, editor enhancements"); mainLayout.AddFlexibleSpace(); contactLayout.Active = false; contactFoldout.OnToggled += x => { contactLayout.Active = x; }; thirdPartyLayout.Active = false; thirdPartyFoldout.OnToggled += x => thirdPartyLayout.Active = x; noticesLayout.Active = false; noticesFoldout.OnToggled += x => noticesLayout.Active = x; collaboratorsLayout.Active = false; collaboratorsFoldout.OnToggled += x => collaboratorsLayout.Active = x; emailLabel.Text = "*****@*****.**"; linkedInBtn.OnClick += () => { System.Diagnostics.Process.Start("http://hr.linkedin.com/in/markopintera"); }; }
/// <summary> /// Constructs a new animation field entry and appends the necessary GUI elements to the provided layouts. /// </summary> /// <param name="layouts">Layouts to append the GUI elements to.</param> /// <param name="path">Path of the curve field.</param> /// <param name="child">Determines if the element is a root path, or a child (sub) element.</param> /// <param name="indentAmount">Determines how much to horizontally indent the element, in pixels.</param> public GUIAnimFieldEntry(GUIAnimFieldLayouts layouts, string path, bool child, int indentAmount) { this.path = path; GUILayoutX toggleLayout = layouts.main.AddLayoutX(); toggleLayout.AddSpace(indentAmount); selectionBtn = new GUIButton(GetDisplayName(path, child), EditorStyles.Label, GUIOption.FlexibleWidth()); selectionBtn.OnClick += () => { OnEntrySelected?.Invoke(path); }; toggleLayout.AddElement(selectionBtn); entryHeight = EditorBuiltin.GUISkin.GetStyle(EditorStyles.Label).Height; backgroundTexture = new GUITexture(Builtin.WhiteTexture, GUITextureScaleMode.StretchToFit, GUIOption.FlexibleWidth()); backgroundTexture.SetTint(Color.Transparent); backgroundTexture.SetHeight(entryHeight); layouts.background.AddElement(backgroundTexture); }
private void OnInitialize() { mainLayout = GUI.AddLayoutY(); GUIContent viewIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.View), new LocEdString("View")); GUIContent moveIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Move), new LocEdString("Move")); GUIContent rotateIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Rotate), new LocEdString("Rotate")); GUIContent scaleIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Scale), new LocEdString("Scale")); GUIContent localIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Local), new LocEdString("Local")); GUIContent worldIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.World), new LocEdString("World")); GUIContent pivotIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Pivot), new LocEdString("Pivot")); GUIContent centerIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Center), new LocEdString("Center")); GUIContent moveSnapIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.MoveSnap), new LocEdString("Move snap")); GUIContent rotateSnapIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.RotateSnap), new LocEdString("Rotate snap")); GUIToggleGroup handlesTG = new GUIToggleGroup(); viewButton = new GUIToggle(viewIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35)); moveButton = new GUIToggle(moveIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35)); rotateButton = new GUIToggle(rotateIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35)); scaleButton = new GUIToggle(scaleIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35)); GUIToggleGroup coordModeTG = new GUIToggleGroup(); localCoordButton = new GUIToggle(localIcon, coordModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(75)); worldCoordButton = new GUIToggle(worldIcon, coordModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(75)); GUIToggleGroup pivotModeTG = new GUIToggleGroup(); pivotButton = new GUIToggle(pivotIcon, pivotModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(35)); centerButton = new GUIToggle(centerIcon, pivotModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(35)); moveSnapButton = new GUIToggle(moveSnapIcon, EditorStyles.Button, GUIOption.FlexibleWidth(35)); moveSnapInput = new GUIFloatField("", GUIOption.FlexibleWidth(35)); rotateSnapButton = new GUIToggle(rotateSnapIcon, EditorStyles.Button, GUIOption.FlexibleWidth(35)); rotateSnapInput = new GUIFloatField("", GUIOption.FlexibleWidth(35)); viewButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.View); moveButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.Move); rotateButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.Rotate); scaleButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.Scale); localCoordButton.OnClick += () => OnCoordinateModeButtonClicked(HandleCoordinateMode.Local); worldCoordButton.OnClick += () => OnCoordinateModeButtonClicked(HandleCoordinateMode.World); pivotButton.OnClick += () => OnPivotModeButtonClicked(HandlePivotMode.Pivot); centerButton.OnClick += () => OnPivotModeButtonClicked(HandlePivotMode.Center); moveSnapButton.OnToggled += (bool active) => OnMoveSnapToggled(active); moveSnapInput.OnChanged += (float value) => OnMoveSnapValueChanged(value); rotateSnapButton.OnToggled += (bool active) => OnRotateSnapToggled(active); rotateSnapInput.OnChanged += (float value) => OnRotateSnapValueChanged(value); GUILayout handlesLayout = mainLayout.AddLayoutX(); handlesLayout.AddElement(viewButton); handlesLayout.AddElement(moveButton); handlesLayout.AddElement(rotateButton); handlesLayout.AddElement(scaleButton); handlesLayout.AddSpace(10); handlesLayout.AddElement(localCoordButton); handlesLayout.AddElement(worldCoordButton); handlesLayout.AddSpace(10); handlesLayout.AddElement(pivotButton); handlesLayout.AddElement(centerButton); handlesLayout.AddFlexibleSpace(); handlesLayout.AddElement(moveSnapButton); handlesLayout.AddElement(moveSnapInput); handlesLayout.AddSpace(10); handlesLayout.AddElement(rotateSnapButton); handlesLayout.AddElement(rotateSnapInput); GUIPanel mainPanel = mainLayout.AddPanel(); rtPanel = mainPanel.AddPanel(); selectionPanel = mainPanel.AddPanel(-1); GUIPanel sceneAxesPanel = mainPanel.AddPanel(-1); sceneAxesGUI = new SceneAxesGUI(this, sceneAxesPanel, HandleAxesGUISize, HandleAxesGUISize, ProjectionType.Perspective); focusCatcher = new GUIButton("", EditorStyles.Blank); focusCatcher.OnFocusGained += () => hasContentFocus = true; focusCatcher.OnFocusLost += () => hasContentFocus = false; GUIPanel focusPanel = GUI.AddPanel(-2); focusPanel.AddElement(focusCatcher); toggleProfilerOverlayKey = new VirtualButton(ToggleProfilerOverlayBinding); viewToolKey = new VirtualButton(ViewToolBinding); moveToolKey = new VirtualButton(MoveToolBinding); rotateToolKey = new VirtualButton(RotateToolBinding); scaleToolKey = new VirtualButton(ScaleToolBinding); frameKey = new VirtualButton(FrameBinding); UpdateRenderTexture(Width, Height - HeaderHeight); UpdateProfilerOverlay(); }
/// <summary> /// Rebuilds the GUI object header if needed. /// </summary> /// <param name="layoutIndex">Index at which to insert the GUI elements.</param> protected void BuildGUI(int layoutIndex) { Action BuildEmptyGUI = () => { if (isInline) { return; } guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0); guiInternalTitleLayout.AddElement(new GUILabel(title)); guiInternalTitleLayout.AddElement(new GUILabel("Empty", GUIOption.FixedWidth(100))); if (!property.IsValueType) { GUIContent createIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Create), new LocEdString("Create")); guiCreateBtn = new GUIButton(createIcon, GUIOption.FixedWidth(30)); guiCreateBtn.OnClick += OnCreateButtonClicked; guiInternalTitleLayout.AddElement(guiCreateBtn); } }; Action BuildFilledGUI = () => { if (!isInline) { guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0); GUIToggle guiFoldout = new GUIToggle(title, EditorStyles.Foldout); guiFoldout.Value = isExpanded; guiFoldout.AcceptsKeyFocus = false; guiFoldout.OnToggled += OnFoldoutToggled; guiInternalTitleLayout.AddElement(guiFoldout); if (!style.StyleFlags.HasFlag(InspectableFieldStyleFlags.NotNull)) { GUIContent clearIcon = new GUIContent( EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Clear), new LocEdString("Clear")); GUIButton clearBtn = new GUIButton(clearIcon, GUIOption.FixedWidth(20)); clearBtn.OnClick += OnClearButtonClicked; guiInternalTitleLayout.AddElement(clearBtn); } } if (isExpanded || isInline) { SerializableObject serializableObject = property.GetObject(); SerializableField[] fields = serializableObject.Fields; if (fields.Length > 0) { GUILayoutY guiContentLayout; if (!isInline) { guiChildLayout = guiLayout.AddLayoutX(); guiChildLayout.AddSpace(IndentAmount); GUIPanel guiContentPanel = guiChildLayout.AddPanel(); GUILayoutX guiIndentLayoutX = guiContentPanel.AddLayoutX(); guiIndentLayoutX.AddSpace(IndentAmount); GUILayoutY guiIndentLayoutY = guiIndentLayoutX.AddLayoutY(); guiIndentLayoutY.AddSpace(IndentAmount); guiContentLayout = guiIndentLayoutY.AddLayoutY(); guiIndentLayoutY.AddSpace(IndentAmount); guiIndentLayoutX.AddSpace(IndentAmount); guiChildLayout.AddSpace(IndentAmount); short backgroundDepth = (short)(Inspector.START_BACKGROUND_DEPTH - depth - 1); string bgPanelStyle = depth % 2 == 0 ? EditorStylesInternal.InspectorContentBgAlternate : EditorStylesInternal.InspectorContentBg; GUIPanel backgroundPanel = guiContentPanel.AddPanel(backgroundDepth); GUITexture inspectorContentBg = new GUITexture(null, bgPanelStyle); backgroundPanel.AddElement(inspectorContentBg); } else { guiContentLayout = guiLayout; } children = CreateFields(serializableObject, context, path, depth + 1, guiContentLayout); } } else { guiChildLayout = null; } }; if (state == State.None) { if (propertyValue != null) { BuildFilledGUI(); state = State.Filled; } else { BuildEmptyGUI(); state = State.Empty; } } else if (state == State.Empty) { if (propertyValue != null) { guiInternalTitleLayout?.Destroy(); guiInternalTitleLayout = null; guiCreateBtn = null; BuildFilledGUI(); state = State.Filled; } } else if (state == State.Filled) { foreach (var child in children) { child.Destroy(); } children.Clear(); guiInternalTitleLayout?.Destroy(); guiInternalTitleLayout = null; guiCreateBtn = null; if (guiChildLayout != null) { guiChildLayout.Destroy(); guiChildLayout = null; } if (propertyValue == null) { BuildEmptyGUI(); state = State.Empty; } else { BuildFilledGUI(); } } }
/// <summary> /// Recreates all the GUI elements used by this inspector. /// </summary> private void BuildGUI() { Layout.Clear(); Animation animation = InspectedObject as Animation; if (animation == null) { return; } animationClipField.OnChanged += x => { AnimationClip clip = Resources.Load <AnimationClip>(x.UUID); animation.DefaultClip = clip; MarkAsModified(); ConfirmModify(); }; wrapModeField.OnSelectionChanged += x => { animation.WrapMode = (AnimWrapMode)x; MarkAsModified(); ConfirmModify(); }; speedField.OnChanged += x => { animation.Speed = x; MarkAsModified(); }; speedField.OnConfirmed += ConfirmModify; speedField.OnFocusLost += ConfirmModify; cullingField.OnChanged += x => { animation.Cull = x; MarkAsModified(); ConfirmModify(); }; overrideBoundsField.OnChanged += x => { animation.UseBounds = x; MarkAsModified(); ConfirmModify(); }; centerField.OnChanged += x => { AABox bounds = animation.Bounds; Vector3 min = x - bounds.Size * 0.5f; Vector3 max = x + bounds.Size * 0.5f; animation.Bounds = new AABox(min, max); MarkAsModified(); }; centerField.OnConfirmed += ConfirmModify; centerField.OnFocusLost += ConfirmModify; sizeField.OnChanged += x => { AABox bounds = animation.Bounds; Vector3 min = bounds.Center - x * 0.5f; Vector3 max = bounds.Center + x * 0.5f; animation.Bounds = new AABox(min, max); MarkAsModified(); }; sizeField.OnConfirmed += ConfirmModify; sizeField.OnFocusLost += ConfirmModify; Layout.AddElement(animationClipField); Layout.AddElement(wrapModeField); Layout.AddElement(speedField); Layout.AddElement(cullingField); Layout.AddElement(overrideBoundsField); GUILayoutX boundsLayout = Layout.AddLayoutX(); boundsLayout.AddElement(new GUILabel(new LocEdString("Bounds"), GUIOption.FixedWidth(100))); GUILayoutY boundsContent = boundsLayout.AddLayoutY(); boundsContent.AddElement(centerField); boundsContent.AddElement(sizeField); // Morph shapes Renderable renderable = animation.SceneObject.GetComponent <Renderable>(); MorphShapes morphShapes = renderable?.Mesh?.MorphShapes; if (morphShapes != null) { GUIToggle morphShapesToggle = new GUIToggle(new LocEdString("Morph shapes"), EditorStyles.Foldout); Layout.AddElement(morphShapesToggle); GUILayoutY channelsLayout = Layout.AddLayoutY(); morphShapesToggle.OnToggled += x => { channelsLayout.Active = x; Persistent.SetBool("Channels_Expanded", x); }; channelsLayout.Active = Persistent.GetBool("Channels_Expanded"); MorphChannel[] channels = morphShapes.Channels; for (int i = 0; i < channels.Length; i++) { GUILayoutY channelLayout = channelsLayout.AddLayoutY(); GUILayoutX channelTitleLayout = channelLayout.AddLayoutX(); channelLayout.AddSpace(5); GUILayoutY channelContentLayout = channelLayout.AddLayoutY(); string channelName = channels[i].Name; GUIToggle channelNameField = new GUIToggle(channelName, EditorStyles.Expand, GUIOption.FlexibleWidth()); channelTitleLayout.AddSpace(15); // Indent channelTitleLayout.AddElement(channelNameField); channelTitleLayout.AddFlexibleSpace(); channelNameField.OnToggled += x => { channelContentLayout.Active = x; Persistent.SetBool(channelName + "_Expanded", x); }; channelContentLayout.Active = Persistent.GetBool(channelName + "_Expanded"); MorphShape[] shapes = channels[i].Shapes; for (int j = 0; j < shapes.Length; j++) { GUILayoutX shapeLayout = channelContentLayout.AddLayoutX(); channelContentLayout.AddSpace(5); LocString nameString = new LocString("[{0}]. {1}"); nameString.SetParameter(0, j.ToString()); nameString.SetParameter(1, shapes[j].Name); GUILabel shapeNameField = new GUILabel(shapes[j].Name); LocString weightString = new LocEdString("Weight: {0}"); weightString.SetParameter(0, shapes[j].Weight.ToString()); GUILabel weightField = new GUILabel(weightString); shapeLayout.AddSpace(30); // Indent shapeLayout.AddElement(shapeNameField); shapeLayout.AddFlexibleSpace(); shapeLayout.AddElement(weightField); } } } }
/// <summary> /// Creates GUI elements required for displaying <see cref="SceneObject"/> fields like name, prefab data and /// transform (position, rotation, scale). Assumes that necessary inspector scroll area layout has already been /// created. /// </summary> private void CreateSceneObjectFields() { GUIPanel sceneObjectPanel = inspectorLayout.AddPanel(); sceneObjectPanel.SetHeight(GetTitleBounds().height); GUILayoutY sceneObjectLayout = sceneObjectPanel.AddLayoutY(); sceneObjectLayout.SetPosition(PADDING, PADDING); GUIPanel sceneObjectBgPanel = sceneObjectPanel.AddPanel(1); GUILayoutX nameLayout = sceneObjectLayout.AddLayoutX(); soActiveToggle = new GUIToggle(""); soActiveToggle.OnToggled += OnSceneObjectActiveStateToggled; GUILabel nameLbl = new GUILabel(new LocEdString("Name"), GUIOption.FixedWidth(50)); soNameInput = new GUITextBox(false, GUIOption.FlexibleWidth(180)); soNameInput.Text = activeSO.Name; soNameInput.OnChanged += OnSceneObjectRename; soNameInput.OnConfirmed += OnModifyConfirm; soNameInput.OnFocusLost += OnModifyConfirm; nameLayout.AddElement(soActiveToggle); nameLayout.AddSpace(3); nameLayout.AddElement(nameLbl); nameLayout.AddElement(soNameInput); nameLayout.AddFlexibleSpace(); soPrefabLayout = sceneObjectLayout.AddLayoutX(); GUILayoutX positionLayout = sceneObjectLayout.AddLayoutX(); GUILabel positionLbl = new GUILabel(new LocEdString("Position"), GUIOption.FixedWidth(50)); soPosX = new GUIFloatField(new LocEdString("X"), 10, "", GUIOption.FixedWidth(60)); soPosY = new GUIFloatField(new LocEdString("Y"), 10, "", GUIOption.FixedWidth(60)); soPosZ = new GUIFloatField(new LocEdString("Z"), 10, "", GUIOption.FixedWidth(60)); soPosX.OnChanged += (x) => OnPositionChanged(0, x); soPosY.OnChanged += (y) => OnPositionChanged(1, y); soPosZ.OnChanged += (z) => OnPositionChanged(2, z); soPosX.OnConfirmed += OnModifyConfirm; soPosY.OnConfirmed += OnModifyConfirm; soPosZ.OnConfirmed += OnModifyConfirm; soPosX.OnFocusLost += OnModifyConfirm; soPosY.OnFocusLost += OnModifyConfirm; soPosZ.OnFocusLost += OnModifyConfirm; positionLayout.AddElement(positionLbl); positionLayout.AddElement(soPosX); positionLayout.AddSpace(10); positionLayout.AddFlexibleSpace(); positionLayout.AddElement(soPosY); positionLayout.AddSpace(10); positionLayout.AddFlexibleSpace(); positionLayout.AddElement(soPosZ); positionLayout.AddFlexibleSpace(); GUILayoutX rotationLayout = sceneObjectLayout.AddLayoutX(); GUILabel rotationLbl = new GUILabel(new LocEdString("Rotation"), GUIOption.FixedWidth(50)); soRotX = new GUIFloatField(new LocEdString("X"), 10, "", GUIOption.FixedWidth(60)); soRotY = new GUIFloatField(new LocEdString("Y"), 10, "", GUIOption.FixedWidth(60)); soRotZ = new GUIFloatField(new LocEdString("Z"), 10, "", GUIOption.FixedWidth(60)); soRotX.OnChanged += (x) => OnRotationChanged(0, x); soRotY.OnChanged += (y) => OnRotationChanged(1, y); soRotZ.OnChanged += (z) => OnRotationChanged(2, z); soRotX.OnConfirmed += OnModifyConfirm; soRotY.OnConfirmed += OnModifyConfirm; soRotZ.OnConfirmed += OnModifyConfirm; soRotX.OnFocusLost += OnModifyConfirm; soRotY.OnFocusLost += OnModifyConfirm; soRotZ.OnFocusLost += OnModifyConfirm; rotationLayout.AddElement(rotationLbl); rotationLayout.AddElement(soRotX); rotationLayout.AddSpace(10); rotationLayout.AddFlexibleSpace(); rotationLayout.AddElement(soRotY); rotationLayout.AddSpace(10); rotationLayout.AddFlexibleSpace(); rotationLayout.AddElement(soRotZ); rotationLayout.AddFlexibleSpace(); GUILayoutX scaleLayout = sceneObjectLayout.AddLayoutX(); GUILabel scaleLbl = new GUILabel(new LocEdString("Scale"), GUIOption.FixedWidth(50)); soScaleX = new GUIFloatField(new LocEdString("X"), 10, "", GUIOption.FixedWidth(60)); soScaleY = new GUIFloatField(new LocEdString("Y"), 10, "", GUIOption.FixedWidth(60)); soScaleZ = new GUIFloatField(new LocEdString("Z"), 10, "", GUIOption.FixedWidth(60)); soScaleX.OnChanged += (x) => OnScaleChanged(0, x); soScaleY.OnChanged += (y) => OnScaleChanged(1, y); soScaleZ.OnChanged += (z) => OnScaleChanged(2, z); soScaleX.OnConfirmed += OnModifyConfirm; soScaleY.OnConfirmed += OnModifyConfirm; soScaleZ.OnConfirmed += OnModifyConfirm; soScaleX.OnFocusLost += OnModifyConfirm; soScaleY.OnFocusLost += OnModifyConfirm; soScaleZ.OnFocusLost += OnModifyConfirm; scaleLayout.AddElement(scaleLbl); scaleLayout.AddElement(soScaleX); scaleLayout.AddSpace(10); scaleLayout.AddFlexibleSpace(); scaleLayout.AddElement(soScaleY); scaleLayout.AddSpace(10); scaleLayout.AddFlexibleSpace(); scaleLayout.AddElement(soScaleZ); scaleLayout.AddFlexibleSpace(); sceneObjectLayout.AddFlexibleSpace(); GUITexture titleBg = new GUITexture(null, EditorStylesInternal.InspectorTitleBg); sceneObjectBgPanel.AddElement(titleBg); }
/// <summary> /// Updates the contents of the details panel according to the currently selected element. /// </summary> private void RefreshDetailsPanel() { detailsArea.Layout.Clear(); if (sSelectedElementIdx != -1) { GUILayoutX paddingX = detailsArea.Layout.AddLayoutX(); paddingX.AddSpace(5); GUILayoutY paddingY = paddingX.AddLayoutY(); paddingX.AddSpace(5); paddingY.AddSpace(5); GUILayoutY mainLayout = paddingY.AddLayoutY(); paddingY.AddSpace(5); ConsoleEntryData entry = filteredEntries[sSelectedElementIdx]; LocString message = new LocEdString(entry.message); GUILabel messageLabel = new GUILabel(message, EditorStyles.MultiLineLabel, GUIOption.FlexibleHeight()); mainLayout.AddElement(messageLabel); mainLayout.AddSpace(10); if (entry.callstack != null) { foreach (var call in entry.callstack) { string fileName = Path.GetFileName(call.file); string callMessage; if (string.IsNullOrEmpty(call.method)) { callMessage = "\tin " + fileName + ":" + call.line; } else { callMessage = "\t" + call.method + " in " + fileName + ":" + call.line; } GUIButton callBtn = new GUIButton(new LocEdString(callMessage)); mainLayout.AddElement(callBtn); CallStackEntry hoistedCall = call; callBtn.OnClick += () => { CodeEditor.OpenFile(hoistedCall.file, hoistedCall.line); }; } } mainLayout.AddFlexibleSpace(); } else { GUILayoutX centerX = detailsArea.Layout.AddLayoutX(); centerX.AddFlexibleSpace(); GUILayoutY centerY = centerX.AddLayoutY(); centerX.AddFlexibleSpace(); centerY.AddFlexibleSpace(); GUILabel nothingSelectedLbl = new GUILabel(new LocEdString("(No entry selected)")); centerY.AddElement(nothingSelectedLbl); centerY.AddFlexibleSpace(); } }
/// <summary> /// Updates contents of the scene object specific fields (name, position, rotation, etc.) /// </summary> /// <param name="forceUpdate">If true, the GUI elements will be updated regardless of whether a change was /// detected or not.</param> private void RefreshSceneObjectFields(bool forceUpdate) { if (activeSO == null) { return; } soNameInput.Text = activeSO.Name; soActiveToggle.Value = activeSO.Active; SceneObject prefabParent = PrefabUtility.GetPrefabParent(activeSO); // Ignore prefab parent if scene root, we only care for non-root prefab instances bool hasPrefab = prefabParent != null && prefabParent.Parent != null; if (soHasPrefab != hasPrefab || forceUpdate) { int numChildren = soPrefabLayout.ChildCount; for (int i = 0; i < numChildren; i++) { soPrefabLayout.GetChild(0).Destroy(); } GUILabel prefabLabel = new GUILabel(new LocEdString("Prefab"), GUIOption.FixedWidth(50)); soPrefabLayout.AddElement(prefabLabel); if (hasPrefab) { GUIButton btnApplyPrefab = new GUIButton(new LocEdString("Apply"), GUIOption.FixedWidth(60)); GUIButton btnRevertPrefab = new GUIButton(new LocEdString("Revert"), GUIOption.FixedWidth(60)); GUIButton btnBreakPrefab = new GUIButton(new LocEdString("Break"), GUIOption.FixedWidth(60)); btnApplyPrefab.OnClick += () => { PrefabUtility.ApplyPrefab(activeSO); }; btnRevertPrefab.OnClick += () => { UndoRedo.RecordSO(activeSO, true, "Reverting \"" + activeSO.Name + "\" to prefab."); PrefabUtility.RevertPrefab(activeSO); EditorApplication.SetSceneDirty(); }; btnBreakPrefab.OnClick += () => { UndoRedo.BreakPrefab(activeSO, "Breaking prefab link for " + activeSO.Name); EditorApplication.SetSceneDirty(); }; soPrefabLayout.AddElement(btnApplyPrefab); soPrefabLayout.AddElement(btnRevertPrefab); soPrefabLayout.AddElement(btnBreakPrefab); } else { GUILabel noPrefabLabel = new GUILabel("None"); soPrefabLayout.AddElement(noPrefabLabel); } soHasPrefab = hasPrefab; } Vector3 position; Vector3 angles; if (EditorApplication.ActiveCoordinateMode == HandleCoordinateMode.World) { position = activeSO.Position; angles = activeSO.Rotation.ToEuler(); } else { position = activeSO.LocalPosition; angles = activeSO.LocalRotation.ToEuler(); } Vector3 scale = activeSO.LocalScale; if (!soPosX.HasInputFocus) { soPosX.Value = position.x; } if (!soPosY.HasInputFocus) { soPosY.Value = position.y; } if (!soPosZ.HasInputFocus) { soPosZ.Value = position.z; } if (!soRotX.HasInputFocus) { soRotX.Value = angles.x; } if (!soRotY.HasInputFocus) { soRotY.Value = angles.y; } if (!soRotZ.HasInputFocus) { soRotZ.Value = angles.z; } if (!soScaleX.HasInputFocus) { soScaleX.Value = scale.x; } if (!soScaleY.HasInputFocus) { soScaleY.Value = scale.y; } if (!soScaleZ.HasInputFocus) { soScaleZ.Value = scale.z; } }
private void OnInitialize() { GUILayoutY layout = GUI.AddLayoutY(); GUILayoutX titleLayout = layout.AddLayoutX(); GUIContentImages infoImages = new GUIContentImages( EditorBuiltin.GetLogIcon(LogIcon.Info, 16, false), EditorBuiltin.GetLogIcon(LogIcon.Info, 16, true)); GUIContentImages warningImages = new GUIContentImages( EditorBuiltin.GetLogIcon(LogIcon.Warning, 16, false), EditorBuiltin.GetLogIcon(LogIcon.Warning, 16, true)); GUIContentImages errorImages = new GUIContentImages( EditorBuiltin.GetLogIcon(LogIcon.Error, 16, false), EditorBuiltin.GetLogIcon(LogIcon.Error, 16, true)); GUIToggle infoBtn = new GUIToggle(new GUIContent(infoImages), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT)); GUIToggle warningBtn = new GUIToggle(new GUIContent(warningImages), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT)); GUIToggle errorBtn = new GUIToggle(new GUIContent(errorImages), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT)); GUIToggle detailsBtn = new GUIToggle(new LocEdString("Show details"), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT)); GUIButton clearBtn = new GUIButton(new LocEdString("Clear"), GUIOption.FixedHeight(TITLE_HEIGHT)); GUIToggle clearOnPlayBtn = new GUIToggle(new LocEdString("Clear on play"), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT)); titleLayout.AddElement(infoBtn); titleLayout.AddElement(warningBtn); titleLayout.AddElement(errorBtn); titleLayout.AddFlexibleSpace(); titleLayout.AddElement(detailsBtn); titleLayout.AddElement(clearBtn); titleLayout.AddElement(clearOnPlayBtn); infoBtn.Value = filter.HasFlag(EntryFilter.Info); warningBtn.Value = filter.HasFlag(EntryFilter.Warning); errorBtn.Value = filter.HasFlag(EntryFilter.Error); clearOnPlayBtn.Value = EditorSettings.GetBool(CLEAR_ON_PLAY_KEY, true); infoBtn.OnToggled += x => { if (x) { SetFilter(filter | EntryFilter.Info); } else { SetFilter(filter & ~EntryFilter.Info); } }; warningBtn.OnToggled += x => { if (x) { SetFilter(filter | EntryFilter.Warning); } else { SetFilter(filter & ~EntryFilter.Warning); } }; errorBtn.OnToggled += x => { if (x) { SetFilter(filter | EntryFilter.Error); } else { SetFilter(filter & ~EntryFilter.Error); } }; detailsBtn.OnToggled += ToggleDetailsPanel; clearBtn.OnClick += ClearLog; clearOnPlayBtn.OnToggled += ToggleClearOnPlay; GUILayoutX mainLayout = layout.AddLayoutX(); listView = new GUIListView <ConsoleGUIEntry, ConsoleEntryData>(Width, ListHeight, ENTRY_HEIGHT, mainLayout); detailsSeparator = new GUITexture(Builtin.WhiteTexture, GUIOption.FixedWidth(SEPARATOR_WIDTH)); detailsArea = new GUIScrollArea(ScrollBarType.ShowIfDoesntFit, ScrollBarType.NeverShow); mainLayout.AddElement(detailsSeparator); mainLayout.AddElement(detailsArea); detailsSeparator.Active = false; detailsArea.Active = false; detailsSeparator.SetTint(SEPARATOR_COLOR); Refresh(); Debug.OnAdded += OnEntryAdded; }
private void OnInitialize() { Title = "Project Manager"; Width = 500; Height = 290; GUILayout vertLayout = GUI.AddLayoutY(); vertLayout.AddSpace(5); GUILayout firstRow = vertLayout.AddLayoutX(); vertLayout.AddFlexibleSpace(); GUILayout secondRow = vertLayout.AddLayoutX(); vertLayout.AddSpace(5); GUILayout thirdRow = vertLayout.AddLayoutX(); vertLayout.AddFlexibleSpace(); GUILayout fourthRow = vertLayout.AddLayoutX(); vertLayout.AddSpace(5); projectInputBox = new GUITextField(new LocEdString("Project path"), 70, false, "", GUIOption.FixedWidth(398)); projectInputBox.Value = EditorSettings.LastOpenProject; GUIButton openBtn = new GUIButton(new LocEdString("Open"), GUIOption.FixedWidth(75)); openBtn.OnClick += OpenProject; firstRow.AddSpace(5); firstRow.AddElement(projectInputBox); firstRow.AddSpace(15); firstRow.AddElement(openBtn); firstRow.AddSpace(5); GUILabel recentProjectsLabel = new GUILabel(new LocEdString("Recent projects:")); secondRow.AddSpace(5); secondRow.AddElement(recentProjectsLabel); secondRow.AddFlexibleSpace(); GUIButton browseBtn = new GUIButton(new LocEdString("Browse"), GUIOption.FixedWidth(75)); browseBtn.OnClick += BrowseClicked; secondRow.AddElement(browseBtn); secondRow.AddSpace(5); thirdRow.AddSpace(5); GUIPanel recentProjectsPanel = thirdRow.AddPanel(); thirdRow.AddSpace(15); GUILayoutY thirdRowVertical = thirdRow.AddLayoutY(); GUIButton createBtn = new GUIButton(new LocEdString("Create new"), GUIOption.FixedWidth(75)); createBtn.OnClick += CreateClicked; thirdRowVertical.AddElement(createBtn); thirdRowVertical.AddFlexibleSpace(); thirdRow.AddSpace(5); recentProjectsArea = new GUIScrollArea(GUIOption.FixedWidth(385), GUIOption.FixedHeight(170)); GUILayoutX recentProjectsLayout = recentProjectsPanel.AddLayoutX(); recentProjectsLayout.AddSpace(10); GUILayoutY recentProjectsPanelY = recentProjectsLayout.AddLayoutY(); recentProjectsPanelY.AddSpace(5); recentProjectsPanelY.AddElement(recentProjectsArea); recentProjectsPanelY.AddSpace(5); recentProjectsLayout.AddFlexibleSpace(); GUIPanel scrollAreaBgPanel = recentProjectsPanel.AddPanel(1); GUITexture scrollAreaBgTex = new GUITexture(null, true, EditorStylesInternal.ScrollAreaBg); scrollAreaBgPanel.AddElement(scrollAreaBgTex); autoLoadToggle = new GUIToggle(""); autoLoadToggle.Value = EditorSettings.AutoLoadLastProject; GUILabel autoLoadLabel = new GUILabel(new LocEdString("Automatically load last open project")); GUIButton cancelBtn = new GUIButton(new LocEdString("Cancel"), GUIOption.FixedWidth(75)); cancelBtn.OnClick += CancelClicked; fourthRow.AddSpace(5); fourthRow.AddElement(autoLoadToggle); fourthRow.AddElement(autoLoadLabel); fourthRow.AddFlexibleSpace(); fourthRow.AddElement(cancelBtn); fourthRow.AddSpace(5); RefreshRecentProjects(); }
/// <summary> /// Creates GUI elements required for displaying <see cref="SceneObject"/> fields like name, prefab data and /// transform (position, rotation, scale). Assumes that necessary inspector scroll area layout has already been /// created. /// </summary> private void CreateSceneObjectFields() { GUIPanel sceneObjectPanel = inspectorLayout.AddPanel(); sceneObjectPanel.SetHeight(GetTitleBounds().height); GUILayoutY sceneObjectLayout = sceneObjectPanel.AddLayoutY(); sceneObjectLayout.SetPosition(PADDING, PADDING); GUIPanel sceneObjectBgPanel = sceneObjectPanel.AddPanel(1); GUILayoutX nameLayout = sceneObjectLayout.AddLayoutX(); soActiveToggle = new GUIToggle(""); soActiveToggle.OnToggled += OnSceneObjectActiveStateToggled; GUILabel nameLbl = new GUILabel(new LocEdString("Name"), GUIOption.FixedWidth(50)); soNameInput = new GUITextBox(false, GUIOption.FlexibleWidth(180)); soNameInput.Text = activeSO.Name; soNameInput.OnChanged += OnSceneObjectRename; soNameInput.OnConfirmed += OnModifyConfirm; soNameInput.OnFocusLost += OnModifyConfirm; nameLayout.AddElement(soActiveToggle); nameLayout.AddSpace(3); nameLayout.AddElement(nameLbl); nameLayout.AddElement(soNameInput); nameLayout.AddFlexibleSpace(); GUILayoutX mobilityLayout = sceneObjectLayout.AddLayoutX(); GUILabel mobilityLbl = new GUILabel(new LocEdString("Mobility"), GUIOption.FixedWidth(50)); soMobility = new GUIEnumField(typeof(ObjectMobility), "", 0, GUIOption.FixedWidth(85)); soMobility.Value = (ulong)activeSO.Mobility; soMobility.OnSelectionChanged += value => activeSO.Mobility = (ObjectMobility)value; mobilityLayout.AddElement(mobilityLbl); mobilityLayout.AddElement(soMobility); soPrefabLayout = sceneObjectLayout.AddLayoutX(); soPos = new GUIVector3Field(new LocEdString("Position"), 50); sceneObjectLayout.AddElement(soPos); soPos.OnChanged += OnPositionChanged; soPos.OnConfirmed += OnModifyConfirm; soPos.OnFocusLost += OnModifyConfirm; soRot = new GUIVector3Field(new LocEdString("Rotation"), 50); sceneObjectLayout.AddElement(soRot); soRot.OnChanged += OnRotationChanged; soRot.OnConfirmed += OnModifyConfirm; soRot.OnFocusLost += OnModifyConfirm; soScale = new GUIVector3Field(new LocEdString("Scale"), 50); sceneObjectLayout.AddElement(soScale); soScale.OnChanged += OnScaleChanged; soScale.OnConfirmed += OnModifyConfirm; soScale.OnFocusLost += OnModifyConfirm; sceneObjectLayout.AddFlexibleSpace(); GUITexture titleBg = new GUITexture(null, EditorStylesInternal.InspectorTitleBg); sceneObjectBgPanel.AddElement(titleBg); }
/// <inheritdoc/> protected internal override void Initialize() { Animation animation = (Animation)InspectedObject; drawer.AddDefault(animation); // Morph shapes Renderable renderable = animation.SceneObject.GetComponent <Renderable>(); MorphShapes morphShapes = renderable?.Mesh.Value?.MorphShapes; if (morphShapes != null) { GUIToggle morphShapesToggle = new GUIToggle(new LocEdString("Morph shapes"), EditorStyles.Foldout); Layout.AddElement(morphShapesToggle); GUILayoutY channelsLayout = Layout.AddLayoutY(); morphShapesToggle.OnToggled += x => { channelsLayout.Active = x; Persistent.SetBool("Channels_Expanded", x); }; channelsLayout.Active = Persistent.GetBool("Channels_Expanded"); MorphChannel[] channels = morphShapes.Channels; for (int i = 0; i < channels.Length; i++) { GUILayoutY channelLayout = channelsLayout.AddLayoutY(); GUILayoutX channelTitleLayout = channelLayout.AddLayoutX(); channelLayout.AddSpace(5); GUILayoutY channelContentLayout = channelLayout.AddLayoutY(); string channelName = channels[i].Name; GUIToggle channelNameField = new GUIToggle(channelName, EditorStyles.Expand, GUIOption.FlexibleWidth()); channelTitleLayout.AddSpace(15); // Indent channelTitleLayout.AddElement(channelNameField); channelTitleLayout.AddFlexibleSpace(); channelNameField.OnToggled += x => { channelContentLayout.Active = x; Persistent.SetBool(channelName + "_Expanded", x); }; channelContentLayout.Active = Persistent.GetBool(channelName + "_Expanded"); MorphShape[] shapes = channels[i].Shapes; for (int j = 0; j < shapes.Length; j++) { GUILayoutX shapeLayout = channelContentLayout.AddLayoutX(); channelContentLayout.AddSpace(5); LocString nameString = new LocString("[{0}]. {1}"); nameString.SetParameter(0, j.ToString()); nameString.SetParameter(1, shapes[j].Name); GUILabel shapeNameField = new GUILabel(shapes[j].Name); LocString weightString = new LocEdString("Weight: {0}"); weightString.SetParameter(0, shapes[j].Weight.ToString()); GUILabel weightField = new GUILabel(weightString); shapeLayout.AddSpace(30); // Indent shapeLayout.AddElement(shapeNameField); shapeLayout.AddFlexibleSpace(); shapeLayout.AddElement(weightField); } } } }