void OnGUI() { float BOX_WIDTH = Screen.width - SPACE_LEFT * 2; float BOX_HEIGHT = Screen.height - SPACE_TOP * 2; float BUTTON_HEIGHT = (BOX_WIDTH - 200f) / 24f; Rect rect = new Rect(SPACE_LEFT, SPACE_TOP, BOX_WIDTH, BOX_HEIGHT); GUI.DrawTexture(rect, background); GUI.Box(rect, ""); { GUILayout.BeginArea(rect, ""); { #region LINE 1 GUILayout.BeginHorizontal(GUILayout.Height(BOX_HEIGHT / 3)); { GUILayout.FlexibleSpace(); foreach (PlayerControllerPhom p in GameModelPhom.ListPlayer) { GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); { float contentWidth = BOX_WIDTH - 100f; GUILayout.Space(30f); GUILayout.Label(p.username, GUILayout.Width(100f)); GUILayout.TextField(playerPick[p.slotServer] == null ? "" : playerPick[p.slotServer], GUILayout.Width(contentWidth - 150f - (BUTTON_HEIGHT * 2))); if (GUILayout.Button("CLEAR", new GUILayoutOption[] { GUILayout.Width(BUTTON_HEIGHT * 2) })) { playerPick[p.slotServer] = ""; } } GUILayout.EndHorizontal(); } GUILayout.BeginVertical(); } } GUILayout.EndHorizontal(); #endregion GUILayout.FlexibleSpace(); #region LINE 2 GUILayout.BeginHorizontal(GUILayout.Height(BOX_HEIGHT / 3)); { float contentWidth = BOX_WIDTH - 20f; GUILayout.BeginVertical(GUILayout.Width(contentWidth / 4)); { #region if (GameModelPhom.CurrentState > GameModelPhom.EGameState.deal && GameManager.Instance.mInfo.role >= User.ERole.Tester) { //GUILayout.FlexibleSpace(); //GUILayout.BeginHorizontal(GUILayout.Width(BOX_WIDTH - 200f)); GUILayout.Space(BUTTON_HEIGHT * 2); if (GUILayout.Button("YÊU CẦU ĐÁNH BÀI", new GUILayoutOption[] { GUILayout.Width(BUTTON_HEIGHT * 4), GUILayout.Height(BUTTON_HEIGHT) })) { OnClickRequestHandRobot(); } if (GUILayout.Button("YÊU CẦU BỐC BÀI", new GUILayoutOption[] { GUILayout.Width(BUTTON_HEIGHT * 4), GUILayout.Height(BUTTON_HEIGHT) })) { IS_TYPE_FORCE_ROBOT = false; } //GUILayout.EndHorizontal(); } else { GUILayout.Label(" ", GUILayout.Height(BUTTON_HEIGHT)); } #endregion } GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.Width(contentWidth / 3)); { string[] lst = strPick.Split(" ".ToCharArray(), StringSplitOptions.None); GUILayout.Label("BẠN ĐANG CHỌN: " + (lst.Length - 1) + " PhomCard.", GUILayout.Width(contentWidth / 3)); GUILayout.TextField(strPick); if (GUILayout.Button("CLEAR", GUILayout.Height(BUTTON_HEIGHT))) { strPick = ""; } foreach (PlayerControllerPhom p in GameModelPhom.ListPlayer) { if (GUILayout.Button("SET TO " + p.username, GUILayout.Height(BUTTON_HEIGHT))) { playerPick[p.slotServer] = strPick; strPick = ""; lastPicks.Clear(); } } } GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.Width(contentWidth / 3)); { GUILayout.Label(" "); if (GUILayout.Button("ĐÃ XONG", new GUILayoutOption[] { GUILayout.Width(contentWidth / 3 / 2), GUILayout.Height(contentWidth / 3 / 2) })) { OnClickDone(); lastPicks.Clear(); } } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); #endregion GUILayout.FlexibleSpace(); #region LINE 3 GUILayout.BeginHorizontal(GUILayout.Height(BOX_HEIGHT / 3)); { int index = 0; for (int i = 0; i < 13; i++) { GUILayout.BeginVertical(); for (int j = 0; j < 4; j++) { string str = GameModelPhom.game.cardController.Deck.PeekCard(index).ToString(); if (strPick.IndexOf(str) >= 0) { str = ""; } if (IS_TYPE_FORCE_ROBOT == false) { if (cardPlaying.Find(c => c.CardId == index) != null) { str = ""; } } else { if (GameModelPhom.CurrentState >= GameModelPhom.EGameState.deal && GameModelPhom.GetNextPlayer(GameModelPhom.IndexInTurn).mCardHand.Find(c => c.CardId == index) == null) { str = ""; } } if (Array.TrueForAll <string>(playerPick, p => p == null || (p != null && p.IndexOf(str) == -1))) { if (GUILayout.Button(str, new GUILayoutOption[] { GUILayout.Width(BUTTON_HEIGHT * 2), GUILayout.Height(BUTTON_HEIGHT) })) { if (string.IsNullOrEmpty(str) == false && ((GameModelPhom.CurrentState >= GameModelPhom.EGameState.deal) ? GameManager.GAME == EGame.Phom ? strPick.Split(" ".ToCharArray(), StringSplitOptions.None).Length <= 1 : strPick.Split(" ".ToCharArray(), StringSplitOptions.None).Length <= MAX_CARD_ON_HAND : strPick.Split(" ".ToCharArray(), StringSplitOptions.None).Length <= MAX_CARD_ON_HAND) ) { if (!lastPicks.Contains(index)) { lastPicks.Add(index); } lastPick = index; strPick += str + " "; } } } else { GUILayout.Button("", new GUILayoutOption[] { GUILayout.Width(BUTTON_HEIGHT * 2), GUILayout.Height(BUTTON_HEIGHT) }); } index++; } GUILayout.EndVertical(); } } GUILayout.EndHorizontal(); #endregion } GUILayout.EndArea(); } }
private void RenderControllerList(SerializedProperty controllerList) { if (thisProfile.ControllerVisualizationSettings.Length != controllerList.arraySize) { return; } EditorGUILayout.Space(); if (GUILayout.Button(ControllerAddButtonContent, EditorStyles.miniButton)) { controllerList.InsertArrayElementAtIndex(controllerList.arraySize); var index = controllerList.arraySize - 1; var controllerSetting = controllerList.GetArrayElementAtIndex(index); var mixedRealityControllerMappingDescription = controllerSetting.FindPropertyRelative("description"); mixedRealityControllerMappingDescription.stringValue = typeof(GenericJoystickController).Name; var mixedRealityControllerHandedness = controllerSetting.FindPropertyRelative("handedness"); mixedRealityControllerHandedness.intValue = 1; serializedObject.ApplyModifiedProperties(); thisProfile.ControllerVisualizationSettings[index].ControllerType.Type = typeof(GenericJoystickController); return; } for (int i = 0; i < controllerList.arraySize; i++) { EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUIUtility.labelWidth = 64f; EditorGUIUtility.fieldWidth = 64f; var controllerSetting = controllerList.GetArrayElementAtIndex(i); var mixedRealityControllerMappingDescription = controllerSetting.FindPropertyRelative("description"); bool hasValidType = thisProfile.ControllerVisualizationSettings[i].ControllerType != null && thisProfile.ControllerVisualizationSettings[i].ControllerType.Type != null; mixedRealityControllerMappingDescription.stringValue = hasValidType ? thisProfile.ControllerVisualizationSettings[i].ControllerType.Type.Name.ToProperCase() : "Undefined Controller"; serializedObject.ApplyModifiedProperties(); var mixedRealityControllerHandedness = controllerSetting.FindPropertyRelative("handedness"); EditorGUILayout.LabelField($"{mixedRealityControllerMappingDescription.stringValue} {((Handedness)mixedRealityControllerHandedness.intValue).ToString().ToProperCase()} Hand"); EditorGUIUtility.fieldWidth = defaultFieldWidth; EditorGUIUtility.labelWidth = defaultLabelWidth; if (GUILayout.Button(ControllerMinusButtonContent, EditorStyles.miniButtonRight, GUILayout.Width(24f))) { controllerList.DeleteArrayElementAtIndex(i); EditorGUILayout.EndHorizontal(); GUILayout.EndVertical(); return; } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(controllerSetting.FindPropertyRelative("controllerType")); EditorGUILayout.PropertyField(controllerSetting.FindPropertyRelative("controllerVisualizationType")); if (!hasValidType) { EditorGUILayout.HelpBox("A controller type must be defined!", MessageType.Error); } var handednessValue = mixedRealityControllerHandedness.intValue - 1; // Reset in case it was set to something other than left or right. if (handednessValue < 0 || handednessValue > 1) { handednessValue = 0; } EditorGUI.BeginChangeCheck(); handednessValue = EditorGUILayout.IntPopup(new GUIContent(mixedRealityControllerHandedness.displayName, mixedRealityControllerHandedness.tooltip), handednessValue, HandednessSelections, null); if (EditorGUI.EndChangeCheck()) { mixedRealityControllerHandedness.intValue = handednessValue + 1; } var overrideModel = controllerSetting.FindPropertyRelative("overrideModel"); var overrideModelPrefab = overrideModel.objectReferenceValue as GameObject; var controllerUseDefaultModelOverride = controllerSetting.FindPropertyRelative("useDefaultModel"); EditorGUILayout.PropertyField(controllerUseDefaultModelOverride); if (controllerUseDefaultModelOverride.boolValue && overrideModelPrefab != null) { EditorGUILayout.HelpBox("When default model is used, the override model will only be used if the default model cannot be loaded from the driver.", MessageType.Warning); } EditorGUI.BeginChangeCheck(); overrideModelPrefab = EditorGUILayout.ObjectField(new GUIContent(overrideModel.displayName, "If no override model is set, the global model is used."), overrideModelPrefab, typeof(GameObject), false) as GameObject; if (EditorGUI.EndChangeCheck() && CheckVisualizer(overrideModelPrefab)) { overrideModel.objectReferenceValue = overrideModelPrefab; } EditorGUI.indentLevel--; } }
void OnGUI() { //if (isPaused) //{ // //If the button is pressed then isPaused becomes false so the game resumes. (Translated from French) // if (GUI.Button(new Rect(Screen.width / 2 - 60, Screen.height / 2 - 60, 100, 40), "Continue")) // { // isPaused = false; // } // //If the button is presser then we completely close the game or load the scene "Main Menu" (Translated from French) // //In the case of the button to leave it is necessary to increase its postion Y so that it is lower. (Translated from French) // if (GUI.Button(new Rect(Screen.width / 2 - 90, Screen.height / 2 + 00, 150, 40), "Load a different level")) // { // // Application.Quit(); // Application.LoadLevel(""); //Loads a different level // } //if (background != null) // GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), background); //if (LOGO != null && clicked != "about") // GUI.DrawTexture(new Rect((Screen.width / 2) - 100, 30, 200, 200), LOGO); GUI.skin = guiSkin; if (clicked == "" && isPaused) { WindowRect = GUI.Window(0, WindowRect, menuFunc, "Main Menu"); } if (clicked == "options") { WindowRect = GUI.Window(1, WindowRect, optionsFunc, "Options"); } //else if (clicked == "about") //{ // GUI.Box(new Rect(0, 0, Screen.width, Screen.height), MessageDisplayOnAbout); //} else if (clicked == "resolution") { GUILayout.BeginVertical(); for (int x = 0; x < Screen.resolutions.Length; x++) { if (GUILayout.Button(Screen.resolutions[x].width + "X" + Screen.resolutions[x].height)) { Screen.SetResolution(Screen.resolutions[x].width, Screen.resolutions[x].height, true); } } GUILayout.EndVertical(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Back")) { clicked = "options"; } GUILayout.EndHorizontal(); } //if (GUI.Button(new Rect(Screen.width / 2 - 60, Screen.height / 2 + 60, 100, 40), "Settings")) //{ // if (GUI.Button(new Rect(Screen.width / 2, Screen.height / 2 + 60, 100, 40), "SFX volume")) // { // } // if (GUI.Button(new Rect(Screen.width / 2, Screen.height / 2, 100, 40), "Music volume")) // { // } // if (GUI.Button(new Rect(Screen.width / 2, Screen.height / 2 - 60, 150, 40), "Change Background Music")) // { // } //} //if (GUI.Button(new Rect(Screen.width / 2 - 60, Screen.height / 2 + 120, 100, 40), "Quit")) //{ // Application.Quit(); // //Application.LoadLevel(""); //} }
/// <summary> /// Draw the label's properties. /// </summary> protected override bool ShouldDrawProperties() { mIsDynamic = false; mHasSymbols = false; mLabel = mWidget as UILabel; GUILayout.BeginHorizontal(); #if DYNAMIC_FONT mFontType = (FontType)EditorGUILayout.EnumPopup(mFontType, "DropDown", GUILayout.Width(74f)); if (NGUIEditorTools.DrawPrefixButton("Font", GUILayout.Width(64f))) #else mFontType = FontType.NGUI; if (NGUIEditorTools.DrawPrefixButton("Font", GUILayout.Width(74f))) #endif { if (mFontType == FontType.NGUI) { var bmf = mLabel.font; if (bmf != null && bmf is UIFont) { ComponentSelector.Show <UIFont>(OnNGUIFont); } else { ComponentSelector.Show <NGUIFont>(OnNGUIFont); } } else { ComponentSelector.Show <Font>(OnUnityFont, new string[] { ".ttf", ".otf" }); } } bool isValid = false; SerializedProperty fnt = null; SerializedProperty ttf = null; GUI.changed = false; if (mFontType == FontType.NGUI) { fnt = NGUIEditorTools.DrawProperty("", serializedObject, "mFont", GUILayout.MinWidth(40f)); // Legacy font support if (fnt.objectReferenceValue != null && fnt.objectReferenceValue is GameObject) { fnt.objectReferenceValue = (fnt.objectReferenceValue as GameObject).GetComponent <UIFont>(); } if (fnt.objectReferenceValue != null) { if (GUI.changed) { serializedObject.FindProperty("mTrueTypeFont").objectReferenceValue = null; } NGUISettings.ambigiousFont = fnt.objectReferenceValue; isValid = true; } } else { ttf = NGUIEditorTools.DrawProperty("", serializedObject, "mTrueTypeFont", GUILayout.MinWidth(40f)); if (ttf.objectReferenceValue != null) { if (GUI.changed) { serializedObject.FindProperty("mFont").objectReferenceValue = null; } NGUISettings.ambigiousFont = ttf.objectReferenceValue; isValid = true; } } GUILayout.EndHorizontal(); #if UNITY_5_6 if (mFontType == FontType.Unity) { EditorGUILayout.HelpBox("Dynamic fonts suffer from issues in Unity itself where your characters may disappear, get garbled, or just not show at times. Use this feature at your own risk.\n\n" + "When you do run into such issues, please submit a Bug Report to Unity via Help -> Report a Bug (as this is will be a Unity bug, not an NGUI one).", MessageType.Warning); } #endif NGUIEditorTools.DrawProperty("Material", serializedObject, "mMat"); EditorGUI.BeginDisabledGroup(!isValid); { var dynFont = (ttf != null) ? ttf.objectReferenceValue as Font : null; var bmFont = (fnt != null) ? fnt.objectReferenceValue : null; var bm = bmFont as INGUIFont; if (bm != null && bm.isDynamic) { dynFont = bm.dynamicFont; mHasSymbols = bm.hasSymbols; bm = null; } if (dynFont != null) { mIsDynamic = true; GUILayout.BeginHorizontal(); { EditorGUI.BeginDisabledGroup((ttf != null) ? ttf.hasMultipleDifferentValues : fnt.hasMultipleDifferentValues); var prop = NGUIEditorTools.DrawProperty("Font Size", serializedObject, "mFontSize", GUILayout.Width(142f)); NGUISettings.fontSize = prop.intValue; prop = NGUIEditorTools.DrawProperty("", serializedObject, "mFontStyle", GUILayout.MinWidth(40f)); NGUISettings.fontStyle = (FontStyle)prop.intValue; NGUIEditorTools.DrawPadding(); EditorGUI.EndDisabledGroup(); } GUILayout.EndHorizontal(); } else if (bmFont != null) { GUILayout.BeginHorizontal(); var prop = NGUIEditorTools.DrawProperty("Font Size", serializedObject, "mFontSize", GUILayout.Width(142f)); EditorGUI.BeginDisabledGroup(true); if (!serializedObject.isEditingMultipleObjects) { var printed = mLabel.finalFontSize; var def = mLabel.defaultFontSize; if (mLabel.overflowMethod == UILabel.Overflow.ShrinkContent && printed != mLabel.fontSize) { GUILayout.Label(" Printed: " + printed); } else if (printed != def) { GUILayout.Label(" Default: " + def); } } EditorGUI.EndDisabledGroup(); NGUISettings.fontSize = prop.intValue; GUILayout.EndHorizontal(); } bool ww = GUI.skin.textField.wordWrap; GUI.skin.textField.wordWrap = true; SerializedProperty sp = serializedObject.FindProperty("mText"); if (sp.hasMultipleDifferentValues) { NGUIEditorTools.DrawProperty("", sp, GUILayout.Height(128f)); } else { GUIStyle style = new GUIStyle(EditorStyles.textField); style.wordWrap = true; float height = style.CalcHeight(new GUIContent(sp.stringValue), Screen.width - 100f); bool offset = true; if (height > 90f) { offset = false; height = style.CalcHeight(new GUIContent(sp.stringValue), Screen.width - 20f); } else { GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayout.Width(76f)); GUILayout.Space(3f); GUILayout.Label("Text"); GUILayout.EndVertical(); GUILayout.BeginVertical(); } Rect rect = EditorGUILayout.GetControlRect(GUILayout.Height(height)); GUI.changed = false; string text = EditorGUI.TextArea(rect, sp.stringValue, style); if (GUI.changed) { sp.stringValue = text; } if (offset) { GUILayout.EndVertical(); GUILayout.EndHorizontal(); } } GUI.skin.textField.wordWrap = ww; NGUIEditorTools.DrawPaddedProperty("Modifier", serializedObject, "mModifier"); SerializedProperty ov = NGUIEditorTools.DrawPaddedProperty("Overflow", serializedObject, "mOverflow"); NGUISettings.overflowStyle = (UILabel.Overflow)ov.intValue; if (NGUISettings.overflowStyle == UILabel.Overflow.ClampContent) { NGUIEditorTools.DrawProperty("Use Ellipsis", serializedObject, "mOverflowEllipsis", GUILayout.Width(110f)); } if (NGUISettings.overflowStyle == UILabel.Overflow.ResizeFreely) { GUILayout.BeginHorizontal(); SerializedProperty s = NGUIEditorTools.DrawPaddedProperty("Max Width", serializedObject, "mOverflowWidth"); if (s != null) { if (s.intValue < 0) { s.intValue = 0; } if (s.intValue == 0) { GUILayout.Label("unlimited"); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); s = NGUIEditorTools.DrawPaddedProperty("Max Height", serializedObject, "mOverflowHeight"); if (s != null) { if (s.intValue < 0) { s.intValue = 0; } if (s.intValue == 0) { GUILayout.Label("unlimited"); } } GUILayout.EndHorizontal(); } NGUIEditorTools.DrawPaddedProperty("Alignment", serializedObject, "mAlignment"); if (dynFont != null) { NGUIEditorTools.DrawPaddedProperty("Keep crisp", serializedObject, "keepCrispWhenShrunk"); } if (bm != null) { EditorGUI.BeginDisabledGroup(bm.packedFontShader); } else { EditorGUI.BeginDisabledGroup(false); } GUILayout.BeginHorizontal(); SerializedProperty gr = NGUIEditorTools.DrawProperty("Gradient", serializedObject, "mApplyGradient", GUILayout.Width(95f)); EditorGUI.BeginDisabledGroup(!gr.hasMultipleDifferentValues && !gr.boolValue); { NGUIEditorTools.SetLabelWidth(30f); NGUIEditorTools.DrawProperty("Top", serializedObject, "mGradientTop", GUILayout.MinWidth(40f)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); NGUIEditorTools.SetLabelWidth(50f); GUILayout.Space(79f); NGUIEditorTools.DrawProperty("Bottom", serializedObject, "mGradientBottom", GUILayout.MinWidth(40f)); NGUIEditorTools.SetLabelWidth(80f); } EditorGUI.EndDisabledGroup(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Effect", GUILayout.Width(76f)); sp = NGUIEditorTools.DrawProperty("", serializedObject, "mEffectStyle", GUILayout.MinWidth(16f)); EditorGUI.BeginDisabledGroup(!sp.hasMultipleDifferentValues && !sp.boolValue); { NGUIEditorTools.DrawProperty("", serializedObject, "mEffectColor", GUILayout.MinWidth(10f)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(" ", GUILayout.Width(56f)); NGUIEditorTools.SetLabelWidth(20f); NGUIEditorTools.DrawProperty("X", serializedObject, "mEffectDistance.x", GUILayout.MinWidth(40f)); NGUIEditorTools.DrawProperty("Y", serializedObject, "mEffectDistance.y", GUILayout.MinWidth(40f)); NGUIEditorTools.DrawPadding(); NGUIEditorTools.SetLabelWidth(80f); } } EditorGUI.EndDisabledGroup(); GUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); sp = NGUIEditorTools.DrawProperty("Float spacing", serializedObject, "mUseFloatSpacing", GUILayout.Width(100f)); if (!sp.boolValue) { GUILayout.BeginHorizontal(); GUILayout.Label("Spacing", GUILayout.Width(56f)); NGUIEditorTools.SetLabelWidth(20f); NGUIEditorTools.DrawProperty("X", serializedObject, "mSpacingX", GUILayout.MinWidth(40f)); NGUIEditorTools.DrawProperty("Y", serializedObject, "mSpacingY", GUILayout.MinWidth(40f)); NGUIEditorTools.DrawPadding(); NGUIEditorTools.SetLabelWidth(80f); GUILayout.EndHorizontal(); } else { GUILayout.BeginHorizontal(); GUILayout.Label("Spacing", GUILayout.Width(56f)); NGUIEditorTools.SetLabelWidth(20f); NGUIEditorTools.DrawProperty("X", serializedObject, "mFloatSpacingX", GUILayout.MinWidth(40f)); NGUIEditorTools.DrawProperty("Y", serializedObject, "mFloatSpacingY", GUILayout.MinWidth(40f)); NGUIEditorTools.DrawPadding(); NGUIEditorTools.SetLabelWidth(80f); GUILayout.EndHorizontal(); } NGUIEditorTools.DrawProperty("Max Lines", serializedObject, "mMaxLineCount", GUILayout.Width(110f)); GUILayout.BeginHorizontal(); sp = NGUIEditorTools.DrawProperty("BBCode", serializedObject, "mEncoding", GUILayout.Width(100f)); EditorGUI.BeginDisabledGroup(!mHasSymbols || !sp.boolValue); NGUIEditorTools.SetLabelWidth(60f); NGUIEditorTools.DrawPaddedProperty("Symbols", serializedObject, "mSymbols"); NGUIEditorTools.SetLabelWidth(80f); EditorGUI.EndDisabledGroup(); GUILayout.EndHorizontal(); } EditorGUI.EndDisabledGroup(); return(isValid); }
protected override void WindowGUI(int windowID) { GUILayout.BeginVertical(); if (core.target.PositionTargetExists) { var ASL = core.vessel.mainBody.TerrainAltitude(core.target.targetLatitude, core.target.targetLongitude); GUILayout.Label(Localizer.Format("#MechJeb_LandingGuidance_label1"));//Target coordinates: GUILayout.BeginHorizontal(); core.target.targetLatitude.DrawEditGUI(EditableAngle.Direction.NS); if (GUILayout.Button("▲")) { moveByMeter(ref core.target.targetLatitude, 10, ASL); } GUILayout.Label("10m"); if (GUILayout.Button("▼")) { moveByMeter(ref core.target.targetLatitude, -10, ASL); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); core.target.targetLongitude.DrawEditGUI(EditableAngle.Direction.EW); if (GUILayout.Button("◄")) { moveByMeter(ref core.target.targetLongitude, -10, ASL); } GUILayout.Label("10m"); if (GUILayout.Button("►")) { moveByMeter(ref core.target.targetLongitude, 10, ASL); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("ASL: " + MuUtils.ToSI(ASL, -1, 4) + "m"); GUILayout.Label(core.target.targetBody.GetExperimentBiomeSafe(core.target.targetLatitude, core.target.targetLongitude)); GUILayout.EndHorizontal(); } else { if (GUILayout.Button(Localizer.Format("#MechJeb_LandingGuidance_button1")))//Enter target coordinates { core.target.SetPositionTarget(mainBody, core.target.targetLatitude, core.target.targetLongitude); } } if (GUILayout.Button(Localizer.Format("#MechJeb_LandingGuidance_button2"))) { core.target.PickPositionTargetOnMap(); //Pick target on map } List <LandingSite> availableLandingSites = landingSites.Where(p => p.body == mainBody).ToList(); if (availableLandingSites.Any()) { GUILayout.BeginHorizontal(); landingSiteIdx = GuiUtils.ComboBox.Box(landingSiteIdx, availableLandingSites.Select(p => p.name).ToArray(), this); if (GUILayout.Button("Set", GUILayout.ExpandWidth(false))) { core.target.SetPositionTarget(mainBody, availableLandingSites[landingSiteIdx].latitude, availableLandingSites[landingSiteIdx].longitude); } GUILayout.EndHorizontal(); } DrawGUITogglePredictions(); if (core.landing != null) { GUILayout.Label(Localizer.Format("#MechJeb_LandingGuidance_label2"));//Autopilot: predictor.maxOrbits = core.landing.enabled ? 0.5 : 4; predictor.noSkipToFreefall = !core.landing.enabled; if (core.landing.enabled) { if (GUILayout.Button(Localizer.Format("#MechJeb_LandingGuidance_button3"))) { core.landing.StopLanding(); //Abort autoland } } else { GUILayout.BeginHorizontal(); if (!core.target.PositionTargetExists || vessel.LandedOrSplashed) { GUI.enabled = false; } if (GUILayout.Button(Localizer.Format("#MechJeb_LandingGuidance_button4"))) { core.landing.LandAtPositionTarget(this); //Land at target } GUI.enabled = !vessel.LandedOrSplashed; if (GUILayout.Button(Localizer.Format("#MechJeb_LandingGuidance_button5"))) { core.landing.LandUntargeted(this); //Land somewhere } GUI.enabled = true; GUILayout.EndHorizontal(); } GuiUtils.SimpleTextBox(Localizer.Format("#MechJeb_LandingGuidance_label3"), core.landing.touchdownSpeed, "m/s", 35);//Touchdown speed: if (core.landing != null) { core.node.autowarp = GUILayout.Toggle(core.node.autowarp, Localizer.Format("#MechJeb_LandingGuidance_checkbox1")); //Auto-warp } core.landing.deployGears = GUILayout.Toggle(core.landing.deployGears, Localizer.Format("#MechJeb_LandingGuidance_checkbox2")); //Deploy Landing Gear GuiUtils.SimpleTextBox(Localizer.Format("#MechJeb_LandingGuidance_label4"), core.landing.limitGearsStage, "", 35); //"Stage Limit:" core.landing.deployChutes = GUILayout.Toggle(core.landing.deployChutes, Localizer.Format("#MechJeb_LandingGuidance_checkbox3")); //Deploy Parachutes predictor.deployChutes = core.landing.deployChutes; GuiUtils.SimpleTextBox(Localizer.Format("#MechJeb_LandingGuidance_label5"), core.landing.limitChutesStage, "", 35); //Stage Limit: predictor.limitChutesStage = core.landing.limitChutesStage; core.landing.rcsAdjustment = GUILayout.Toggle(core.landing.rcsAdjustment, Localizer.Format("#MechJeb_LandingGuidance_checkbox4")); //Use RCS for small adjustment if (core.landing.enabled) { GUILayout.Label(Localizer.Format("#MechJeb_LandingGuidance_label6") + core.landing.status); //Status: GUILayout.Label(Localizer.Format("#MechJeb_LandingGuidance_label7") + (core.landing.CurrentStep != null ? core.landing.CurrentStep.GetType().Name : "N/A")); //Step: GUILayout.Label(Localizer.Format("#MechJeb_LandingGuidance_label8") + (core.landing.descentSpeedPolicy != null ? core.landing.descentSpeedPolicy.GetType().Name : "N/A") + " (" + core.landing.UseAtmosphereToBrake().ToString() + ")"); //Mode //GUILayout.Label("DecEndAlt: " + core.landing.DecelerationEndAltitude().ToString("F2")); //var dragLength = mainBody.DragLength(core.landing.LandingAltitude, core.landing.vesselAverageDrag, vesselState.mass); //GUILayout.Label("Drag Length: " + ( dragLength < double.MaxValue ? dragLength.ToString("F2") : "infinite")); // //string parachuteInfo = core.landing.ParachuteControlInfo; //if (null != parachuteInfo) //{ // GUILayout.Label(parachuteInfo); //} } } GUILayout.EndVertical(); base.WindowGUI(windowID); }
protected override void OnInspectorGUIOverride() { if (m_spline == null) { return; } rotationSpeedProp.floatValue = EditorGUILayout.FloatField("Rotation Speed", rotationSpeedProp.floatValue); if (ConvergingSpline) { if (GUILayout.Button("Cancel")) { ConvergingSpline = null; } return; } GUILayout.BeginHorizontal(); { GUILayout.BeginVertical(); int curveIndex = (SelectedIndex - 1) / 3; if (GUILayout.Button("OUT -> Branch")) { CreateBranch(m_spline, SelectedIndex, false); } if (curveIndex == m_spline.CurveCount - 1 && m_spline.NextSpline == null) { if (m_spline.NextSpline == null) { if (GUILayout.Button("Append")) { SplineEditor.Append(m_spline); Selection.activeGameObject = m_spline.GetSplineControlPoints().Last().gameObject; } } } if (curveIndex == 0 && m_spline.PrevSpline == null) { if (m_spline.PrevSpline == null) { if (GUILayout.Button("Prepend")) { SplineEditor.Prepend(m_spline); Selection.activeGameObject = m_spline.GetSplineControlPoints().First().gameObject; } } } if (GUILayout.Button("Insert")) { SplineEditor.Insert(m_spline, SelectedIndex); Selection.activeGameObject = m_spline.GetSplineControlPoints().ElementAt(SelectedIndex + 3).gameObject; } GUILayout.EndVertical(); GUILayout.BeginVertical(); if (GUILayout.Button("Branch -> IN")) { CreateBranch(m_spline, SelectedIndex, true); } if (curveIndex == m_spline.CurveCount - 1 && m_spline.NextSpline == null) { if (m_spline.NextSpline == null) { if (SceneView.lastActiveSceneView != null && SceneView.lastActiveSceneView.camera) { if (GUILayout.Button("To Cam")) { SplineEditor.AppendThrough(m_spline, SceneView.lastActiveSceneView.camera.transform); Selection.activeGameObject = m_spline.GetSplineControlPoints().Last().gameObject; } } } } if (curveIndex == 0 && m_spline.PrevSpline == null) { if (m_spline.PrevSpline == null) { if (SceneView.lastActiveSceneView != null && SceneView.lastActiveSceneView.camera) { if (GUILayout.Button("To Cam")) { SplineEditor.PrependThrough(m_spline, SceneView.lastActiveSceneView.camera.transform); Selection.activeGameObject = m_spline.GetSplineControlPoints().First().gameObject; } } } } if (SelectedIndex >= 0 && curveIndex < m_spline.CurveCount) { if (GUILayout.Button("Remove")) { Remove(m_spline, SelectedIndex); } } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); if (SelectedIndex == 0 && m_spline.PrevSpline == null || SelectedIndex == m_spline.ControlPointCount - 1 && m_spline.NextSpline == null) { if (!m_spline.HasBranches(SelectedIndex)) { if (GUILayout.Button("Converge")) { if (m_spline.Loop) { EditorUtility.DisplayDialog("Unable to converge", "Unable to converge. Selected spline has loop.", "OK"); } else { ConvergingSpline = m_spline; } } } } if (SelectedIndex < m_spline.ControlPointCount && SelectedIndex >= 0) { if (m_spline.HasBranches(SelectedIndex)) { if (GUILayout.Button("Separate")) { Separate(m_spline, SelectedIndex); } } } if (GUILayout.Button("Align View To Point")) { if (SceneView.lastActiveSceneView != null) { SplineControlPoint controlPoint = (SplineControlPoint)target; SceneView.lastActiveSceneView.AlignViewToObject(controlPoint.transform); SceneView.lastActiveSceneView.Repaint(); } } base.OnInspectorGUIOverride(); }
void OnGUI() { if (Event.current.type == EventType.DragUpdated) { if (IsValidDragPayload()) { dragging = true; } } else if (Event.current.type == EventType.DragExited) { dragging = false; Repaint(); } else { if (currentDraggingValue != dragging) { currentDraggingValue = dragging; } } if (Event.current.type == EventType.Layout && deferredDroppedObjects != null) { HandleDroppedPayload(deferredDroppedObjects); deferredDroppedObjects = null; } if (HandleAssetsInResources()) { return; } GUILayout.BeginVertical(); DrawToolbar(); GUILayout.BeginHorizontal(); if (currentDraggingValue) { DrawDropZone(); } else { DrawSpriteList(); } if (settingsView.show || (spriteCollectionProxy != null && spriteCollectionProxy.Empty)) { settingsView.Draw(); } else if (fontView.Draw(selectedEntries)) { } else if (spriteSheetView.Draw(selectedEntries)) { } else { spriteView.Draw(selectedEntries); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); }
public override void DoWindowContents(Rect inRect) { // close on world map, on committed maps var mapState = RerollToolbox.GetStateForMap(); if (Find.World.renderer.wantedMode != WorldRenderMode.None || Find.CurrentMap == null || mapState.MapCommitted) { Close(); return; } float diceButtonSize = MapRerollController.Instance.WidgetSizeSetting; var buttonRect = new Rect((inRect.width - diceButtonSize) + Margin, -Margin, diceButtonSize, diceButtonSize); if (Widgets.ButtonImage(buttonRect, Resources.Textures.UIDiceActive)) { Close(); } var contentsRect = inRect.ContractedBy(ContentsPadding); Text.Anchor = TextAnchor.MiddleCenter; Text.Font = GameFont.Medium; var headerRect = new Rect(contentsRect.x, contentsRect.y, contentsRect.width, 30f); Widgets.Label(headerRect, "MapReroll_windowTitle".Translate()); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; var layoutRect = new Rect(contentsRect.x, contentsRect.y + headerRect.yMax, contentsRect.width, contentsRect.height - headerRect.yMax); GUILayout.BeginArea(layoutRect); GUILayout.BeginVertical(); var extraResourcesHeight = 0f; var separatorHeight = ContentsPadding + 1; var controlHeight = (layoutRect.height - (ControlSpacing * 2f + separatorHeight + extraResourcesHeight)) / 4f; balanceWidget.DrawLayout(controlHeight + extraResourcesHeight); GUILayout.Space(ControlSpacing); DoRerollTabButton(Resources.Textures.UIRerollMapOn, Resources.Textures.UIRerollMapOff, MapRerollUtility.WithCostSuffix("Reroll2_rerollMap", PaidOperationType.GeneratePreviews), null, controlHeight, () => { if (RerollToolbox.GetOperationCost(PaidOperationType.GeneratePreviews) > 0) { RerollToolbox.ChargeForOperation(PaidOperationType.GeneratePreviews); } Find.WindowStack.Add(new Dialog_MapPreviews()); }); GUILayout.Space(ControlSpacing); DoRerollTabButton(Resources.Textures.UIRerollGeysersOn, Resources.Textures.UIRerollGeysersOff, MapRerollUtility.WithCostSuffix("Reroll2_rerollGeysers", PaidOperationType.RerollGeysers), null, controlHeight, () => { if (!MapRerollController.Instance.GeyserRerollInProgress) { MapRerollController.Instance.RerollGeysers(); } else { Messages.Message("Reroll2_rerollInProgress".Translate(), MessageTypeDefOf.RejectInput); } }); DrawSeparator(separatorHeight); DoRerollTabButton(Resources.Textures.UICommitMapOn, Resources.Textures.UICommitMapOff, MapRerollUtility.WithCostSuffix("Reroll2_commitMap", PaidOperationType.RerollGeysers), "Reroll2_commitMap_tip".Translate(), controlHeight, () => { RerollToolbox.GetStateForMap().MapCommitted = true; MapRerollController.Instance.UIController.ResetCache(); }); GUILayout.EndVertical(); GUILayout.EndArea(); }
void OnGUIMapper() { TextAsset prevTextFile = mTextFileMapper; EditorGUIUtility.labelWidth = 80.0f; GUILayout.BeginHorizontal(); bool doCreate = false; if (mTextFileMapper == null) { GUI.backgroundColor = Color.green; doCreate = GUILayout.Button("Create", GUILayout.Width(76f)); GUI.backgroundColor = Color.white; mTextNameMapper = GUILayout.TextField(mTextNameMapper); } GUILayout.EndHorizontal(); if (mTextFileMapper != null) { mTextNameMapper = mTextFileMapper.name; mTextFilePathMapper = AssetDatabase.GetAssetPath(mTextFileMapper); } else if (!string.IsNullOrEmpty(mTextNameMapper)) { mTextFilePathMapper = Utility.GetSelectionFolder() + mTextNameMapper + ".txt"; } if (doCreate && !string.IsNullOrEmpty(mTextNameMapper)) { File.WriteAllText(mTextFilePathMapper, ""); AssetDatabase.Refresh(); mTextFileMapper = (TextAsset)AssetDatabase.LoadAssetAtPath(mTextFilePathMapper, typeof(TextAsset)); } GUILayout.BeginHorizontal(); GUILayout.Label("Select: "); mTextFileMapper = (TextAsset)EditorGUILayout.ObjectField(mTextFileMapper, typeof(TextAsset), false); GUILayout.EndHorizontal(); if (!string.IsNullOrEmpty(mTextFilePathMapper)) { GUILayout.Label("Path: " + mTextFilePathMapper); } else { GUILayout.Label("Path: <none>" + mTextFilePathMapper); } GUILayout.BeginVertical(GUI.skin.box); mGenerateScript = GUILayout.Toggle(mGenerateScript, "Generate Script"); if (mGenerateScript) { EditorGUIUtility.labelWidth = 46.0f; GUILayout.BeginHorizontal(); mGenerateScriptFolder = EditorGUILayout.TextField("Folder", mGenerateScriptFolder); if (GUILayout.Button("Browse", GUILayout.Width(55f))) { string path = EditorUtility.SaveFolderPanel("Select Directory", mGenerateScriptFolder, ""); if (!string.IsNullOrEmpty(path)) { mGenerateScriptFolder = path; } } GUILayout.EndHorizontal(); GUILayout.Label("Path: " + mGenerateScriptFolder + "/InputAction.cs"); } GUILayout.EndVertical(); GUILayout.Space(6f); GUILayout.BeginVertical(GUI.skin.box); if (mTextFileMapper != null) { if (prevTextFile != mTextFileMapper || mActions == null) { GetInputActions(mTextFileMapper); } //list actions int removeInd = -1; Regex r = new Regex("^[a-zA-Z0-9]*$"); for (int i = 0; i < mActions.Count; i++) { GUILayout.BeginHorizontal(); GUILayout.Label(i.ToString(), GUILayout.MaxWidth(20)); string text = GUILayout.TextField(mActions[i], 255); if (text.Length > 0 && (r.IsMatch(text) && !char.IsDigit(text[0]))) { mActions[i] = text; } if (GUILayout.Button("DEL", GUILayout.MaxWidth(40))) { removeInd = i; } GUILayout.EndHorizontal(); } if (removeInd != -1) { mActions.RemoveAt(removeInd); } if (GUILayout.Button("Add")) { mActions.Add("Unknown" + (mUnknownCount++)); } } GUILayout.EndVertical(); EditorGUIUtility.labelWidth = 0.0f; }
public override void OnInspectorGUI() { bool isEnabled = _dsp.IsInstantiated(); if (!isEnabled) { EditorGUILayout.LabelField("Press Play!", EditorStyles.centeredGreyMiniLabel); } GUILayout.BeginVertical(); // EVENTS GUI.enabled = isEnabled; EditorGUILayout.Space(); // bass if (GUILayout.Button("bass")) { _dsp.SendEvent(Hv_heavy_AudioLib.Event.Bass); } // checkpoint0 if (GUILayout.Button("checkpoint0")) { _dsp.SendEvent(Hv_heavy_AudioLib.Event.Checkpoint0); } // checkpoint1 if (GUILayout.Button("checkpoint1")) { _dsp.SendEvent(Hv_heavy_AudioLib.Event.Checkpoint1); } // checkpoint2 if (GUILayout.Button("checkpoint2")) { _dsp.SendEvent(Hv_heavy_AudioLib.Event.Checkpoint2); } // checkpoint3 if (GUILayout.Button("checkpoint3")) { _dsp.SendEvent(Hv_heavy_AudioLib.Event.Checkpoint3); } // drum1 if (GUILayout.Button("drum1")) { _dsp.SendEvent(Hv_heavy_AudioLib.Event.Drum1); } // drum2 if (GUILayout.Button("drum2")) { _dsp.SendEvent(Hv_heavy_AudioLib.Event.Drum2); } // engine if (GUILayout.Button("engine")) { _dsp.SendEvent(Hv_heavy_AudioLib.Event.Engine); } // fill1 if (GUILayout.Button("fill1")) { _dsp.SendEvent(Hv_heavy_AudioLib.Event.Fill1); } // fill2 if (GUILayout.Button("fill2")) { _dsp.SendEvent(Hv_heavy_AudioLib.Event.Fill2); } // finishline if (GUILayout.Button("finishline")) { _dsp.SendEvent(Hv_heavy_AudioLib.Event.Finishline); } // startendvol if (GUILayout.Button("startendvol")) { _dsp.SendEvent(Hv_heavy_AudioLib.Event.Startendvol); } // startstopseq if (GUILayout.Button("startstopseq")) { _dsp.SendEvent(Hv_heavy_AudioLib.Event.Startstopseq); } // wall if (GUILayout.Button("wall")) { _dsp.SendEvent(Hv_heavy_AudioLib.Event.Wall); } // PARAMETERS GUI.enabled = true; EditorGUILayout.Space(); EditorGUI.indentLevel++; // frequency GUILayout.BeginHorizontal(); float frequency = _dsp.GetFloatParameter(Hv_heavy_AudioLib.Parameter.Frequency); float newFrequency = EditorGUILayout.Slider("frequency", frequency, 0.0f, 1000.0f); if (frequency != newFrequency) { _dsp.SetFloatParameter(Hv_heavy_AudioLib.Parameter.Frequency, newFrequency); } GUILayout.EndHorizontal(); EditorGUI.indentLevel--; GUILayout.EndVertical(); }
void DrawMainWindow(int windowID) { //help button if (GUI.Button(new Rect(WindowPos.width - 23f, 2f, 20f, 18f), new GUIContent("?", "Help"))) { TCAManual.Toggle(); } if (TCA.Controllable) { //options button if (GUI.Button(new Rect(2f, 2f, 70f, 18f), new GUIContent("advanced", "Advanced configuration"), adv_options? Styles.enabled_button : Styles.normal_button)) { adv_options = !adv_options; } GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); //tca toggle var enabled_style = Styles.inactive_button; if (CFG.Enabled) { enabled_style = Styles.enabled_button; } else if (!VSL.LandedOrSplashed) { if (EnabledBlinker.On) { enabled_style = Styles.danger_button; } Status(0.1, "red", "<b>TCA is disabled</b>"); } if (GUILayout.Button("Enabled", enabled_style, GUILayout.Width(70))) { if (SQD == null) { TCA.ToggleTCA(); } else { SQD.Apply(tca => tca.ToggleTCA()); } } //squad mode switch SquadControls.Draw(); GUILayout.FlexibleSpace(); StatusString(); GUILayout.EndHorizontal(); SelectConfig_start(); AdvancedOptions(); AttitudeControls.Draw(); InOrbitControls.Draw(); OnPlanetControls.Draw(); NavigationControls.Draw(); MacroControls.Draw(); NavigationControls.WaypointList(); EnginesControl(); #if DEBUG DebugInfo(); // EnginesInfo(); #endif if (!string.IsNullOrEmpty(StatusMessage)) { if (GUILayout.Button(new GUIContent(StatusMessage, "Click to dismiss"), Styles.boxed_label, GUILayout.ExpandWidth(true)) || StatusEndTime > DateTime.MinValue && DateTime.Now > StatusEndTime) { StatusMessage = ""; } } SelectConfig_end(); GUILayout.EndVertical(); } else { GUILayout.Label("Vessel is Uncontrollable", Styles.label, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); } TooltipsAndDragWindow(WindowPos); }
public void OnGUI(Rect pos) { m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition); bool newState = false; var centeredStyle = GUI.skin.GetStyle("Label"); centeredStyle.alignment = TextAnchor.UpperCenter; GUILayout.Label(new GUIContent("Example build setup"), centeredStyle); //basic options EditorGUILayout.Space(); GUILayout.BeginVertical(); // build target using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildTarget)) { ValidBuildTarget tgt = (ValidBuildTarget)EditorGUILayout.EnumPopup(m_TargetContent, m_UserData.m_BuildTarget); if (tgt != m_UserData.m_BuildTarget) { m_UserData.m_BuildTarget = tgt; if (m_UserData.m_UseDefaultPath) { m_UserData.m_OutputPath = "AssetBundles/"; m_UserData.m_OutputPath += m_UserData.m_BuildTarget.ToString(); //EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_OutputPath); } } } ////output path using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildOutputDirectory)) { EditorGUILayout.Space(); GUILayout.BeginHorizontal(); var newPath = EditorGUILayout.TextField("Output Path", m_UserData.m_OutputPath); if ((newPath != m_UserData.m_OutputPath) && (newPath != string.Empty)) { m_UserData.m_UseDefaultPath = false; m_UserData.m_OutputPath = newPath; //EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_OutputPath); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Browse", GUILayout.MaxWidth(75f))) { BrowseForFolder(); } if (GUILayout.Button("Reset", GUILayout.MaxWidth(75f))) { ResetPathToDefault(); } //if (string.IsNullOrEmpty(m_OutputPath)) // m_OutputPath = EditorUserBuildSettings.GetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath"); GUILayout.EndHorizontal(); EditorGUILayout.Space(); newState = GUILayout.Toggle( m_ForceRebuild.state, m_ForceRebuild.content); if (newState != m_ForceRebuild.state) { if (newState) { m_UserData.m_OnToggles.Add(m_ForceRebuild.content.text); } else { m_UserData.m_OnToggles.Remove(m_ForceRebuild.content.text); } m_ForceRebuild.state = newState; } newState = GUILayout.Toggle( m_CopyToStreaming.state, m_CopyToStreaming.content); if (newState != m_CopyToStreaming.state) { if (newState) { m_UserData.m_OnToggles.Add(m_CopyToStreaming.content.text); } else { m_UserData.m_OnToggles.Remove(m_CopyToStreaming.content.text); } m_CopyToStreaming.state = newState; } } // advanced options using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildOptions)) { EditorGUILayout.Space(); m_AdvancedSettings = EditorGUILayout.Foldout(m_AdvancedSettings, "Advanced Settings"); if (m_AdvancedSettings) { var indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 1; CompressOptions cmp = (CompressOptions)EditorGUILayout.IntPopup( m_CompressionContent, (int)m_UserData.m_Compression, m_CompressionOptions, m_CompressionValues); if (cmp != m_UserData.m_Compression) { m_UserData.m_Compression = cmp; } foreach (var tog in m_ToggleData) { newState = EditorGUILayout.ToggleLeft( tog.content, tog.state); if (newState != tog.state) { if (newState) { m_UserData.m_OnToggles.Add(tog.content.text); } else { m_UserData.m_OnToggles.Remove(tog.content.text); } tog.state = newState; } } EditorGUILayout.Space(); EditorGUI.indentLevel = indent; } } // build. EditorGUILayout.Space(); if (GUILayout.Button("Build")) { EditorApplication.delayCall += ExecuteBuild; } GUILayout.EndVertical(); EditorGUILayout.EndScrollView(); }
void DrawNewGUI() { #region Preparations for unity versions and skin c = Color.Lerp(GUI.color * new Color(0.8f, 0.8f, 0.8f, 0.7f), GUI.color, Mathf.InverseLerp(0f, 0.15f, Get.SpineAnimatorAmount)); bc = GUI.backgroundColor; RectOffset zeroOff = new RectOffset(0, 0, 0, 0); float bgAlpha = 0.05f; if (EditorGUIUtility.isProSkin) { bgAlpha = 0.1f; } #if UNITY_2019_3_OR_NEWER int headerHeight = 22; #else int headerHeight = 25; #endif if (Get.SpineBones == null) { Get.SpineBones = new System.Collections.Generic.List <FIMSpace.FSpine.FSpineAnimator.SpineBone>(); } #endregion GUILayout.BeginVertical(FGUI_Resources.BGBoxStyle); GUILayout.Space(1f); // ------------------------------------------------------------------------ // If spine setup is not finished, then not drawing rest of the inspector if (Get.SpineBones.Count <= 1) { Get._Editor_Category = FIMSpace.FSpine.FSpineAnimator.EFSpineEditorCategory.Setup; GUILayout.BeginVertical(FGUI_Inspector.Style(zeroOff, zeroOff, new Color(.7f, .7f, 0.7f, bgAlpha), Vector4.one * 3, 3)); EditorGUILayout.BeginHorizontal(FGUI_Resources.HeaderBoxStyle); GUILayout.Label(new GUIContent(" "), GUILayout.Width(1)); if (GUILayout.Button(new GUIContent(FGUI_Resources.Tex_GearSetup), EditorStyles.label, new GUILayoutOption[2] { GUILayout.Width(headerHeight), GUILayout.Height(headerHeight) })) { } if (GUILayout.Button(Lang("Prepare Spine Chain"), LangBig() ? FGUI_Resources.HeaderStyleBig : FGUI_Resources.HeaderStyle, GUILayout.Height(headerHeight))) { } if (GUILayout.Button(new GUIContent(FGUI_Resources.Tex_Repair), EditorStyles.label, new GUILayoutOption[2] { GUILayout.Width(headerHeight), GUILayout.Height(headerHeight) })) { } GUILayout.Label(new GUIContent(" "), GUILayout.Width(1)); EditorGUILayout.EndHorizontal(); Tab_DrawPreSetup(); GUILayout.EndVertical(); GUILayout.EndVertical(); return; } GUILayout.Space(2); EditorGUILayout.BeginHorizontal(); DrawCategoryButton(FIMSpace.FSpine.FSpineAnimator.EFSpineEditorCategory.Setup, FGUI_Resources.Tex_GearSetup, "Setup"); DrawCategoryButton(FIMSpace.FSpine.FSpineAnimator.EFSpineEditorCategory.Tweak, FGUI_Resources.Tex_Sliders, "Tweak"); DrawCategoryButton(FIMSpace.FSpine.FSpineAnimator.EFSpineEditorCategory.Adjust, FGUI_Resources.Tex_Repair, "Adjust"); DrawCategoryButton(FIMSpace.FSpine.FSpineAnimator.EFSpineEditorCategory.Physical, FGUI_Resources.Tex_Collider, "Physical"); EditorGUILayout.EndHorizontal(); GUILayout.Space(4); switch (Get._Editor_Category) { case FIMSpace.FSpine.FSpineAnimator.EFSpineEditorCategory.Setup: GUILayout.BeginVertical(FGUI_Inspector.Style(zeroOff, zeroOff, new Color(.7f, .7f, 0.7f, bgAlpha), Vector4.one * 3, 3)); FGUI_Inspector.HeaderBox(Lang("Character Setup"), true, FGUI_Resources.Tex_GearSetup, headerHeight, headerHeight - 1, LangBig()); Tab_DrawSetup(); GUILayout.EndVertical(); break; case FIMSpace.FSpine.FSpineAnimator.EFSpineEditorCategory.Tweak: GUILayout.BeginVertical(FGUI_Inspector.Style(zeroOff, zeroOff, new Color(.3f, .4f, 1f, bgAlpha), Vector4.one * 3, 3)); FGUI_Inspector.HeaderBox(Lang("Tweak Animation"), true, FGUI_Resources.Tex_Sliders, headerHeight, headerHeight - 1, LangBig()); Tab_DrawTweaking(); GUILayout.EndVertical(); break; case FIMSpace.FSpine.FSpineAnimator.EFSpineEditorCategory.Adjust: GUILayout.BeginVertical(FGUI_Inspector.Style(zeroOff, zeroOff, new Color(.825f, .825f, 0.225f, bgAlpha * 0.8f), Vector4.one * 3, 3)); FGUI_Inspector.HeaderBox(Lang("Adjustements"), true, FGUI_Resources.Tex_Repair, headerHeight, headerHeight - 1, LangBig()); Tab_DrawCorrections(); GUILayout.EndVertical(); break; case FIMSpace.FSpine.FSpineAnimator.EFSpineEditorCategory.Physical: GUILayout.BeginVertical(FGUI_Inspector.Style(zeroOff, zeroOff, new Color(.4f, 1f, .7f, bgAlpha), Vector4.one * 3, 3)); FGUI_Inspector.HeaderBox(Lang("Physical Parameters"), true, FGUI_Resources.Tex_Physics, headerHeight, headerHeight - 1, LangBig()); Tab_DrawPhysics(); GUILayout.EndVertical(); break; } GUILayout.EndVertical(); }
protected virtual void UiMainWizard() { GUILayout.Space(15); // title UiTitleBox(CurrentLang.PUNWizardLabel, BackgroundImage); // wizard info text GUILayout.Label("This window should help you find important settings for PUN, as well as documentation."); GUILayout.Space(15); // pun+ info if (isPunPlus) { GUILayout.Label(CurrentLang.MobilePunPlusExportNoteLabel); GUILayout.Space(15); } else if (!InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.Android) || !InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.iOS)) { GUILayout.Label(CurrentLang.MobileExportNoteLabel); GUILayout.Space(15); } // settings button GUILayout.BeginHorizontal(); GUILayout.Label(CurrentLang.SettingsButton, EditorStyles.boldLabel, GUILayout.Width(100)); GUILayout.BeginVertical(); if (GUILayout.Button(new GUIContent(CurrentLang.LocateSettingsButton, CurrentLang.SettingsHighlightLabel))) { HighlightSettings(); } if (GUILayout.Button(new GUIContent(CurrentLang.OpenCloudDashboardText, CurrentLang.OpenCloudDashboardTooltip))) { EditorUtility.OpenWithDefaultApp(UrlCloudDashboard + Uri.EscapeUriString(this.mailOrAppId)); } if (GUILayout.Button(new GUIContent(CurrentLang.SetupButton, CurrentLang.SetupServerCloudLabel))) { this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(15); // converter GUILayout.BeginHorizontal(); GUILayout.Label(CurrentLang.ConverterLabel, EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent(CurrentLang.StartButton, CurrentLang.UNtoPUNLabel))) { PhotonConverter.RunConversion(); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); // documentation GUILayout.BeginHorizontal(); GUILayout.Label(CurrentLang.DocumentationLabel, EditorStyles.boldLabel, GUILayout.Width(100)); GUILayout.BeginVertical(); if (GUILayout.Button(new GUIContent(CurrentLang.OpenPDFText, CurrentLang.OpenPDFTooltip))) { EditorUtility.OpenWithDefaultApp(DocumentationLocation); } if (GUILayout.Button(new GUIContent(CurrentLang.OpenDevNetText, CurrentLang.OpenDevNetTooltip))) { EditorUtility.OpenWithDefaultApp(UrlDevNet); } GUI.skin.label.wordWrap = true; GUILayout.Label(CurrentLang.OwnHostCloudCompareLabel); if (GUILayout.Button(CurrentLang.ComparisonPageButton)) { Application.OpenURL(UrlCompare); } if (GUILayout.Button(new GUIContent(CurrentLang.OpenForumText, CurrentLang.OpenForumTooltip))) { EditorUtility.OpenWithDefaultApp(UrlForum); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); }
public override void DrawGUI(Rect position, BuildInfo buildReportToDisplay) { BuildSettingCategory b = ReportGenerator.GetBuildSettingCategoryFromBuildValues(buildReportToDisplay); _buildTargetOfReport = UnityBuildSettingsUtility.GetReadableBuildSettingCategory(b); UnityBuildSettings settings = buildReportToDisplay.UnityBuildSettings; if (settings == null) { Utility.DrawCentralMessage(position, "No \"Project Settings\" recorded in this build report."); return; } // ---------------------------------------------------------- // top bar GUILayout.Space(1); GUILayout.BeginHorizontal(); GUILayout.Label(" ", BuildReportTool.Window.Settings.TOP_BAR_BG_STYLE_NAME); GUILayout.Space(8); GUILayout.Label("Build Target: ", BuildReportTool.Window.Settings.TOP_BAR_LABEL_STYLE_NAME); InitializeDropdownBoxLabelsIfNeeded(); _selectedSettingsIdxFromDropdownBox = EditorGUILayout.Popup(_selectedSettingsIdxFromDropdownBox, _settingDropdownBoxLabels, BuildReportTool.Window.Settings.FILE_FILTER_POPUP_STYLE_NAME); GUILayout.Space(15); GUILayout.Label("Note: Project was built in " + _buildTargetOfReport + " target", BuildReportTool.Window.Settings.TOP_BAR_LABEL_STYLE_NAME); GUILayout.FlexibleSpace(); _settingsShown = UnityBuildSettingsUtility.GetSettingsCategoryFromIdx(_selectedSettingsIdxFromDropdownBox); GUILayout.EndHorizontal(); // ---------------------------------------------------------- _scrollPos = GUILayout.BeginScrollView(_scrollPos); GUILayout.BeginHorizontal(); GUILayout.Space(10); GUILayout.BeginVertical(); GUILayout.Space(10); // ================================================================= DrawProjectSettings(buildReportToDisplay, settings); GUILayout.Space(SETTINGS_GROUP_SPACING); // ================================================================= DrawPathSettings(buildReportToDisplay, settings); GUILayout.Space(SETTINGS_GROUP_SPACING); // ================================================================= DrawBuildSettings(buildReportToDisplay, settings); GUILayout.Space(SETTINGS_GROUP_SPACING); // ================================================================= DrawRuntimeSettings(buildReportToDisplay, settings); // -------------------------------------------------- // security settings if (IsShowingMacSettings) { DrawSetting("Use App Store validation:", settings.MacUseAppStoreValidation); } else if (IsShowingAndroidSettings) { DrawSetting("Use license verification:", settings.AndroidUseLicenseVerification); } GUILayout.Space(SETTINGS_GROUP_SPACING); // ================================================================= DrawDebugSettings(buildReportToDisplay, settings); GUILayout.Space(SETTINGS_GROUP_SPACING); // ================================================================= DrawCodeSettings(buildReportToDisplay, settings); GUILayout.Space(SETTINGS_GROUP_SPACING); // ================================================================= DrawGraphicsSettings(buildReportToDisplay, settings); GUILayout.Space(SETTINGS_GROUP_SPACING); GUILayout.Space(10); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.EndScrollView(); }
void OnGUIBinder() { TextAsset prevTextFile = mTextFileBinder; EditorGUIUtility.labelWidth = 80.0f; GUILayout.BeginHorizontal(); bool doCreate = false; if (mTextFileBinder == null) { GUI.backgroundColor = Color.green; doCreate = GUILayout.Button("Create", GUILayout.Width(76f)); GUI.backgroundColor = Color.white; mTextNameBinder = GUILayout.TextField(mTextNameBinder); } GUILayout.EndHorizontal(); if (mTextFileBinder != null) { mTextNameBinder = mTextFileBinder.name; mTextFilePathBinder = AssetDatabase.GetAssetPath(mTextFileBinder); } else if (!string.IsNullOrEmpty(mTextNameBinder)) { mTextFilePathBinder = Utility.GetSelectionFolder() + mTextNameBinder + ".txt"; } if (doCreate && !string.IsNullOrEmpty(mTextNameBinder)) { File.WriteAllText(mTextFilePathBinder, ""); AssetDatabase.Refresh(); mTextFileBinder = (TextAsset)AssetDatabase.LoadAssetAtPath(mTextFilePathBinder, typeof(TextAsset)); } GUILayout.BeginHorizontal(); GUILayout.Label("Select: "); mTextFileBinder = (TextAsset)EditorGUILayout.ObjectField(mTextFileBinder, typeof(TextAsset), false); GUILayout.EndHorizontal(); if (!string.IsNullOrEmpty(mTextFilePathBinder)) { GUILayout.Label("Path: " + mTextFilePathBinder); } else { GUILayout.Label("Path: <none>" + mTextFilePathBinder); } GUILayout.Space(6f); bool refreshBinds = mTextFileBinder != prevTextFile; if (mTextFileBinder != null && actions != null) { //initialize bind data if (mBinds == null || mBinds.Length != actions.Count) { if (mBinds == null) { mBinds = new BindData[actions.Count]; } else { System.Array.Resize <BindData>(ref mBinds, actions.Count); } refreshBinds = true; } //load from file if (refreshBinds && mTextFileBinder.text.Length > 0) { //load data List <InputManager.Bind> loadBinds = InputManager.BindList.FromJSON(mTextFileBinder.text); foreach (InputManager.Bind bind in loadBinds) { if (bind.action < mBinds.Length) { mBinds[bind.action].bind = bind; mBinds[bind.action].RefreshKeyTypes(); } } } //display binds for (int i = 0; i < mBinds.Length; i++) { if (mBinds[i].bind == null) { mBinds[i].bind = new InputManager.Bind(); } mBinds[i].bind.action = i; GUILayout.BeginVertical(GUI.skin.box); GUILayout.BeginHorizontal(); GUILayout.Label(actions[i]); GUILayout.FlexibleSpace(); mBinds[i].bind.control = (InputManager.Control)EditorGUILayout.EnumPopup(mBinds[i].bind.control); GUILayout.EndHorizontal(); if (mBinds[i].bind.control == InputManager.Control.Axis) { mBinds[i].bind.deadZone = EditorGUILayout.FloatField("Deadzone", mBinds[i].bind.deadZone); mBinds[i].bind.forceRaw = EditorGUILayout.Toggle("Force Raw", mBinds[i].bind.forceRaw); } int keyCount = mBinds[i].keyTypes != null ? mBinds[i].keyTypes.Length : 0; mBinds[i].foldOut = EditorGUILayout.Foldout(mBinds[i].foldOut, string.Format("Binds [{0}]", keyCount)); if (mBinds[i].foldOut) { int delKey = -1; for (int key = 0; key < keyCount; key++) { GUILayout.BeginVertical(GUI.skin.box); GUILayout.BeginHorizontal(); mBinds[i].bind.keys[key].player = EditorGUILayout.IntField("Player", mBinds[i].bind.keys[key].player, GUILayout.MaxWidth(200)); GUILayout.FlexibleSpace(); if (GUILayout.Button("DEL", GUILayout.MaxWidth(40))) { delKey = key; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); //key bind mBinds[i].keyTypes[key] = (InputType)EditorGUILayout.EnumPopup(mBinds[i].keyTypes[key]); switch (mBinds[i].keyTypes[key]) { case InputType.Unity: mBinds[i].bind.keys[key].input = EditorGUILayout.TextField(mBinds[i].bind.keys[key].input, GUILayout.MinWidth(250)); break; case InputType.KeyCode: mBinds[i].bind.keys[key].code = (KeyCode)EditorGUILayout.EnumPopup(mBinds[i].bind.keys[key].code); break; case InputType.InputMap: mBinds[i].bind.keys[key].map = (InputKeyMap)EditorGUILayout.EnumPopup(mBinds[i].bind.keys[key].map); break; } GUILayout.EndHorizontal(); //other configs if (mBinds[i].bind.control == InputManager.Control.Axis) { if (mBinds[i].keyTypes[key] != InputType.Unity) { mBinds[i].bind.keys[key].axis = (InputManager.ButtonAxis)EditorGUILayout.EnumPopup("Axis", mBinds[i].bind.keys[key].axis, GUILayout.MaxWidth(200)); } if (mBinds[i].keyTypes[key] == InputType.Unity || mBinds[i].bind.keys[key].axis == InputManager.ButtonAxis.Both) { mBinds[i].bind.keys[key].invert = EditorGUILayout.Toggle("Invert", mBinds[i].bind.keys[key].invert); } } else { mBinds[i].bind.keys[key].index = EditorGUILayout.IntField("Index", mBinds[i].bind.keys[key].index, GUILayout.MaxWidth(200)); } GUILayout.EndVertical(); } if (delKey != -1) { mBinds[i].DeleteKey(delKey); } if (GUILayout.Button("Add")) { mBinds[i].ResizeKeys(keyCount + 1); } } GUILayout.EndVertical(); } } EditorGUIUtility.labelWidth = 0.0f; }
public void OnGUI() { GUILayout.Space(10f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); GUILayout.Label(string.Format("Version {0}", SVGImporterSettings.version), new GUILayoutOption[0]); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); GUILayout.Label(AboutWindow.s_Header, GUIStyle.none, new GUILayoutOption[0]); OnLastRectClick(delegate() { Application.OpenURL("http://www.svgimporter.com"); }); this.ListenForSecretCodes(); GUILayout.Space(4f); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.TextArea(kSpecialThanksNames + "\n" + kSpecialThanksNamesTesters, GUI.skin.label); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label(AboutWindow.s_ClipperLogo, new GUILayoutOption[0]); OnLastRectClick(delegate() { Application.OpenURL("http://www.angusj.com/delphi/clipper.php"); }); GUILayout.Label("Clipping powered by Clipper.\n\n(c) 2010-2014 Angus Johnson", "MiniLabel", new GUILayoutOption[] { GUILayout.Width(200f) }); OnLastRectClick(delegate() { Application.OpenURL("http://www.angusj.com/delphi/clipper.php"); }); GUILayout.Label(AboutWindow.s_SGILogo, new GUILayoutOption[0]); OnLastRectClick(delegate() { Application.OpenURL("https://github.com/speps/LibTessDotNet"); }); GUILayout.Label("Tesselation powered by LibTessDotNet.\n\n(c) 2011 Silicon Graphics, Inc.", "MiniLabel", new GUILayoutOption[] { GUILayout.Width(200f) }); OnLastRectClick(delegate() { Application.OpenURL("https://github.com/speps/LibTessDotNet"); }); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(5f); GUILayout.BeginVertical(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); GUILayout.Label("\n" + "Copyright (c) 2015 Jaroslav Stehlik", "MiniLabel", new GUILayoutOption[0]); GUILayout.EndVertical(); GUILayout.Space(10f); GUILayout.FlexibleSpace(); GUILayout.Space(5f); GUILayout.EndHorizontal(); GUILayout.Space(5f); }
void _drawGUI(int id) { UpArrow = ResonantOrbitCalculator.Instance.upContent; DownArrow = ResonantOrbitCalculator.Instance.downContent; GUILayout.BeginHorizontal(GUILayout.Width(wnd_width)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(GUILayout.Width(wnd_width)); GUILayout.BeginVertical(GUILayout.Width(GRAPH_WIDTH + 10)); // draw graph box GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(OrbitCalc.header[0]); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(OrbitCalc.header[1]); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Box(graph_texture); GUILayout.EndVertical(); // draw side text GUILayout.BeginVertical(GUILayout.Width(wnd_width - GRAPH_WIDTH - 30)); bool draw = false; if (firstTime) { firstTime = false; draw = true; } // if (!PlanetSelection.isActive) { if (GUILayout.Button("Select Planet")) { if (!PlanetSelection.isActive) { planetSelection = new GameObject().AddComponent <PlanetSelection>(); } else { planetSelection.DestroyThis(); } } } GUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Number of satellites:", "Total number of satellites to arrange")); var newsNumSats = GUILayout.TextField(sNumSats); int butW = 19; if (GUILayout.Button(UpArrow, GUILayout.Width(butW))) { numSats++; sNumSats = numSats.ToString(); newsNumSats = sNumSats; draw = true; } if (GUILayout.Button(DownArrow, GUILayout.Width(butW))) { if (numSats > 1) { numSats--; } sNumSats = numSats.ToString(); newsNumSats = sNumSats; draw = true; } if (sNumSats != newsNumSats) { bValidNumSats = int.TryParse(newsNumSats, out iTmp); if (!bValidNumSats) { sNumSats = numSats.ToString(); } else { numSats = iTmp; sNumSats = newsNumSats; draw = true; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Altitude:", "Orbital altitude")); GUI.SetNextControlName("altitude"); string newsOrbitAltitude = GUILayout.TextField(sOrbitAltitude); if (newsOrbitAltitude != sOrbitAltitude) { bValidOrbitAltitude = double.TryParse(newsOrbitAltitude, out dTmp); if (bValidOrbitAltitude) { selectedOrbit = SelectedOrbit.None; orbitAltitude = dTmp; } sOrbitAltitude = orbitAltitude.ToString("F0"); draw = true; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Orbital Period: "); GUILayout.FlexibleSpace(); GUI.SetNextControlName("periodHour"); string h = GUILayout.TextField(OrbitCalc.periodHour, bh ? textStyle : textErrorStyle, GUILayout.MinWidth(25)); GUILayout.Label("h "); GUI.SetNextControlName("periodMin"); string m = GUILayout.TextField(OrbitCalc.periodMin, bm ? textStyle : textErrorStyle, GUILayout.MinWidth(25)); GUILayout.Label("m "); GUI.SetNextControlName("periodSec"); string s = GUILayout.TextField(OrbitCalc.periodSec, bs ? textStyle : textErrorStyle, GUILayout.MinWidth(25)); GUILayout.Label("s"); OrbitCalc.periodEntry = GUI.GetNameOfFocusedControl() == "periodHour" || GUI.GetNameOfFocusedControl() == "periodMin" || GUI.GetNameOfFocusedControl() == "periodSec"; bh = Double.TryParse(h, out dh); bm = Double.TryParse(m, out dm); bs = Double.TryParse(s, out ds); if (h != OrbitCalc.periodHour || m != OrbitCalc.periodMin || s != OrbitCalc.periodSec) { if (bh && bm && bs) { double T = dh * 3600 + dm * 60 + ds; orbitAltitude = OrbitCalc.satelliteorbit.a(T); sOrbitAltitude = orbitAltitude.ToString("F0"); draw = true; } OrbitCalc.periodHour = h; OrbitCalc.periodMin = m; OrbitCalc.periodSec = s; } GUILayout.EndHorizontal(); if (OrbitCalc.synchrorbit == "" || OrbitCalc.synchrorbit == "n/a") { GUI.enabled = false; } GUILayout.BeginHorizontal(); if (GUILayout.Toggle(synchronousOrbit, new GUIContent("Synchronous orbit (" + OrbitCalc.synchrorbit + ")", "Set the altitude to have the satellites be in a geosynchronous orbit"))) { selectedOrbit = SelectedOrbit.Synchronous; orbitAltitude = OrbitCalc.body.geoAlt; sOrbitAltitude = orbitAltitude.ToString(); OrbitCalc.periodEntry = false; draw = true; } GUILayout.EndHorizontal(); GUI.enabled = true; GUILayout.Space(10); GUILayout.BeginHorizontal(); if (OrbitCalc.losorbit == "" || OrbitCalc.losorbit == "n/a") { GUI.enabled = false; } if (GUILayout.Toggle(minLOSorbit, new GUIContent("Minimum LOS orbit (" + OrbitCalc.losorbit + ")", "Set the altitude to the minimum altitude possible to maintain a Line of Sight"), OrbitCalc.losOrbitWarning ? toggleMinLOSWarning : toggleMinLOSNormal)) { selectedOrbit = SelectedOrbit.MinLOS; orbitAltitude = OrbitCalc.minLOS; sOrbitAltitude = orbitAltitude.ToString(); OrbitCalc.periodEntry = false; draw = true; } GUILayout.EndHorizontal(); GUI.enabled = true; if (HighLogic.LoadedSceneIsFlight) { GUILayout.Space(10); GUILayout.BeginHorizontal(); bool warning = false; warning = (FlightGlobals.activeTarget.orbit.ApA < FlightGlobals.ActiveVessel.mainBody.atmosphereDepth); if (GUILayout.Toggle(currentAp, new GUIContent("Current Ap (" + FlightGlobals.activeTarget.orbit.ApA.ToString("N0") + ")", "Set the altitude to the current vessel's Ap"), warning ? toggleMinLOSWarning : GUI.skin.toggle)) { selectedOrbit = SelectedOrbit.Ap; orbitAltitude = Math.Round(FlightGlobals.activeTarget.orbit.ApA); sOrbitAltitude = orbitAltitude.ToString(); OrbitCalc.periodEntry = false; draw = true; } GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); warning = (FlightGlobals.activeTarget.orbit.PeA < FlightGlobals.ActiveVessel.mainBody.atmosphereDepth); if (FlightGlobals.activeTarget.orbit.PeA < 1) { GUI.enabled = false; } if (GUILayout.Toggle(currentPe, new GUIContent("Current Pe (" + FlightGlobals.activeTarget.orbit.PeA.ToString("N0") + ")", "Set the altitude to the current vessel's Pe"), OrbitCalc.losOrbitWarning ? toggleMinLOSWarning : GUI.skin.toggle)) { selectedOrbit = SelectedOrbit.Pe; orbitAltitude = Math.Round(FlightGlobals.activeTarget.orbit.PeA); sOrbitAltitude = orbitAltitude.ToString(); OrbitCalc.periodEntry = false; draw = true; } GUI.enabled = true; GUILayout.EndHorizontal(); } GUILayout.Space(10); GUILayout.BeginHorizontal(); bool newshowLOSlines = GUILayout.Toggle(showLOSlines, new GUIContent("Show LOS lines", "Show the Line Of Sight lines")); if (newshowLOSlines != showLOSlines) { draw = true; showLOSlines = newshowLOSlines; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); bool newocclusionModifiers = GUILayout.Toggle(occlusionModifiers, new GUIContent("Occlusion modifiers", "Enable occlusion modifiers for vacuum and atmospheres")); GUILayout.EndHorizontal(); if (occlusionModifiers) { GUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent(" Atm:", "Occlusion atmospheric modifier")); var newsAtmOcclusion = GUILayout.TextField(sAtmOcclusion); if (GUILayout.Button(UpArrow, GUILayout.Width(butW))) { if (atmOcclusion < 1.1) { atmOcclusion += 0.01f; } sAtmOcclusion = atmOcclusion.ToString("F2"); newsAtmOcclusion = sAtmOcclusion; draw = true; } if (GUILayout.Button(DownArrow, GUILayout.Width(butW))) { if (atmOcclusion > 0) { atmOcclusion -= 0.01f; } sAtmOcclusion = atmOcclusion.ToString("F2"); newsAtmOcclusion = sAtmOcclusion; draw = true; } if (newsAtmOcclusion != sAtmOcclusion) { bValidAtmOcclusion = double.TryParse(newsAtmOcclusion, out dTmp); if (!bValidAtmOcclusion) { sAtmOcclusion = atmOcclusion.ToString("F2"); } else { atmOcclusion = dTmp; sAtmOcclusion = newsAtmOcclusion; draw = true; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent(" Vac:", "Occlusion vacuum modifier")); var newsVacOcclusion = GUILayout.TextField(sVacOcclusion); if (GUILayout.Button(UpArrow, GUILayout.Width(butW))) { if (vacOcclusion < 1.1) { vacOcclusion += 0.01f; } sVacOcclusion = vacOcclusion.ToString("F2"); newsVacOcclusion = sVacOcclusion; draw = true; } if (GUILayout.Button(DownArrow, GUILayout.Width(butW))) { if (vacOcclusion > 0) { vacOcclusion -= 0.01f; } sVacOcclusion = vacOcclusion.ToString("F2"); newsVacOcclusion = sVacOcclusion; draw = true; } if (newsVacOcclusion != sVacOcclusion) { bValidVacOcclusion = Double.TryParse(newsVacOcclusion, out dTmp); if (!bValidVacOcclusion) { sVacOcclusion = vacOcclusion.ToString("F2"); } else { vacOcclusion = dTmp; sVacOcclusion = newsVacOcclusion; draw = true; } } GUILayout.EndHorizontal(); } if (occlusionModifiers != newocclusionModifiers) { draw = true; } occlusionModifiers = newocclusionModifiers; GUILayout.Space(15); GUILayout.BeginHorizontal(); GUILayout.Label("Resonant Orbit", labelResonantOrbit); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); bool newflipOrbit = GUILayout.Toggle(flipOrbit, new GUIContent("Dive orbit", "Set Carrier orbit to be lower than target orbit")); if (newflipOrbit != flipOrbit) { draw = true; flipOrbit = newflipOrbit; } GUILayout.EndHorizontal(); if (draw) { UpdateGraph(); } GUILayout.BeginHorizontal(); GUILayout.Label("Orbital Period: "); GUILayout.Label(OrbitCalc.carrierT); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Apoapsis: "); GUILayout.Label(OrbitCalc.carrierAp); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Periapsis: "); if (OrbitCalc.carrierPe != "") { GUILayout.Label(OrbitCalc.carrierPe, OrbitCalc.carrierPeWarning ? warningLabel : normalLabel); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Injection Δv: "); GUILayout.Label(OrbitCalc.burnDV); GUILayout.EndHorizontal(); Log.Info("LoadedSceneIsFlight: " + HighLogic.LoadedSceneIsFlight + ", patchedConicsUnlocked: " + FlightGlobals.ActiveVessel.patchedConicsUnlocked()); if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ActiveVessel.patchedConicsUnlocked()) { GUILayout.FlexibleSpace(); Log.Info("selectedOrbit: " + selectedOrbit); if (selectedOrbit == SelectedOrbit.Ap) { GUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent("Create Maneuver Node at Ap", "Creates a maneuver node to put the current vessel into the resonant orbit"))) { Vector3d circularizeDv = VesselOrbitalCalc.CircularizeAtAP(FlightGlobals.ActiveVessel); // If a flip, then subtract double UT = Planetarium.GetUniversalTime(); UT += FlightGlobals.ActiveVessel.orbit.timeToAp; var o = FlightGlobals.ActiveVessel.orbit; if (flipOrbit) { circularizeDv -= OrbitCalc.dBurnDV * o.Horizontal(UT); } else { circularizeDv += OrbitCalc.dBurnDV * o.Horizontal(UT); } FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Clear(); VesselOrbitalCalc.PlaceManeuverNode(FlightGlobals.ActiveVessel, FlightGlobals.ActiveVessel.orbit, circularizeDv, UT); } GUILayout.EndHorizontal(); } if (selectedOrbit == SelectedOrbit.Pe) { if (OrbitCalc.carrierPeWarning) { buttonStyle = buttonRed; } else { buttonStyle = GUI.skin.button; } GUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent("Create Maneuver Node at Pe", "Creates a maneuver node to put the current vessel into the resonant orbit"), buttonStyle)) { double UT = Planetarium.GetUniversalTime(); UT += FlightGlobals.ActiveVessel.orbit.timeToPe; var o = FlightGlobals.ActiveVessel.orbit; Vector3d circularizeDv = VesselOrbitalCalc.CircularizeAtPE(FlightGlobals.ActiveVessel); // If a flip, then subtract if (flipOrbit) { circularizeDv -= OrbitCalc.dBurnDV * o.Horizontal(UT); } else { circularizeDv += OrbitCalc.dBurnDV * o.Horizontal(UT); } FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Clear(); VesselOrbitalCalc.PlaceManeuverNode(FlightGlobals.ActiveVessel, FlightGlobals.ActiveVessel.orbit, circularizeDv, UT); } GUILayout.EndHorizontal(); } Log.Info("FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count(): " + FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count()); if (FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count() > 0) { GUILayout.BeginHorizontal(); if (GUILayout.Button("Clear all nodes")) { for (int i = FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count - 1; i >= 0; i--) { FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes[i].RemoveSelf(); } } GUILayout.EndHorizontal(); if (selectedOrbit == SelectedOrbit.Ap || selectedOrbit == SelectedOrbit.Pe) { if (KACWrapper.APIReady) { GUILayout.BeginHorizontal(); if (GUILayout.Button("Add alarms to KAC")) { double timeToOrbit = FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes[0].UT; double period = OrbitCalc.satelliteorbit.T; String aID; if (!ResonantOrbitCalculator.Instance.mucore.Available) { aID = KACWrapper.KAC.CreateAlarm(KACWrapper.KACAPI.AlarmTypeEnum.Maneuver, "Orbital Maneuver", timeToOrbit - 60); KACWrapper.KAC.Alarms.First(z => z.ID == aID).Notes = "Put carrier craft into resonant orbit"; KACWrapper.KAC.Alarms.First(z => z.ID == aID).AlarmMargin = 60; } timeToOrbit += period; for (int i = 0; i < numSats; i++) { aID = KACWrapper.KAC.CreateAlarm(KACWrapper.KACAPI.AlarmTypeEnum.Raw, "Detachment # " + (i + 1).ToString(), timeToOrbit - 60); KACWrapper.KAC.Alarms.First(z => z.ID == aID).Notes = "Detach satellite # " + (i + 1) + " and circularize it's orbit"; KACWrapper.KAC.Alarms.First(z => z.ID == aID).AlarmMargin = 60; timeToOrbit += period; } } GUILayout.EndHorizontal(); } if (ResonantOrbitCalculator.Instance.mucore.Available) { GUILayout.BeginHorizontal(); if (GUILayout.Button("Execute maneuver")) { ResonantOrbitCalculator.Instance.mucore.ExecuteNode(); } GUILayout.EndHorizontal(); } } } } GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent("Save Window", "Saves an image of the window to the Screenshots directory"))) { saveScreen = true; } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); if (Event.current.type == EventType.Repaint && GUI.tooltip != tooltip) { tooltip = GUI.tooltip; } GUI.DragWindow(); }
void DrawSpriteList() { if (spriteCollectionProxy != null && spriteCollectionProxy.Empty) { DrawDropZone(); return; } int spriteListControlId = GUIUtility.GetControlID("tk2d.SpriteList".GetHashCode(), FocusType.Keyboard); HandleListKeyboardShortcuts(spriteListControlId); spriteListScroll = GUILayout.BeginScrollView(spriteListScroll, GUILayout.Width(leftBarWidth)); GUILayout.BeginVertical(tk2dEditorSkin.SC_ListBoxBG, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); bool multiSelectKey = (Application.platform == RuntimePlatform.OSXEditor)?Event.current.command:Event.current.control; bool shiftSelectKey = Event.current.shift; bool selectionChanged = false; SpriteCollectionEditorEntry.Type lastType = SpriteCollectionEditorEntry.Type.None; foreach (var entry in entries) { if (lastType != entry.type) { if (lastType != SpriteCollectionEditorEntry.Type.None) { GUILayout.Space(8); } else { GUI.SetNextControlName("firstLabel"); } GUILayout.Label(GetEntryTypeString(entry.type), tk2dEditorSkin.SC_ListBoxSectionHeader, GUILayout.ExpandWidth(true)); lastType = entry.type; } bool newSelected = GUILayout.Toggle(entry.selected, entry.name, tk2dEditorSkin.SC_ListBoxItem, GUILayout.ExpandWidth(true)); if (newSelected != entry.selected) { GUI.FocusControl("firstLabel"); entry.selectionKey = spriteListSelectionKey++; if (multiSelectKey) { // Only allow multiselection with sprites bool selectionAllowed = entry.type == SpriteCollectionEditorEntry.Type.Sprite; foreach (var e in entries) { if (e != entry && e.selected && e.type != entry.type) { selectionAllowed = false; break; } } if (selectionAllowed) { entry.selected = newSelected; selectionChanged = true; } else { foreach (var e in entries) { e.selected = false; } entry.selected = true; selectionChanged = true; } } else if (shiftSelectKey) { // find first selected entry in list int firstSelection = int.MaxValue; foreach (var e in entries) { if (e.selected && e.listIndex < firstSelection) { firstSelection = e.listIndex; } } int lastSelection = entry.listIndex; if (lastSelection < firstSelection) { lastSelection = firstSelection; firstSelection = entry.listIndex; } // Filter for multiselection if (entry.type == SpriteCollectionEditorEntry.Type.Sprite) { for (int i = firstSelection; i <= lastSelection; ++i) { if (entries[i].type != entry.type) { firstSelection = entry.listIndex; lastSelection = entry.listIndex; } } } else { firstSelection = lastSelection = entry.listIndex; } foreach (var e in entries) { e.selected = (e.listIndex >= firstSelection && e.listIndex <= lastSelection); } selectionChanged = true; } else { foreach (var e in entries) { e.selected = false; } entry.selected = true; selectionChanged = true; } } } if (selectionChanged) { GUIUtility.keyboardControl = spriteListControlId; UpdateSelection(); Repaint(); } GUILayout.EndVertical(); GUILayout.EndScrollView(); Rect viewRect = GUILayoutUtility.GetLastRect(); tk2dPreferences.inst.spriteCollectionListWidth = (int)tk2dGuiUtility.DragableHandle(4819283, viewRect, tk2dPreferences.inst.spriteCollectionListWidth, tk2dGuiUtility.DragDirection.Horizontal); }
void OnGUI() { GUILayout.BeginVertical("box"); for (int i = 0; i < GUIContents.Length; i++) { if (GUILayout.Button(GUIContents[i])) { currentState = GUIContents[i].text; } AnimatorStateInfo stateInfo = animator[0].GetCurrentAnimatorStateInfo(0); if (!stateInfo.IsName("Base Layer.idle2")) { for (int j = 0; j < animator.Length; j++) { animator[j].SetBool("idle2ToIdle0", false); animator[j].SetBool("idle2ToIdle1", false); animator[j].SetBool("idle2ToWalk", false); animator[j].SetBool("idle2ToRun", false); animator[j].SetBool("idle2ToWound", false); animator[j].SetBool("idle2ToSkill1", false); animator[j].SetBool("idle2ToSkill0", false); animator[j].SetBool("idle2ToAttack1", false); animator[j].SetBool("idle2ToAttack0", false); animator[j].SetBool("idle2ToDeath", false); } } else { for (int j = 0; j < animator.Length; j++) { animator[j].SetBool("walkToIdle2", false); animator[j].SetBool("runToIdle2", false); animator[j].SetBool("deathToIdle2", false); } } if (currentState != "") { if (stateInfo.IsName("Base Layer.walk") && currentState != "walk") { for (int j = 0; j < animator.Length; j++) { animator[j].SetBool("walkToIdle2", true); } } if (stateInfo.IsName("Base Layer.run") && currentState != "run") { for (int j = 0; j < animator.Length; j++) { animator[j].SetBool("runToIdle2", true); } } if (stateInfo.IsName("Base Layer.death") && currentState != "death") { for (int j = 0; j < animator.Length; j++) { animator[j].SetBool("deathToIdle2", true); } } switch (currentState) { case "idle0": for (int j = 0; j < animator.Length; j++) { animator[j].SetBool("idle2ToIdle0", true); } break; case "idle1": for (int j = 0; j < animator.Length; j++) { animator[j].SetBool("idle2ToIdle1", true); } break; case "idle2": break; case "walk": for (int j = 0; j < animator.Length; j++) { animator[j].SetBool("idle2ToWalk", true); } break; case "run": for (int j = 0; j < animator.Length; j++) { animator[j].SetBool("idle2ToRun", true); } break; case "attack0": for (int j = 0; j < animator.Length; j++) { animator[j].SetBool("idle2ToAttack0", true); } break; case "attack1": for (int j = 0; j < animator.Length; j++) { animator[j].SetBool("idle2ToAttack1", true); } break; case "skill0": for (int j = 0; j < animator.Length; j++) { animator[j].SetBool("idle2ToSkill0", true); } break; case "skill1": for (int j = 0; j < animator.Length; j++) { animator[j].SetBool("idle2ToSkill1", true); } break; case "wound": for (int j = 0; j < animator.Length; j++) { animator[j].SetBool("idle2ToWound", true); } break; case "death": for (int j = 0; j < animator.Length; j++) { animator[j].SetBool("idle2ToDeath", true); } break; default: break; } currentState = ""; } } GUILayout.EndVertical(); }
public override void OnInspectorGUI() { serializedObject.Update(); if (toolbars != null && toolbars.Count > 1) { GUILayout.BeginVertical(headerAttribute != null ? headerAttribute.header : target.GetType().Name, skin.window); GUILayout.Label(m_Logo, skin.label, GUILayout.MaxHeight(25)); if (headerAttribute.openClose) { openCloseWindow = GUILayout.Toggle(openCloseWindow, openCloseWindow ? "Close Properties" : "Open Properties", EditorStyles.toolbarButton); } if (!headerAttribute.openClose || openCloseWindow) { var titles = getToobarTitles(); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Script")); var customToolbar = skin.GetStyle("customToolbar"); if (headerAttribute.useHelpBox) { EditorGUILayout.HelpBox(headerAttribute.helpBoxText, MessageType.Info); } GUILayout.Space(10); selectedToolBar = GUILayout.SelectionGrid(selectedToolBar, titles, titles.Length > 2?3: titles.Length, customToolbar, GUILayout.MinWidth(250)); if (!(selectedToolBar < toolbars.Count)) { selectedToolBar = 0; } GUILayout.Space(10); //GUILayout.Box(toolbars[selectedToolBar].title, skin.box, GUILayout.ExpandWidth(true)); var ignore = getIgnoreProperties(toolbars[selectedToolBar]); var ignoreProperties = ignore.Append(ignore_vMono); DrawPropertiesExcluding(serializedObject, ignoreProperties); } GUILayout.EndVertical(); } else { if (headerAttribute == null) { if (((vMonoBehaviour)target) != null) { DrawPropertiesExcluding(serializedObject, ignore_vMono); } else { base.OnInspectorGUI(); } } else { GUILayout.BeginVertical(headerAttribute.header, skin.window); GUILayout.Label(m_Logo, skin.label, GUILayout.MaxHeight(25)); if (headerAttribute.openClose) { openCloseWindow = GUILayout.Toggle(openCloseWindow, openCloseWindow ? "Close Properties" : "Open Properties", EditorStyles.toolbarButton); } if (!headerAttribute.openClose || openCloseWindow) { if (headerAttribute.useHelpBox) { EditorGUILayout.HelpBox(headerAttribute.helpBoxText, MessageType.Info); } if (ignoreEvents != null && ignoreEvents.Length > 0) { var ignoreProperties = ignoreEvents.Append(ignore_vMono); DrawPropertiesExcluding(serializedObject, ignoreProperties); openCloseEvents = GUILayout.Toggle(openCloseEvents, (openCloseEvents ? "Close " : "Open ") + "Events ", skin.button); if (openCloseEvents) { foreach (string propName in ignoreEvents) { var prop = serializedObject.FindProperty(propName); if (prop != null) { EditorGUILayout.PropertyField(prop); } } } } else { var ignoreProperties = ignoreEvents.Append(ignore_vMono); DrawPropertiesExcluding(serializedObject, ignoreProperties); } } EditorGUILayout.EndVertical(); } } if (GUI.changed) { serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(serializedObject.targetObject); } }
public override void OnInspectorGUI() { GUILayout.Space(10.0f); serializedObject.Update(); GUILayout.BeginVertical("box"); var usesNormalLight = serializedObject.FindProperty("IsAddedToNormalLight"); if (usesNormalLight.boolValue) { EditorGUILayout.HelpBox("This light will use the settings of the light on this GameObject.\n\nRemove this component if the light should not be recognized by Fog Volume 3", MessageType.Info); } else { var enabled = serializedObject.FindProperty("Enabled"); if (GUILayout.Button(enabled.boolValue ? "Disable the light" : "Enable the light")) { enabled.boolValue = !enabled.boolValue; } if (enabled.boolValue == true) { GUILayout.Space(10.0f); var isPointLight = serializedObject.FindProperty("IsPointLight"); int selectedLightType = isPointLight.boolValue ? 0 : 1; selectedLightType = EditorGUILayout.Popup("Light Type: ", selectedLightType, m_lightTypes, EditorStyles.toolbarButton); if (selectedLightType == 0) { isPointLight.boolValue = true; } else { isPointLight.boolValue = false; } GUILayout.Space(10.0f); var color = serializedObject.FindProperty("Color"); EditorGUILayout.PropertyField(color, new GUIContent("Color:")); GUILayout.Space(10.0f); var intensity = serializedObject.FindProperty("Intensity"); EditorGUILayout.Slider(intensity, MinIntensity, MaxIntenstity, new GUIContent("Intensity:")); GUILayout.Space(10.0f); var range = serializedObject.FindProperty("Range"); EditorGUILayout.Slider(range, MinRange, MaxRange, new GUIContent("Range:")); if (selectedLightType == 1) { GUILayout.Space(10.0f); var angle = serializedObject.FindProperty("Angle"); EditorGUILayout.Slider(angle, MinSpotAngle, MaxSpotAngle, new GUIContent("SpotAngle:")); } } } GUILayout.EndVertical(); serializedObject.ApplyModifiedProperties(); }
override public void OnInspectorGUI() { base.OnInspectorGUI(); GUILayout.Space(3); EditorGUIUtils.SetGUIStyles(); bool playMode = Application.isPlaying; _runtimeEditMode = _runtimeEditMode && playMode; GUILayout.BeginHorizontal(); EditorGUIUtils.InspectorLogo(); GUILayout.Label(_src.animationType.ToString() + (string.IsNullOrEmpty(_src.id) ? "" : " [" + _src.id + "]"), EditorGUIUtils.sideLogoIconBoldLabelStyle); // Up-down buttons GUILayout.FlexibleSpace(); if (GUILayout.Button("▲", DeGUI.styles.button.toolIco)) { UnityEditorInternal.ComponentUtility.MoveComponentUp(_src); } if (GUILayout.Button("▼", DeGUI.styles.button.toolIco)) { UnityEditorInternal.ComponentUtility.MoveComponentDown(_src); } GUILayout.EndHorizontal(); if (playMode) { if (_runtimeEditMode) { } else { GUILayout.Space(8); GUILayout.Label("Animation Editor disabled while in play mode", EditorGUIUtils.wordWrapLabelStyle); if (!_src.isActive) { GUILayout.Label("This animation has been toggled as inactive and won't be generated", EditorGUIUtils.wordWrapLabelStyle); GUI.enabled = false; } if (GUILayout.Button(new GUIContent("Activate Edit Mode", "Switches to Runtime Edit Mode, where you can change animations values and restart them"))) { _runtimeEditMode = true; } GUILayout.Label("NOTE: when using DOPlayNext, the sequence is determined by the DOTweenAnimation Components order in the target GameObject's Inspector", EditorGUIUtils.wordWrapLabelStyle); GUILayout.Space(10); if (!_runtimeEditMode) { return; } } } Undo.RecordObject(_src, "DOTween Animation"); // _src.isValid = Validate(); // Moved down EditorGUIUtility.labelWidth = 110; if (playMode) { GUILayout.Space(4); DeGUILayout.Toolbar("Edit Mode Commands"); DeGUILayout.BeginVBox(DeGUI.styles.box.stickyTop); GUILayout.BeginHorizontal(); if (GUILayout.Button("TogglePause")) { _src.tween.TogglePause(); } if (GUILayout.Button("Rewind")) { _src.tween.Rewind(); } if (GUILayout.Button("Restart")) { _src.tween.Restart(); } GUILayout.EndHorizontal(); if (GUILayout.Button("Commit changes and restart")) { _src.tween.Rewind(); _src.tween.Kill(); if (_src.isValid) { _src.CreateTween(); _src.tween.Play(); } } GUILayout.Label("To apply your changes when exiting Play mode, use the Component's upper right menu and choose \"Copy Component\", then \"Paste Component Values\" after exiting Play mode", DeGUI.styles.label.wordwrap); DeGUILayout.EndVBox(); } else { bool hasManager = _src.GetComponent <DOTweenVisualManager>() != null; if (!hasManager) { if (GUILayout.Button(new GUIContent("Add Manager", "Adds a manager component which allows you to choose additional options for this gameObject"))) { _src.gameObject.AddComponent <DOTweenVisualManager>(); } } } GUILayout.BeginHorizontal(); DOTweenAnimationType prevAnimType = _src.animationType; // _src.animationType = (DOTweenAnimationType)EditorGUILayout.EnumPopup(_src.animationType, EditorGUIUtils.popupButton); _src.isActive = EditorGUILayout.Toggle(new GUIContent("", "If unchecked, this animation will not be created"), _src.isActive, GUILayout.Width(16)); GUI.enabled = _src.isActive; _src.animationType = AnimationToDOTweenAnimationType(_AnimationType[EditorGUILayout.Popup(DOTweenAnimationTypeToPopupId(_src.animationType), _AnimationType)]); _src.autoPlay = DeGUILayout.ToggleButton(_src.autoPlay, new GUIContent("AutoPlay", "If selected, the tween will play automatically")); _src.autoKill = DeGUILayout.ToggleButton(_src.autoKill, new GUIContent("AutoKill", "If selected, the tween will be killed when it completes, and won't be reusable")); GUILayout.EndHorizontal(); if (prevAnimType != _src.animationType) { // Set default optional values based on animation type _src.endValueTransform = null; _src.useTargetAsV3 = false; switch (_src.animationType) { case DOTweenAnimationType.Move: case DOTweenAnimationType.LocalMove: case DOTweenAnimationType.Rotate: case DOTweenAnimationType.LocalRotate: case DOTweenAnimationType.Scale: _src.endValueV3 = Vector3.zero; _src.endValueFloat = 0; _src.optionalBool0 = _src.animationType == DOTweenAnimationType.Scale; break; case DOTweenAnimationType.UIWidthHeight: _src.endValueV3 = Vector3.zero; _src.endValueFloat = 0; _src.optionalBool0 = _src.animationType == DOTweenAnimationType.UIWidthHeight; break; case DOTweenAnimationType.Color: case DOTweenAnimationType.Fade: _isLightSrc = _src.GetComponent <Light>() != null; _src.endValueFloat = 0; break; case DOTweenAnimationType.Text: _src.optionalBool0 = true; break; case DOTweenAnimationType.PunchPosition: case DOTweenAnimationType.PunchRotation: case DOTweenAnimationType.PunchScale: _src.endValueV3 = _src.animationType == DOTweenAnimationType.PunchRotation ? new Vector3(0, 180, 0) : Vector3.one; _src.optionalFloat0 = 1; _src.optionalInt0 = 10; _src.optionalBool0 = false; break; case DOTweenAnimationType.ShakePosition: case DOTweenAnimationType.ShakeRotation: case DOTweenAnimationType.ShakeScale: _src.endValueV3 = _src.animationType == DOTweenAnimationType.ShakeRotation ? new Vector3(90, 90, 90) : Vector3.one; _src.optionalInt0 = 10; _src.optionalFloat0 = 90; _src.optionalBool0 = false; break; case DOTweenAnimationType.CameraAspect: case DOTweenAnimationType.CameraFieldOfView: case DOTweenAnimationType.CameraOrthoSize: _src.endValueFloat = 0; break; case DOTweenAnimationType.CameraPixelRect: case DOTweenAnimationType.CameraRect: _src.endValueRect = new Rect(0, 0, 0, 0); break; } } if (_src.animationType == DOTweenAnimationType.None) { _src.isValid = false; if (GUI.changed) { EditorUtility.SetDirty(_src); } return; } if (prevAnimType != _src.animationType || ComponentsChanged()) { _src.isValid = Validate(); // See if we need to choose between multiple targets if (_src.animationType == DOTweenAnimationType.Fade && _src.GetComponent <CanvasGroup>() != null && _src.GetComponent <Image>() != null) { _chooseTargetMode = ChooseTargetMode.BetweenCanvasGroupAndImage; // Reassign target and forcedTargetType if lost if (_src.forcedTargetType == TargetType.Unset) { _src.forcedTargetType = _src.targetType; } switch (_src.forcedTargetType) { case TargetType.CanvasGroup: _src.target = _src.GetComponent <CanvasGroup>(); break; case TargetType.Image: _src.target = _src.GetComponent <Image>(); break; } } else { _chooseTargetMode = ChooseTargetMode.None; _src.forcedTargetType = TargetType.Unset; } } if (!_src.isValid) { GUI.color = Color.red; GUILayout.BeginVertical(GUI.skin.box); GUILayout.Label("No valid Component was found for the selected animation", EditorGUIUtils.wordWrapLabelStyle); GUILayout.EndVertical(); GUI.color = Color.white; if (GUI.changed) { EditorUtility.SetDirty(_src); } return; } // Special cases in which multiple target types could be used (set after validation) if (_chooseTargetMode == ChooseTargetMode.BetweenCanvasGroupAndImage && _src.forcedTargetType != TargetType.Unset) { FadeTargetType fadeTargetType = (FadeTargetType)Enum.Parse(typeof(FadeTargetType), _src.forcedTargetType.ToString()); TargetType prevTargetType = _src.forcedTargetType; _src.forcedTargetType = (TargetType)Enum.Parse(typeof(TargetType), EditorGUILayout.EnumPopup(_src.animationType + " Target", fadeTargetType).ToString()); if (_src.forcedTargetType != prevTargetType) { // Target type change > assign correct target switch (_src.forcedTargetType) { case TargetType.CanvasGroup: _src.target = _src.GetComponent <CanvasGroup>(); break; case TargetType.Image: _src.target = _src.GetComponent <Image>(); break; } } } GUILayout.BeginHorizontal(); _src.duration = EditorGUILayout.FloatField("Duration", _src.duration); if (_src.duration < 0) { _src.duration = 0; } _src.isSpeedBased = DeGUILayout.ToggleButton(_src.isSpeedBased, new GUIContent("SpeedBased", "If selected, the duration will count as units/degree x second"), DeGUI.styles.button.tool, GUILayout.Width(75)); GUILayout.EndHorizontal(); _src.delay = EditorGUILayout.FloatField("Delay", _src.delay); if (_src.delay < 0) { _src.delay = 0; } _src.isIndependentUpdate = EditorGUILayout.Toggle("Ignore TimeScale", _src.isIndependentUpdate); _src.easeType = EditorGUIUtils.FilteredEasePopup(_src.easeType); if (_src.easeType == Ease.INTERNAL_Custom) { _src.easeCurve = EditorGUILayout.CurveField(" Ease Curve", _src.easeCurve); } _src.loops = EditorGUILayout.IntField(new GUIContent("Loops", "Set to -1 for infinite loops"), _src.loops); if (_src.loops < -1) { _src.loops = -1; } if (_src.loops > 1 || _src.loops == -1) { _src.loopType = (LoopType)EditorGUILayout.EnumPopup(" Loop Type", _src.loopType); } _src.id = EditorGUILayout.TextField("ID", _src.id); bool canBeRelative = true; // End value and eventual specific options switch (_src.animationType) { case DOTweenAnimationType.Move: case DOTweenAnimationType.LocalMove: GUIEndValueV3(_src.animationType == DOTweenAnimationType.Move); _src.optionalBool0 = EditorGUILayout.Toggle(" Snapping", _src.optionalBool0); canBeRelative = !_src.useTargetAsV3; break; case DOTweenAnimationType.Rotate: case DOTweenAnimationType.LocalRotate: if (_src.GetComponent <Rigidbody2D>()) { GUIEndValueFloat(); } else { GUIEndValueV3(); _src.optionalRotationMode = (RotateMode)EditorGUILayout.EnumPopup(" Rotation Mode", _src.optionalRotationMode); } break; case DOTweenAnimationType.Scale: if (_src.optionalBool0) { GUIEndValueFloat(); } else { GUIEndValueV3(); } _src.optionalBool0 = EditorGUILayout.Toggle("Uniform Scale", _src.optionalBool0); break; case DOTweenAnimationType.UIWidthHeight: if (_src.optionalBool0) { GUIEndValueFloat(); } else { GUIEndValueV2(); } _src.optionalBool0 = EditorGUILayout.Toggle("Uniform Scale", _src.optionalBool0); break; case DOTweenAnimationType.Color: GUIEndValueColor(); canBeRelative = false; break; case DOTweenAnimationType.Fade: GUIEndValueFloat(); if (_src.endValueFloat < 0) { _src.endValueFloat = 0; } if (!_isLightSrc && _src.endValueFloat > 1) { _src.endValueFloat = 1; } canBeRelative = false; break; case DOTweenAnimationType.Text: GUIEndValueString(); _src.optionalBool0 = EditorGUILayout.Toggle("Rich Text Enabled", _src.optionalBool0); _src.optionalScrambleMode = (ScrambleMode)EditorGUILayout.EnumPopup("Scramble Mode", _src.optionalScrambleMode); _src.optionalString = EditorGUILayout.TextField(new GUIContent("Custom Scramble", "Custom characters to use in case of ScrambleMode.Custom"), _src.optionalString); break; case DOTweenAnimationType.PunchPosition: case DOTweenAnimationType.PunchRotation: case DOTweenAnimationType.PunchScale: GUIEndValueV3(); canBeRelative = false; _src.optionalInt0 = EditorGUILayout.IntSlider(new GUIContent(" Vibrato", "How much will the punch vibrate"), _src.optionalInt0, 1, 50); _src.optionalFloat0 = EditorGUILayout.Slider(new GUIContent(" Elasticity", "How much the vector will go beyond the starting position when bouncing backwards"), _src.optionalFloat0, 0, 1); if (_src.animationType == DOTweenAnimationType.PunchPosition) { _src.optionalBool0 = EditorGUILayout.Toggle(" Snapping", _src.optionalBool0); } break; case DOTweenAnimationType.ShakePosition: case DOTweenAnimationType.ShakeRotation: case DOTweenAnimationType.ShakeScale: GUIEndValueV3(); canBeRelative = false; _src.optionalInt0 = EditorGUILayout.IntSlider(new GUIContent(" Vibrato", "How much will the shake vibrate"), _src.optionalInt0, 1, 50); _src.optionalFloat0 = EditorGUILayout.Slider(new GUIContent(" Randomness", "The shake randomness"), _src.optionalFloat0, 0, 90); if (_src.animationType == DOTweenAnimationType.ShakePosition) { _src.optionalBool0 = EditorGUILayout.Toggle(" Snapping", _src.optionalBool0); } break; case DOTweenAnimationType.CameraAspect: case DOTweenAnimationType.CameraFieldOfView: case DOTweenAnimationType.CameraOrthoSize: GUIEndValueFloat(); canBeRelative = false; break; case DOTweenAnimationType.CameraBackgroundColor: GUIEndValueColor(); canBeRelative = false; break; case DOTweenAnimationType.CameraPixelRect: case DOTweenAnimationType.CameraRect: GUIEndValueRect(); canBeRelative = false; break; } // Final settings if (canBeRelative) { _src.isRelative = EditorGUILayout.Toggle(" Relative", _src.isRelative); } // Events 注释掉,不需要事件的编辑窗口 // AnimationInspectorGUI.AnimationEvents(this, _src); if (GUI.changed) { EditorUtility.SetDirty(_src); } }
public static void DrawThemePopup(ThemesDatabase database, ThemeData themeData, string[] themeNames, int themeIndex, ColorName componentColorName, SerializedObject serializedObject, Object[] targets, ThemeTarget target, Color initialGUIColor, Action updateIds, Action updateLists) { GUILayout.BeginHorizontal(); { DGUI.Line.Draw(false, componentColorName, true, () => { GUILayout.Space(DGUI.Properties.Space(2)); DGUI.Label.Draw(UILabels.SelectedTheme, Size.S, componentColorName, DGUI.Properties.SingleLineHeight); GUILayout.Space(DGUI.Properties.Space()); GUILayout.BeginVertical(GUILayout.Height(DGUI.Properties.SingleLineHeight)); { GUILayout.Space(0); GUI.color = DGUI.Colors.PropertyColor(componentColorName); EditorGUI.BeginChangeCheck(); themeIndex = EditorGUILayout.Popup(GUIContent.none, themeIndex, themeNames); GUI.color = initialGUIColor; } GUILayout.EndVertical(); if (EditorGUI.EndChangeCheck()) { if (serializedObject.isEditingMultipleObjects) { DoozyUtils.UndoRecordObjects(targets, UILabels.UpdateValue); themeData = database.Themes[themeIndex]; foreach (Object o in targets) { var themeTarget = (ThemeTarget)o; if (themeTarget == null) { continue; } themeTarget.ThemeId = themeData.Id; } updateIds.Invoke(); updateLists.Invoke(); foreach (Object o in targets) { var themeTarget = (ThemeTarget)o; if (themeTarget == null) { continue; } if (!themeData.ContainsColorProperty(themeTarget.PropertyId)) { themeTarget.PropertyId = themeData.ColorLabels.Count > 0 ? themeData.ColorLabels[0].Id : Guid.Empty; } themeTarget.UpdateTarget(themeData); } } else { DoozyUtils.UndoRecordObject(target, UILabels.UpdateValue); themeData = database.Themes[themeIndex]; target.ThemeId = themeData.Id; updateIds.Invoke(); updateLists.Invoke(); target.UpdateTarget(themeData); } } }); GUILayout.Space(DGUI.Properties.Space()); ThemeTargetEditorUtils.DrawButtonTheme(themeData, componentColorName); } GUILayout.EndHorizontal(); }
protected override void WindowGUI(int windowID) { GUILayout.BeginVertical(); if (core.target.PositionTargetExists) { GUILayout.Label("Target coordinates:"); core.target.targetLatitude.DrawEditGUI(EditableAngle.Direction.NS); core.target.targetLongitude.DrawEditGUI(EditableAngle.Direction.EW); } else { if (GUILayout.Button("Enter target coordinates")) { core.target.SetPositionTarget(mainBody, core.target.targetLatitude, core.target.targetLongitude); } } if (GUILayout.Button("Pick target on map")) { core.target.PickPositionTargetOnMap(); } if (mainBody.bodyName.ToLower().Contains("kerbin")) { if (GUILayout.Button("Target KSC")) { core.target.SetPositionTarget(mainBody, -0.10267, -74.57538); } } core.node.autowarp = GUILayout.Toggle(core.node.autowarp, "Auto-warp"); bool active = GUILayout.Toggle(predictor.enabled, "Show landing predictions"); if (predictor.enabled != active) { if (active) { predictor.users.Add(this); } else { predictor.users.Remove(this); } } if (predictor.enabled) { predictor.makeAerobrakeNodes = GUILayout.Toggle(predictor.makeAerobrakeNodes, "Show aerobrake nodes"); DrawGUIPrediction(); } if (autopilot != null) { GUILayout.Label("Autopilot:"); if (autopilot.enabled) { if (GUILayout.Button("Abort autoland")) { autopilot.StopLanding(); } } else { GUILayout.BeginHorizontal(); if (!core.target.PositionTargetExists) { GUI.enabled = false; } if (GUILayout.Button("Land at target")) { autopilot.LandAtPositionTarget(this); } GUI.enabled = true; if (GUILayout.Button("Land somewhere")) { autopilot.LandUntargeted(this); } GUILayout.EndHorizontal(); } GuiUtils.SimpleTextBox("Touchdown speed:", autopilot.touchdownSpeed, "m/s", 35); if (autopilot.enabled) { GUILayout.Label("Status: " + autopilot.status); } } GUILayout.EndVertical(); GUI.DragWindow(); }
void OnGUI() { GUIStyle boldNumberFieldStyle = new GUIStyle(EditorStyles.numberField); boldNumberFieldStyle.font = EditorStyles.boldFont; GUIStyle boldToggleStyle = new GUIStyle(EditorStyles.toggle); boldToggleStyle.font = EditorStyles.boldFont; GUI.enabled = !waitTillPlistHasBeenWritten; //Toolbar EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); { Rect optionsRect = GUILayoutUtility.GetRect(0, 20, GUILayout.ExpandWidth(false)); if (GUILayout.Button(new GUIContent("Sort " + (sortAscending ? "▼" : "▲"), "Change sorting to " + (sortAscending ? "descending" : "ascending")), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { OnChangeSortModeClicked(); } if (GUILayout.Button(new GUIContent("Options", "Contains additional functionality like \"Add new entry\" and \"Delete all entries\" "), EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false))) { GenericMenu options = new GenericMenu(); options.AddItem(new GUIContent("New Entry..."), false, OnNewEntryClicked); options.AddSeparator(""); options.AddItem(new GUIContent("Delete Selected Entries"), false, OnDeleteSelectedClicked); options.AddItem(new GUIContent("Delete All Entries"), false, OnDeleteAllClicked); options.DropDown(optionsRect); } GUILayout.FlexibleSpace(); if (Application.platform == RuntimePlatform.WindowsEditor) { string refreshTooltip = "Should all entries be automaticly refreshed every " + UpdateIntervalInSeconds + " seconds?"; autoRefresh = GUILayout.Toggle(autoRefresh, new GUIContent("Auto Refresh ", refreshTooltip), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false), GUILayout.MinWidth(20)); } if (GUILayout.Button(new GUIContent(RefreshIcon, "Force a refresh, could take a few seconds."), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false))) { RefreshKeys(); } Rect r; if (Application.platform == RuntimePlatform.OSXEditor) { r = GUILayoutUtility.GetRect(16, 16); } else { r = GUILayoutUtility.GetRect(9, 16); } if (waitTillPlistHasBeenWritten) { Texture2D t = AssetDatabase.LoadAssetAtPath(IconsPath + "loader/" + (Mathf.FloorToInt(rotation % 12) + 1) + ".png", typeof(Texture2D)) as Texture2D; GUI.DrawTexture(new Rect(r.x + 3, r.y, 16, 16), t); } } EditorGUILayout.EndHorizontal(); GUI.enabled = !waitTillPlistHasBeenWritten; if (showNewEntryBox) { GUILayout.BeginHorizontal(GUI.skin.box); { GUILayout.BeginVertical(GUILayout.ExpandWidth(true)); { newKey = EditorGUILayout.TextField("Key", newKey); switch (selectedType) { default: case ValueType.String: newValueString = EditorGUILayout.TextField("Value", newValueString); break; case ValueType.Float: newValueFloat = EditorGUILayout.FloatField("Value", newValueFloat); break; case ValueType.Int: newValueInt = EditorGUILayout.IntField("Value", newValueInt); break; } selectedType = (ValueType)EditorGUILayout.EnumPopup("Type", selectedType); } GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.Width(1)); { GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("X", "Close"), EditorStyles.boldLabel, GUILayout.ExpandWidth(false))) { showNewEntryBox = false; } } GUILayout.EndHorizontal(); if (GUILayout.Button(new GUIContent(AddIcon, "Add a new key-value."))) { if (!string.IsNullOrEmpty(newKey)) { switch (selectedType) { case ValueType.Int: PlayerPrefs.SetInt(newKey, newValueInt); ppeList.Add(new PlayerPrefsEntry(newKey, newValueInt)); break; case ValueType.Float: PlayerPrefs.SetFloat(newKey, newValueFloat); ppeList.Add(new PlayerPrefsEntry(newKey, newValueFloat)); break; default: case ValueType.String: PlayerPrefs.SetString(newKey, newValueString); ppeList.Add(new PlayerPrefsEntry(newKey, newValueString)); break; } PlayerPrefs.Save(); } newKey = newValueString = ""; newValueInt = 0; newValueFloat = 0; GUIUtility.keyboardControl = 0; //move focus from textfield, else the text won't be cleared showNewEntryBox = false; } } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } GUILayout.Space(2); GUI.backgroundColor = Color.white; EditorGUI.indentLevel++; scrollPos = EditorGUILayout.BeginScrollView(scrollPos); { EditorGUILayout.BeginVertical(); { for (int i = 0; i < ppeList.Count; i++) { if (ppeList[i].Value != null) { EditorGUILayout.BeginHorizontal(); { ppeList[i].IsSelected = GUILayout.Toggle(ppeList[i].IsSelected, new GUIContent(ppeList[i].Key, "Toggle selection."), ppeList[i].HasChanged ? boldToggleStyle : EditorStyles.toggle, GUILayout.MinWidth(40), GUILayout.MaxWidth(125), GUILayout.ExpandWidth(true)); GUIStyle numberFieldStyle = ppeList[i].HasChanged ? boldNumberFieldStyle : EditorStyles.numberField; switch (ppeList[i].Type) { default: case ValueType.String: ppeList[i].Value = EditorGUILayout.TextField("", (string)ppeList[i].Value, numberFieldStyle, GUILayout.MinWidth(40)); break; case ValueType.Float: ppeList[i].Value = EditorGUILayout.FloatField("", (float)ppeList[i].Value, numberFieldStyle, GUILayout.MinWidth(40)); break; case ValueType.Int: ppeList[i].Value = EditorGUILayout.IntField("", (int)ppeList[i].Value, numberFieldStyle, GUILayout.MinWidth(40)); break; } GUI.enabled = ppeList[i].HasChanged && !waitTillPlistHasBeenWritten; if (GUILayout.Button(new GUIContent(SaveIcon, "Save changes made to this value."), GUILayout.ExpandWidth(false))) { ppeList[i].SaveChanges(); } if (GUILayout.Button(new GUIContent(UndoIcon, "Discard changes made to this value."), GUILayout.ExpandWidth(false))) { ppeList[i].RevertChanges(); } GUI.enabled = !waitTillPlistHasBeenWritten; if (GUILayout.Button(new GUIContent(DeleteIcon, "Delete this key-value."), GUILayout.ExpandWidth(false))) { PlayerPrefs.DeleteKey(ppeList[i].Key); ppeList.Remove(ppeList[i]); PlayerPrefs.Save(); break; } } EditorGUILayout.EndHorizontal(); } } } EditorGUILayout.EndVertical(); } EditorGUILayout.EndScrollView(); EditorGUI.indentLevel--; }
public override void OnInspectorGUI() { mFont = target as UIFont; NGUIEditorTools.SetLabelWidth(80f); GUILayout.Space(6f); if (mFont.replacement != null) { mType = FontType.Reference; mReplacement = mFont.replacement; } else if (mFont.dynamicFont != null) { mType = FontType.Dynamic; } GUI.changed = false; GUILayout.BeginHorizontal(); mType = (FontType)EditorGUILayout.EnumPopup("Font Type", mType); GUILayout.Space(18f); GUILayout.EndHorizontal(); if (GUI.changed) { if (mType == FontType.Bitmap) { OnSelectFont(null); } if (mType != FontType.Dynamic && mFont.dynamicFont != null) { mFont.dynamicFont = null; } } if (mType == FontType.Reference) { ComponentSelector.Draw <UIFont>(mFont.replacement, OnSelectFont, true); GUILayout.Space(6f); EditorGUILayout.HelpBox("You can have one font simply point to " + "another one. This is useful if you want to be " + "able to quickly replace the contents of one " + "font with another one, for example for " + "swapping an SD font with an HD one, or " + "replacing an English font with a Chinese " + "one. All the labels referencing this font " + "will update their references to the new one.", MessageType.Info); if (mReplacement != mFont && mFont.replacement != mReplacement) { NGUIEditorTools.RegisterUndo("Font Change", mFont); mFont.replacement = mReplacement; NGUITools.SetDirty(mFont); } return; } else if (mType == FontType.Dynamic) { #if UNITY_3_5 EditorGUILayout.HelpBox("Dynamic fonts require Unity 4.0 or higher.", MessageType.Error); #else Font fnt = EditorGUILayout.ObjectField("TTF Font", mFont.dynamicFont, typeof(Font), false) as Font; if (fnt != mFont.dynamicFont) { NGUIEditorTools.RegisterUndo("Font change", mFont); mFont.dynamicFont = fnt; } Material mat = EditorGUILayout.ObjectField("Material", mFont.material, typeof(Material), false) as Material; if (mFont.material != mat) { NGUIEditorTools.RegisterUndo("Font Material", mFont); mFont.material = mat; } GUILayout.BeginHorizontal(); int size = EditorGUILayout.IntField("Default Size", mFont.defaultSize, GUILayout.Width(120f)); FontStyle style = (FontStyle)EditorGUILayout.EnumPopup(mFont.dynamicFontStyle); GUILayout.Space(18f); GUILayout.EndHorizontal(); if (size != mFont.defaultSize) { NGUIEditorTools.RegisterUndo("Font change", mFont); mFont.defaultSize = size; } if (style != mFont.dynamicFontStyle) { NGUIEditorTools.RegisterUndo("Font change", mFont); mFont.dynamicFontStyle = style; } #endif } else { ComponentSelector.Draw <UIAtlas>(mFont.atlas, OnSelectAtlas, true); if (mFont.atlas != null) { if (mFont.bmFont.isValid) { NGUIEditorTools.DrawAdvancedSpriteField(mFont.atlas, mFont.spriteName, SelectSprite, false); } EditorGUILayout.Space(); } else { // No atlas specified -- set the material and texture rectangle directly Material mat = EditorGUILayout.ObjectField("Material", mFont.material, typeof(Material), false) as Material; if (mFont.material != mat) { NGUIEditorTools.RegisterUndo("Font Material", mFont); mFont.material = mat; } } // For updating the font's data when importing from an external source, such as the texture packer bool resetWidthHeight = false; if (mFont.atlas != null || mFont.material != null) { TextAsset data = EditorGUILayout.ObjectField("Import Data", null, typeof(TextAsset), false) as TextAsset; if (data != null) { NGUIEditorTools.RegisterUndo("Import Font Data", mFont); BMFontReader.Load(mFont.bmFont, NGUITools.GetHierarchy(mFont.gameObject), data.bytes); mFont.MarkAsChanged(); resetWidthHeight = true; GameDebug.Log("Imported " + mFont.bmFont.glyphCount + " characters"); } } if (mFont.bmFont.isValid) { Texture2D tex = mFont.texture; if (tex != null && mFont.atlas == null) { // Pixels are easier to work with than UVs Rect pixels = NGUIMath.ConvertToPixels(mFont.uvRect, tex.width, tex.height, false); // Automatically set the width and height of the rectangle to be the original font texture's dimensions if (resetWidthHeight) { pixels.width = mFont.texWidth; pixels.height = mFont.texHeight; } // Font sprite rectangle pixels = EditorGUILayout.RectField("Pixel Rect", pixels); // Convert the pixel coordinates back to UV coordinates Rect uvRect = NGUIMath.ConvertToTexCoords(pixels, tex.width, tex.height); if (mFont.uvRect != uvRect) { NGUIEditorTools.RegisterUndo("Font Pixel Rect", mFont); mFont.uvRect = uvRect; } //NGUIEditorTools.DrawSeparator(); EditorGUILayout.Space(); } } } // Dynamic fonts don't support emoticons if (!mFont.isDynamic && mFont.bmFont.isValid) { if (mFont.atlas != null) { if (NGUIEditorTools.DrawHeader("Symbols and Emoticons")) { NGUIEditorTools.BeginContents(); List <BMSymbol> symbols = mFont.symbols; for (int i = 0; i < symbols.Count;) { BMSymbol sym = symbols[i]; GUILayout.BeginHorizontal(); GUILayout.Label(sym.sequence, GUILayout.Width(40f)); if (NGUIEditorTools.DrawSpriteField(mFont.atlas, sym.spriteName, ChangeSymbolSprite, GUILayout.MinWidth(100f))) { mSelectedSymbol = sym; } if (GUILayout.Button("Edit", GUILayout.Width(40f))) { if (mFont.atlas != null) { NGUISettings.atlas = mFont.atlas; NGUISettings.selectedSprite = sym.spriteName; NGUIEditorTools.Select(mFont.atlas.gameObject); } } GUI.backgroundColor = Color.red; if (GUILayout.Button("X", GUILayout.Width(22f))) { NGUIEditorTools.RegisterUndo("Remove symbol", mFont); mSymbolSequence = sym.sequence; mSymbolSprite = sym.spriteName; symbols.Remove(sym); mFont.MarkAsChanged(); } GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); GUILayout.Space(4f); ++i; } if (symbols.Count > 0) { GUILayout.Space(6f); } GUILayout.BeginHorizontal(); mSymbolSequence = EditorGUILayout.TextField(mSymbolSequence, GUILayout.Width(40f)); NGUIEditorTools.DrawSpriteField(mFont.atlas, mSymbolSprite, SelectSymbolSprite); bool isValid = !string.IsNullOrEmpty(mSymbolSequence) && !string.IsNullOrEmpty(mSymbolSprite); GUI.backgroundColor = isValid ? Color.green : Color.grey; if (GUILayout.Button("Add", GUILayout.Width(40f)) && isValid) { NGUIEditorTools.RegisterUndo("Add symbol", mFont); mFont.AddSymbol(mSymbolSequence, mSymbolSprite); mFont.MarkAsChanged(); mSymbolSequence = ""; mSymbolSprite = ""; } GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); if (symbols.Count == 0) { EditorGUILayout.HelpBox("Want to add an emoticon to your font? In the field above type ':)', choose a sprite, then hit the Add button.", MessageType.Info); } else { GUILayout.Space(4f); } NGUIEditorTools.EndContents(); } } } if (mFont.bmFont != null && mFont.bmFont.isValid) { if (NGUIEditorTools.DrawHeader("Modify")) { NGUIEditorTools.BeginContents(); UISpriteData sd = mFont.sprite; bool disable = (sd != null && (sd.paddingLeft != 0 || sd.paddingBottom != 0)); EditorGUI.BeginDisabledGroup(disable || mFont.packedFontShader); EditorGUILayout.BeginHorizontal(); GUILayout.Space(20f); EditorGUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); NGUISettings.foregroundColor = EditorGUILayout.ColorField("Foreground", NGUISettings.foregroundColor); NGUISettings.backgroundColor = EditorGUILayout.ColorField("Background", NGUISettings.backgroundColor); GUILayout.EndVertical(); mCurve = EditorGUILayout.CurveField("", mCurve, GUILayout.Width(40f), GUILayout.Height(40f)); GUILayout.EndHorizontal(); if (GUILayout.Button("Add a Shadow")) { ApplyEffect(Effect.Shadow, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Add a Soft Outline")) { ApplyEffect(Effect.Outline, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Rebalance Colors")) { ApplyEffect(Effect.Rebalance, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Apply Curve to Alpha")) { ApplyEffect(Effect.AlphaCurve, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Apply Curve to Foreground")) { ApplyEffect(Effect.ForegroundCurve, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Apply Curve to Background")) { ApplyEffect(Effect.BackgroundCurve, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } GUILayout.Space(10f); if (GUILayout.Button("Add Transparent Border (+1)")) { ApplyEffect(Effect.Border, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } if (GUILayout.Button("Remove Border (-1)")) { ApplyEffect(Effect.Crop, NGUISettings.foregroundColor, NGUISettings.backgroundColor); } EditorGUILayout.EndVertical(); GUILayout.Space(20f); EditorGUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); if (disable) { GUILayout.Space(3f); EditorGUILayout.HelpBox("The sprite used by this font has been trimmed and is not suitable for modification. " + "Try re-adding this sprite with 'Trim Alpha' disabled.", MessageType.Warning); } NGUIEditorTools.EndContents(); } } // The font must be valid at this point for the rest of the options to show up if (mFont.isDynamic || mFont.bmFont.isValid) { if (mFont.atlas == null) { mView = View.Font; mUseShader = false; } } // Preview option if (!mFont.isDynamic && mFont.atlas != null) { GUILayout.BeginHorizontal(); { mView = (View)EditorGUILayout.EnumPopup("Preview", mView); GUILayout.Label("Shader", GUILayout.Width(45f)); mUseShader = EditorGUILayout.Toggle(mUseShader, GUILayout.Width(20f)); } GUILayout.EndHorizontal(); } }
void GameObjectGroupsGUI() { for (int i = 0; i < objectGroups.arraySize; i++) { SerializedProperty gameobjects = objectGroups.GetArrayElementAtIndex(i).FindPropertyRelative("GOs"); SerializedProperty groupParent = objectGroups.GetArrayElementAtIndex(i).FindPropertyRelative("GroupParent"); SerializedProperty foldoutBool = objectGroups.GetArrayElementAtIndex(i).FindPropertyRelative("IsOpen"); SerializedProperty groupName = objectGroups.GetArrayElementAtIndex(i).FindPropertyRelative("GroupName"); GUILayout.Box(GUIContent.none, GUILayout.Height(2), GUILayout.ExpandWidth(true)); if (groupName.stringValue == "") { groupName.stringValue = "ObjectGroup" + i; } // start foldout for object group if (foldoutBool.boolValue = EditorGUILayout.Foldout(foldoutBool.boolValue, groupName.stringValue, EditorStyles.foldout)) { EditorGUI.indentLevel++; GUILayout.BeginVertical(); // group name, remove group button GUILayout.BeginHorizontal(); groupName.stringValue = EditorGUILayout.TextField("Group Name", groupName.stringValue); if (groupName.stringValue == "") { groupName.stringValue = " "; } if (GUILayout.Button("Remove Object Group")) { objectGroups.DeleteArrayElementAtIndex(i); if (i == selectedObjectId.vector2Value.x) { selectedObjectId.vector2Value = disabledId; } break; } GUILayout.EndHorizontal(); // parent transform EditorGUILayout.PropertyField(groupParent); // if(groupParent.objectReferenceValue != null) // { // Transform parentTrans = groupParent.objectReferenceValue as Transform; // } AddObjectDropZone(gameobjects); // draw the game objects GameObjectListGUI(i, gameobjects); GUILayout.BeginHorizontal(); if (GUILayout.Button("Add a game object")) { gameobjects.InsertArrayElementAtIndex(gameobjects.arraySize); } if (GUILayout.Button("Remove all objects")) { for (int k = gameobjects.arraySize - 1; k >= 0; k--) { RemoveGameObjectFromList(gameobjects, i, k); groupParent.objectReferenceValue = null; } } GUILayout.EndHorizontal(); GUILayout.EndVertical(); EditorGUI.indentLevel--; } GUILayout.Box(GUIContent.none, GUILayout.Height(2), GUILayout.ExpandWidth(true)); //EditorGUILayout.Space (); } }
void OnGUI() { if (m_Info != null && m_DebugGui) { GUI.depth = -1; GUI.matrix = Matrix4x4.TRS(new Vector3(m_GuiPositionX, 10f, 0f), Quaternion.identity, new Vector3(s_GuiScale, s_GuiScale, 1.0f)); GUILayout.BeginVertical("box", GUILayout.MaxWidth(s_GuiWidth)); GUILayout.Label(System.IO.Path.GetFileName(m_VideoPath)); GUILayout.Label("Dimensions: " + m_Info.GetVideoWidth() + "x" + m_Info.GetVideoHeight() + "@" + m_Info.GetVideoFrameRate().ToString("F2")); GUILayout.Label("Time: " + (m_Control.GetCurrentTimeMs() * 0.001f).ToString("F1") + "s / " + (m_Info.GetDurationMs() * 0.001f).ToString("F1") + "s"); GUILayout.Label("Rate: " + m_Info.GetVideoDisplayRate().ToString("F2") + "Hz"); if (TextureProducer != null && TextureProducer.GetTexture() != null) { // Show texture without and with alpha blending GUILayout.BeginHorizontal(); Rect r1 = GUILayoutUtility.GetRect(32f, 32f); GUILayout.Space(8f); Rect r2 = GUILayoutUtility.GetRect(32f, 32f); Matrix4x4 prevMatrix = GUI.matrix; if (TextureProducer.RequiresVerticalFlip()) { GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0, r1.y + (r1.height / 2))); } GUI.DrawTexture(r1, TextureProducer.GetTexture(), ScaleMode.ScaleToFit, false); GUI.DrawTexture(r2, TextureProducer.GetTexture(), ScaleMode.ScaleToFit, true); GUI.matrix = prevMatrix; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } #if AVPROVIDEO_DEBUG_DISPLAY_EVENTS // Dirty code to hack in an event monitor if (Event.current.type == EventType.Repaint) { this.Events.RemoveListener(OnMediaPlayerEvent); this.Events.AddListener(OnMediaPlayerEvent); UpdateEventLogs(); } if (_eventLog != null && _eventLog.Count > 0) { GUILayout.Label("Recent Events: "); GUILayout.BeginVertical("box"); int eventIndex = 0; foreach (string eventString in _eventLog) { GUI.color = Color.white; if (eventIndex == 0) { GUI.color = new Color(1f, 1f, 1f, _eventTimer); } GUILayout.Label(eventString); eventIndex++; } GUILayout.EndVertical(); GUI.color = Color.white; } #endif GUILayout.EndVertical(); } }
private void DrawNodes() { Event e = Event.current; if (e.type == EventType.Layout) { selectionCache = new List <UnityEngine.Object>(Selection.objects); } System.Reflection.MethodInfo onValidate = null; if (Selection.activeObject != null && Selection.activeObject is XNode.Node) { onValidate = Selection.activeObject.GetType().GetMethod("OnValidate"); if (onValidate != null) { EditorGUI.BeginChangeCheck(); } } BeginZoomed(position, zoom, topPadding); Vector2 mousePos = Event.current.mousePosition; if (e.type != EventType.Layout) { hoveredNode = null; hoveredPort = null; } List <UnityEngine.Object> preSelection = preBoxSelection != null ? new List <UnityEngine.Object>(preBoxSelection) : new List <UnityEngine.Object>(); // Selection box stuff Vector2 boxStartPos = GridToWindowPositionNoClipped(dragBoxStart); Vector2 boxSize = mousePos - boxStartPos; if (boxSize.x < 0) { boxStartPos.x += boxSize.x; boxSize.x = Mathf.Abs(boxSize.x); } if (boxSize.y < 0) { boxStartPos.y += boxSize.y; boxSize.y = Mathf.Abs(boxSize.y); } Rect selectionBox = new Rect(boxStartPos, boxSize); //Save guiColor so we can revert it Color guiColor = GUI.color; List <XNode.NodePort> removeEntries = new List <XNode.NodePort>(); if (e.type == EventType.Layout) { culledNodes = new List <XNode.Node>(); } for (int n = 0; n < graph.nodes.Count; n++) { // Skip null nodes. The user could be in the process of renaming scripts, so removing them at this point is not advisable. if (graph.nodes[n] == null) { continue; } if (n >= graph.nodes.Count) { return; } XNode.Node node = graph.nodes[n]; // Culling if (e.type == EventType.Layout) { // Cull unselected nodes outside view if (!Selection.Contains(node) && ShouldBeCulled(node)) { culledNodes.Add(node); continue; } } else if (culledNodes.Contains(node)) { continue; } if (e.type == EventType.Repaint) { removeEntries.Clear(); foreach (var kvp in _portConnectionPoints) { if (kvp.Key.node == node) { removeEntries.Add(kvp.Key); } } foreach (var k in removeEntries) { _portConnectionPoints.Remove(k); } } NodeEditor nodeEditor = NodeEditor.GetEditor(node, this); NodeEditor.portPositions.Clear(); // Set default label width. This is potentially overridden in OnBodyGUI EditorGUIUtility.labelWidth = nodeEditor.GetLabelWidth(); //Get node position Vector2 nodePos = GridToWindowPositionNoClipped(node.position); GUILayout.BeginArea(new Rect(nodePos, new Vector2(nodeEditor.GetWidth(), 4000))); bool selected = selectionCache.Contains(graph.nodes[n]); if (selected) { GUIStyle style = new GUIStyle(nodeEditor.GetBodyStyle()); GUIStyle highlightStyle = new GUIStyle(nodeEditor.GetBodyHighlightStyle()); highlightStyle.padding = style.padding; style.padding = new RectOffset(); GUI.color = nodeEditor.GetTint(); GUILayout.BeginVertical(style); GUI.color = NodeEditorPreferences.GetSettings().highlightColor; GUILayout.BeginVertical(new GUIStyle(highlightStyle)); } else { GUIStyle style = new GUIStyle(nodeEditor.GetBodyStyle()); GUI.color = nodeEditor.GetTint(); GUILayout.BeginVertical(style); } GUI.color = guiColor; EditorGUI.BeginChangeCheck(); //Draw node contents nodeEditor.OnHeaderGUI(); nodeEditor.OnBodyGUI(); //If user changed a value, notify other scripts through onUpdateNode if (EditorGUI.EndChangeCheck()) { if (NodeEditor.onUpdateNode != null) { NodeEditor.onUpdateNode(node); } EditorUtility.SetDirty(node); nodeEditor.serializedObject.ApplyModifiedProperties(); } GUILayout.EndVertical(); //Cache data about the node for next frame if (e.type == EventType.Repaint) { Vector2 size = GUILayoutUtility.GetLastRect().size; if (nodeSizes.ContainsKey(node)) { nodeSizes[node] = size; } else { nodeSizes.Add(node, size); } foreach (var kvp in NodeEditor.portPositions) { Vector2 portHandlePos = kvp.Value; portHandlePos += node.position; Rect rect = new Rect(portHandlePos.x - 8, portHandlePos.y - 8, 16, 16); portConnectionPoints[kvp.Key] = rect; } } if (selected) { GUILayout.EndVertical(); } if (e.type != EventType.Layout) { //Check if we are hovering this node Vector2 nodeSize = GUILayoutUtility.GetLastRect().size; Rect windowRect = new Rect(nodePos, nodeSize); if (windowRect.Contains(mousePos)) { hoveredNode = node; } //If dragging a selection box, add nodes inside to selection if (currentActivity == NodeActivity.DragGrid) { if (windowRect.Overlaps(selectionBox)) { preSelection.Add(node); } } //Check if we are hovering any of this nodes ports //Check input ports foreach (XNode.NodePort input in node.Inputs) { //Check if port rect is available if (!portConnectionPoints.ContainsKey(input)) { continue; } Rect r = GridToWindowRectNoClipped(portConnectionPoints[input]); if (r.Contains(mousePos)) { hoveredPort = input; } } //Check all output ports foreach (XNode.NodePort output in node.Outputs) { //Check if port rect is available if (!portConnectionPoints.ContainsKey(output)) { continue; } Rect r = GridToWindowRectNoClipped(portConnectionPoints[output]); if (r.Contains(mousePos)) { hoveredPort = output; } } } GUILayout.EndArea(); } if (e.type != EventType.Layout && currentActivity == NodeActivity.DragGrid) { Selection.objects = preSelection.ToArray(); } EndZoomed(position, zoom, topPadding); //If a change in is detected in the selected node, call OnValidate method. //This is done through reflection because OnValidate is only relevant in editor, //and thus, the code should not be included in build. if (onValidate != null && EditorGUI.EndChangeCheck()) { onValidate.Invoke(Selection.activeObject, null); } }