public override void OnInspectorGUI() { serializedObject.Update(); //OYM:更新表现形式; if (!Application.isPlaying) { EditorGUILayout.PropertyField(serializedObject.FindProperty("settings"), new GUIContent("全局关联设置"), true); Titlebar("=============== 节点设置", new Color(0.7f, 1.0f, 0.7f)); controller.generateTransform = (Transform)EditorGUILayout.ObjectField(new GUIContent("搜索起始点"), controller.generateTransform, typeof(Transform), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("generateKeyWordWhiteList"), new GUIContent("识别关键词"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("blackListOfGenerateTransform"), new GUIContent("节点黑名单"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("generateKeyWordBlackList"), new GUIContent("关键词黑名单"), true); if (GUILayout.Button("生成节点数据", GUILayout.Height(22.0f))) { controller.ListCheck(); controller.InitializePoint(); controller.isDebug = true; } if (controller.allPointTrans != null) { EditorGUILayout.PropertyField(serializedObject.FindProperty("inspectorPointList"), new GUIContent("所有节点坐标 :" + controller.allPointTrans?.Count), true); GUILayout.Space(5); } Titlebar("=============== 碰撞体设置", new Color(0.7f, 1.0f, 0.7f)); string key = controller.isGenerateColliderAutomaitc ? "生成" : "刷新"; if (GUILayout.Button(key + "碰撞体", GUILayout.Height(22.0f))) { controller.initializeCollider(); controller.isDebug = true; } controller.isGenerateColliderAutomaitc = EditorGUILayout.Toggle("自动生成全身碰撞体 ", controller.isGenerateColliderAutomaitc); if (controller.isGenerateColliderAutomaitc) { controller.isGenerateByAllPoint = EditorGUILayout.Toggle(" ┗━以所有节点作为参照 ", controller.isGenerateByAllPoint); } if (controller.editorColliderList != null) { EditorGUILayout.PropertyField(serializedObject.FindProperty("editorColliderList"), new GUIContent("碰撞体列表 :" + controller.editorColliderList?.Count), true); GUILayout.Space(5); if (controller.editorColliderList.Count > 0) { if (GUILayout.Button("移除所有碰撞体", GUILayout.Height(22.0f))) { if (controller.editorColliderList == null) { return; } if (isDeleteCollider) { for (int i = 0; i < controller.editorColliderList.Count; i++) { DestroyImmediate(controller.editorColliderList[i]); } isDeleteCollider = false; } controller.editorColliderList = null; } isDeleteCollider = EditorGUILayout.Toggle("同时删去碰撞体脚本", isDeleteCollider); } } Titlebar("=============== physical setting", new Color(0.7f, 1.0f, 0.7f)); controller.delayTime = EditorGUILayout.FloatField("延迟时间", controller.delayTime); } else { Titlebar("运行中", new Color(0.5F, 1, 1)); EditorGUILayout.PropertyField(serializedObject.FindProperty("settings"), new GUIContent("全局关联设置"), true); GUILayout.Space(10); Titlebar("=============== 节点设置", new Color(0.5F, 1, 1)); if (GUILayout.Button("重置所有节点位置", GUILayout.Height(22.0f))) { controller.RestorePoint(); } if (GUILayout.Button("重置所有节点数据并重新运行", GUILayout.Height(22.0f))) { controller.Reset(); } if (controller.allPointTrans != null) { EditorGUILayout.PropertyField(serializedObject.FindProperty("inspectorPointList"), new GUIContent("所有节点坐标 :" + controller.allPointTrans?.Count), true); } Titlebar("===============碰撞体设定", new Color(0.5F, 1, 1)); GUILayout.Space(5); if (GUILayout.Button("重新绘制碰撞体", GUILayout.Height(22.0f))) { for (int i = 0; i < controller.editorColliderList.Count; i++) { controller.editorColliderList[i].Refresh(); } controller.isDebug = true; } if (controller.editorColliderList != null) { EditorGUILayout.PropertyField(serializedObject.FindProperty("editorColliderList"), new GUIContent("碰撞体列表 :" + controller.editorColliderList?.Count), true); } Titlebar("=============== physical setting", new Color(0.5F, 1, 1)); } controller.isDebug = EditorGUILayout.Toggle("是否绘制所有辅助线", controller.isDebug); controller.isOptimize = EditorGUILayout.Toggle("轨迹优化", controller.isOptimize); controller.isFuzzyCompute = EditorGUILayout.Toggle("高性能模式", controller.isFuzzyCompute); controller.iteration = EditorGUILayout.IntSlider("迭代次数", controller.iteration, 1, max * (controller.isFuzzyCompute?8:1) * (controller.isDebug?2:1)); if (controller.iteration > 256) { controller.isDetectAsync = EditorGUILayout.Toggle("自动优化迭代次数", controller.isDetectAsync); } controller.windForceScale = EditorGUILayout.Slider("风力", controller.windForceScale, 0, 1); controller.colliderCollisionType = (ColliderCollisionType)EditorGUILayout.EnumPopup("碰撞模式", (ColliderCollisionTypeZh)controller.colliderCollisionType); if (controller.colliderCollisionType == 0) { controller.colliderCollisionType = ColliderCollisionType.Constraint; } serializedObject.ApplyModifiedProperties(); }
/// <summary> /// /// </summary> /// <returns></returns> protected override int DrawAndUpdateValue() { return(EditorGUILayout.IntSlider(Label, m_cachedValue, LeftValue, RightValue)); }
private void ShowBulkOperations() { GUILayout.BeginArea(new Rect(0, 616, 895, 200)); GUILayout.BeginHorizontal(EditorStyles.objectFieldThumb); GUI.contentColor = DTGUIHelper.BrightButtonColor; GUILayout.Label("Bulk Settings: Click Copy buttons to copy setting to all selected."); // the setting above it to all selected. GUILayout.Space(26); GUI.contentColor = DTGUIHelper.BrightButtonColor; if (GUILayout.Button(new GUIContent("Copy", "Copy Compression bitrate above to all selected"), EditorStyles.toolbarButton, GUILayout.Width(45))) { CopyBitrateToSelected(); } GUILayout.Space(6); if (GUILayout.Button(new GUIContent("Copy", "Copy 3D setting above to all selected"), EditorStyles.toolbarButton, GUILayout.Width(45))) { Copy3DToSelected(); } GUILayout.Space(8); if (GUILayout.Button(new GUIContent("Copy", "Copy Force Mono setting above to all selected"), EditorStyles.toolbarButton, GUILayout.Width(45))) { CopyForceMonoToSelected(); } GUILayout.Space(26); if (GUILayout.Button(new GUIContent("Copy", "Copy Audio Format setting above to all selected"), EditorStyles.toolbarButton, GUILayout.Width(45))) { CopyFormatToSelected(); } GUILayout.Space(101); if (GUILayout.Button(new GUIContent("Copy", "Copy Load Type setting above to all selected"), EditorStyles.toolbarButton, GUILayout.Width(45))) { CopyLoadTypeToSelected(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUI.contentColor = Color.white; GUILayout.BeginHorizontal(DTGUIHelper.CornerGUIStyle); GUILayout.Space(246); _bulkBitrate = EditorGUILayout.IntSlider("", _bulkBitrate / 1000, 32, 256, GUILayout.Width(202)) * 1000; GUILayout.Space(13); _bulk3D = GUILayout.Toggle(_bulk3D, ""); GUILayout.Space(36); _bulkForceMono = GUILayout.Toggle(_bulkForceMono, ""); GUILayout.Space(35); _bulkFormat = (AudioImporterFormat)EditorGUILayout.EnumPopup(_bulkFormat, GUILayout.Width(136)); GUILayout.Space(6); _bulkLoadType = (AudioImporterLoadType)EditorGUILayout.EnumPopup(_bulkLoadType, GUILayout.Width(140)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndArea(); }
private void DrawClass(RPGDatabaseManager database) { var weaponTypeIds = database.FetchEntry <WeaponTypeDataList>().entries.Select(l => l.Id).ToArray(); var weaponTypeNames = database.FetchEntry <WeaponTypeDataList>().entries.Select(l => l.name).ToArray(); var skillIds = database.FetchEntry <SkillDataList>().entries.Select(l => l.Id).ToArray(); var skillNames = database.FetchEntry <SkillDataList>().entries.Select(l => l.name).ToArray(); var entry = (ActorClassData)entrySelected; EditorGUILayout.BeginVertical("GroupBox", GUILayout.Width(400)); classAreaVect = EditorGUILayout.BeginScrollView(classAreaVect, GUILayout.Width(400)); DrawTitle(); entry.name = EditorGUILayout.TextField("Name", entry.name); #region Growth BrightEditorGUILayout.LabelFieldBold("Growth"); entry.expCurve = EditorGUILayout.CurveField(Constants.Attributes.EXP, entry.expCurve, GUILayout.Height(25f)); entry.hpCurve = EditorGUILayout.CurveField(Constants.Attributes.HP, entry.hpCurve, GUILayout.Height(25f)); entry.mpCurve = EditorGUILayout.CurveField(Constants.Attributes.MP, entry.mpCurve, GUILayout.Height(25f)); entry.strCurve = EditorGUILayout.CurveField(Constants.Attributes.STR, entry.strCurve, GUILayout.Height(25f)); entry.intCurve = EditorGUILayout.CurveField(Constants.Attributes.INT, entry.intCurve, GUILayout.Height(25f)); entry.dexCurve = EditorGUILayout.CurveField(Constants.Attributes.DEX, entry.dexCurve, GUILayout.Height(25f)); entry.agiCurve = EditorGUILayout.CurveField(Constants.Attributes.AGI, entry.agiCurve, GUILayout.Height(25f)); entry.lckCurve = EditorGUILayout.CurveField(Constants.Attributes.LCK, entry.lckCurve, GUILayout.Height(25f)); entry.defCurve = EditorGUILayout.CurveField(Constants.Attributes.DEF, entry.defCurve, GUILayout.Height(25f)); entry.resCurve = EditorGUILayout.CurveField(Constants.Attributes.RES, entry.resCurve, GUILayout.Height(25f)); #endregion #region Preview EditorGUILayout.BeginVertical("GroupBox", GUILayout.Width(350)); var list = database.FetchEntry <AttributeSpecDataList>(); var level = list.entries.First(x => x.name == Constants.Attributes.LEVEL); var exp = list.entries.First(x => x.name == Constants.Attributes.EXP); var hp = list.entries.First(x => x.name == Constants.Attributes.HP); var mp = list.entries.First(x => x.name == Constants.Attributes.MP); var attr = list.entries.First(x => x.name == Constants.Attributes.COMMON); BrightEditorGUILayout.LabelFieldBold("Preview"); previewLv = EditorGUILayout.IntSlider(Constants.Attributes.LEVEL_SHORT, previewLv, level.start, level.end); float normalizedValue = Mathf.InverseLerp(level.start, level.end, previewLv); float targetCurveValue = 0f; targetCurveValue = entry.expCurve.Evaluate(normalizedValue); EditorGUILayout.LabelField($"{Constants.Attributes.EXP}:\t{exp.FetchAtCurvePoint(targetCurveValue)}"); targetCurveValue = entry.hpCurve.Evaluate(normalizedValue); EditorGUILayout.LabelField($"{Constants.Attributes.HP}:\t{hp.FetchAtCurvePoint(targetCurveValue)}"); targetCurveValue = entry.mpCurve.Evaluate(normalizedValue); EditorGUILayout.LabelField($"{Constants.Attributes.MP}:\t{mp.FetchAtCurvePoint(targetCurveValue)}"); targetCurveValue = entry.strCurve.Evaluate(normalizedValue); EditorGUILayout.LabelField($"{Constants.Attributes.STR_SHORT}:\t{attr.FetchAtCurvePoint(targetCurveValue)}"); targetCurveValue = entry.intCurve.Evaluate(normalizedValue); EditorGUILayout.LabelField($"{Constants.Attributes.INT_SHORT}:\t{attr.FetchAtCurvePoint(targetCurveValue)}"); targetCurveValue = entry.dexCurve.Evaluate(normalizedValue); EditorGUILayout.LabelField($"{Constants.Attributes.DEX_SHORT}:\t{attr.FetchAtCurvePoint(targetCurveValue)}"); targetCurveValue = entry.agiCurve.Evaluate(normalizedValue); EditorGUILayout.LabelField($"{Constants.Attributes.AGI_SHORT}:\t{attr.FetchAtCurvePoint(targetCurveValue)}"); targetCurveValue = entry.lckCurve.Evaluate(normalizedValue); EditorGUILayout.LabelField($"{Constants.Attributes.LCK_SHORT}:\t{attr.FetchAtCurvePoint(targetCurveValue)}"); targetCurveValue = entry.defCurve.Evaluate(normalizedValue); EditorGUILayout.LabelField($"{Constants.Attributes.DEF_SHORT}:\t{attr.FetchAtCurvePoint(targetCurveValue)}"); targetCurveValue = entry.resCurve.Evaluate(normalizedValue); EditorGUILayout.LabelField($"{Constants.Attributes.RES_SHORT}:\t{attr.FetchAtCurvePoint(targetCurveValue)}"); EditorGUILayout.EndVertical(); #endregion #region Weapons EditorGUILayout.BeginVertical("GroupBox", GUILayout.Width(350)); BrightEditorGUILayout.LabelFieldBold("Weapon Type"); entry.weaponTypeId = EditorGUILayout.IntPopup(entry.weaponTypeId, weaponTypeNames, weaponTypeIds); EditorGUILayout.EndVertical(); #endregion #region Skills EditorGUILayout.BeginVertical("GroupBox", GUILayout.Width(350)); skillUnlockVect = EditorGUILayout.BeginScrollView(skillUnlockVect, GUILayout.MinHeight(90)); BrightEditorGUILayout.LabelFieldBold(Constants.SKILLS); if (entry.skills == null) { entry.skills = new System.Collections.Generic.List <SkillUnlockArgs>(); } for (int i = 0; i < entry.skills.Count; i++) { var skillUnlockArgs = entry.skills[i]; EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); skillUnlockArgs.level = EditorGUILayout.IntField(Constants.Attributes.LEVEL_SHORT, skillUnlockArgs.level); skillUnlockArgs.skillId = EditorGUILayout.IntPopup(skillUnlockArgs.skillId, skillNames, skillIds); if (GUILayout.Button("-", GUILayout.Width(20f))) { entry.skills.RemoveAt(i); break; } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+", GUILayout.Width(40f))) { entry.skills.Add(new SkillUnlockArgs()); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); #endregion EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }
public override void OnInspectorGUI() { Actor myActor = target as Actor; myActor.actorName = EditorGUILayout.TextField("Actor name", myActor.actorName); if (myActor.actorName == "") { myActor.actorName = myActor.name; } // max hit points myActor.maxHitPoints = EditorGUILayout.IntSlider("Max Hit Points", myActor.maxHitPoints, 0, 1000); // current hit points myActor.hitPoints = EditorGUILayout.IntSlider("Current Hit Points", myActor.hitPoints, 0, 1000); // Initiative myActor.initiative = EditorGUILayout.IntSlider("Initiative", myActor.initiative, 0, 50); // Damage myActor.damage = EditorGUILayout.IntSlider("Damage", myActor.damage, 0, 180); // Action target Actor.ActionTarget[] targetValue = Enum.GetValues(typeof(Actor.ActionTarget)) as Actor.ActionTarget[]; string[] targetName = Enum.GetNames(typeof(Actor.ActionTarget)); SelectionList <Actor.ActionTarget> targetSource = new SelectionList <Actor.ActionTarget>(targetValue, targetName); myActor.actionTarget = targetSource.RadioList("Action Target", myActor.actionTarget, 3); // Action Effect Actor.ActionEffect[] effectValue = Enum.GetValues(typeof(Actor.ActionEffect)) as Actor.ActionEffect[]; string[] effectName = Enum.GetNames(typeof(Actor.ActionTarget)); SelectionList <Actor.ActionEffect> actionEffect = new SelectionList <Actor.ActionEffect>(effectValue, effectName); myActor.actionEffect = actionEffect.RadioList("Action Effect", myActor.actionEffect, 3); // for action effect source Actor.ActionSource[] sourceValues = Enum.GetValues(typeof(Actor.ActionSource)) as Actor.ActionSource[]; string[] sourceNames = Enum.GetNames(typeof(Actor.ActionSource)); SelectionList <Actor.ActionSource> sources = new SelectionList <Actor.ActionSource>(sourceValues, sourceNames); isActionEffectShowing = EditorGUILayout.Foldout(isActionEffectShowing, "Action Effect Source"); if (isActionEffectShowing) { myActor.actionEffectSource = sources.RadioList("Action Effect Source", myActor.actionEffectSource, 3); } // myActor.immunities = immune.SelectionList(myActor.source); // Immunities isImmunitiesShowing = EditorGUILayout.Foldout(isImmunitiesShowing, "Immunities"); if (isImmunitiesShowing) { myActor.actionEffectSource = (Actor.ActionSource)EditorGUILayout.EnumPopup("Immunities", myActor.actionEffectSource); } // Percent Chance to hit myActor.percentChanceToHit = EditorGUILayout.Slider("Percent Chance", myActor.percentChanceToHit, 0.0f, 100.0f); // Board Position Actor.Position[] positionValue = Enum.GetValues(typeof(Actor.Position)) as Actor.Position[]; string[] positionName = Enum.GetNames(typeof(Actor.Position)); SelectionList <Actor.Position> position = new SelectionList <Actor.Position>(positionValue, positionName); isBoardShowing = EditorGUILayout.Foldout(isBoardShowing, "Board Position"); if (isBoardShowing) { myActor.boardPosition = position.RadioList("Board Position", myActor.boardPosition, 3); } }
public override void OnInspectorGUI() { EditorGUIUtility.LookLikeControls(80f); UISlider slider = target as UISlider; NGUIEditorTools.DrawSeparator(); float sliderValue = EditorGUILayout.Slider("Value", slider.sliderValue, 0f, 1f); if (slider.sliderValue != sliderValue) { NGUIEditorTools.RegisterUndo("Slider Change", slider); slider.sliderValue = sliderValue; UnityEditor.EditorUtility.SetDirty(slider); } int steps = EditorGUILayout.IntSlider("Steps", slider.numberOfSteps, 0, 11); if (slider.numberOfSteps != steps) { NGUIEditorTools.RegisterUndo("Slider Change", slider); slider.numberOfSteps = steps; slider.ForceUpdate(); UnityEditor.EditorUtility.SetDirty(slider); } NGUIEditorTools.DrawSeparator(); Vector2 size = slider.fullSize; GUILayout.Label(" Size"); GUILayout.Space(-36f); GUILayout.BeginHorizontal(); GUILayout.Space(66f); size = EditorGUILayout.Vector2Field("", size); GUILayout.Space(18f); GUILayout.EndHorizontal(); if (mShowWarning && slider.foreground != null) { UIWidget widget = slider.foreground.GetComponent <UIWidget>(); if (widget != null && !(widget is UIFilledSprite)) { GUI.color = new Color(1f, 0.7f, 0f); GUILayout.Label("Don't forget to adjust the background as well"); GUILayout.Label("(the slider doesn't know what it is)"); GUI.color = Color.white; } } Transform fg = EditorGUILayout.ObjectField("Foreground", slider.foreground, typeof(Transform), true) as Transform; Transform tb = EditorGUILayout.ObjectField("Thumb", slider.thumb, typeof(Transform), true) as Transform; UISlider.Direction dir = (UISlider.Direction)EditorGUILayout.EnumPopup("Direction", slider.direction); // If we're using a sprite for the foreground, ensure it's using a proper pivot. ValidatePivot(fg, "Foreground sprite", dir); NGUIEditorTools.DrawSeparator(); GameObject er = EditorGUILayout.ObjectField("Event Recv.", slider.eventReceiver, typeof(GameObject), true) as GameObject; GUILayout.BeginHorizontal(); string fn = EditorGUILayout.TextField("Function", slider.functionName); GUILayout.Space(18f); GUILayout.EndHorizontal(); if (slider.foreground != fg || slider.thumb != tb || slider.direction != dir || slider.fullSize != size || slider.eventReceiver != er || slider.functionName != fn) { if (slider.fullSize != size) { mShowWarning = true; } NGUIEditorTools.RegisterUndo("Slider Change", slider); slider.foreground = fg; slider.thumb = tb; slider.direction = dir; slider.fullSize = size; slider.eventReceiver = er; slider.functionName = fn; if (slider.thumb != null) { slider.thumb.localPosition = Vector3.zero; slider.sliderValue = -1f; slider.sliderValue = sliderValue; } else { slider.ForceUpdate(); } UnityEditor.EditorUtility.SetDirty(slider); } }
public override void OnInspectorGUI() { CheckGUIRes(); EditorGUILayout.Space(); _currentMenuBar = GUILayout.Toolbar(_currentMenuBar, _menuBars); EditorGUILayout.Space(); if (_currentMenuBar == 0) { Rect boxRectBegin = GUILayoutUtility.GetLastRect(); if (_editor._prototypes.Count > 0) { GUILayoutOption preViewImageWidth = GUILayout.Width(IMAGE_SIZE); GUILayoutOption preViewImageHeight = GUILayout.Height(IMAGE_SIZE); int rows = Mathf.CeilToInt(_editor._prototypes.Count / (float)IMAGES_PER_ROW); EditorGUILayout.BeginVertical(); for (int r = 0; r < rows; r++) { EditorGUILayout.BeginHorizontal(); for (int i = r * IMAGES_PER_ROW; i < (r + 1) * IMAGES_PER_ROW && i < _editor._prototypes.Count; i++) { _previewImageStyle.normal.background = _currentDetailSel == i ? _editor._buttonOnTex : _editor._buttonOffTex; EditorGUILayout.BeginVertical(); Texture2D imgPreview = GetImagePreView(_editor._prototypes[i]); if (GUILayout.Button(imgPreview, _previewImageStyle, preViewImageWidth, preViewImageHeight)) { if (_currentDetailSel == i) { _currentDetailSel = -1; } else { _currentDetailSel = i; } } EditorGUI.BeginChangeCheck(); Material newMaterial = EditorGUILayout.ObjectField(_editor._prototypes[i]._material, typeof(Material), false, preViewImageWidth) as Material; if (EditorGUI.EndChangeCheck()) { SetPrototypeMaterial(_editor._prototypes[i], newMaterial); } EditorGUILayout.EndVertical(); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("New")) { Undo.RecordObject(_editor, "Add New Prototype"); NewPrototype(); } if (_currentDetailSel != -1) { if (GUILayout.Button("Edit")) { GrassPrototypeEditor editWindow = ScriptableObject.CreateInstance <GrassPrototypeEditor>(); editWindow._parent = this; editWindow._prototype = _editor._prototypes[_currentDetailSel]; editWindow.Show(); } if (GUILayout.Button("Delete")) { bool remove = true; if (_editor._prototypes[_currentDetailSel]._material != null) { if (!EditorUtility.DisplayDialog("确认删除吗?", "这将删除所有使用当前材质的草!!!", "确认", "取消")) { remove = false; } } if (remove) { Undo.RecordObject(_editor, "Delete Prototype"); if (RemovePrototype(_currentDetailSel)) { if (_editor._prototypes.Count == 0) { _currentDetailSel = -1; } else if (_currentDetailSel >= _editor._prototypes.Count) { _currentDetailSel = _editor._prototypes.Count - 1; } } } } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); Rect boxRectEnd = GUILayoutUtility.GetLastRect(); GUI.Box(new Rect(boxRectBegin.xMin - 3, boxRectBegin.yMin, (IMAGE_SIZE + 6) * IMAGES_PER_ROW + 6, boxRectEnd.yMax - boxRectBegin.yMin + 5), GUIContent.none); GUILayout.Space(10); EditorGUI.BeginChangeCheck(); int brushSize = EditorGUILayout.IntSlider("Brush Size", _editor._brushSize, 1, 20); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(_editor, "Set Brush Size"); _editor._brushSize = brushSize; } EditorGUI.BeginChangeCheck(); int density = EditorGUILayout.IntSlider("Density", _editor._density, 1, 20); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(_editor, "Set Brush Density"); _editor._density = density; } EditorGUI.BeginChangeCheck(); bool isKeepInDeep = EditorGUILayout.Toggle("Keep In Deep", _editor._isKeepInDeep); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(_editor, "Set Keep In Deep"); _editor._isKeepInDeep = isKeepInDeep; } EditorGUILayout.Space(); _showAdvanced = EditorGUILayout.Toggle("Advanced", _showAdvanced); if (_showAdvanced) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Delete Grass Root")) { if (EditorUtility.DisplayDialog("确认删除", "确认要删除跟对象吗?这样会删除场景中所有的草!", "确认", "取消")) { GameObject.DestroyImmediate(GrassRootGo); } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } } else if (_currentMenuBar == 1) //Setting { EditorGUI.BeginChangeCheck(); int layerMask = LayerMaskField("Culling Mask", _editor._layerMask); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(_editor, "Set Bursh Culling Mask"); _editor._layerMask = layerMask; BrushProjector.ignoreLayers = ~_editor._layerMask; } float scaleInLightmap = EditorGUILayout.FloatField("Scale In Lightmap", _editor._scaleInLightmap); if (scaleInLightmap < 0) { scaleInLightmap = 0; } if (scaleInLightmap != _editor._scaleInLightmap) { Undo.RecordObject(_editor, "Set Detail Scale In Lightmap"); _editor._scaleInLightmap = scaleInLightmap; UpdateAllScaleInLightmap(); } } }
public override void OnInspectorGUI() { var glowEffect = target as GlowEffect; if (glowEffect == null) { return; // How'd this happen? } EditorGUI.BeginChangeCheck(); // Glow Mode: EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Glow Mode", GUILayout.Width(150)); glowEffect.glowMode = (GlowEffect.GlowMode)EditorGUILayout.EnumPopup(glowEffect.glowMode); EditorGUILayout.EndHorizontal(); // Glow Material: EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Material", GUILayout.Width(150)); glowEffect.glowMaterial = (Material)EditorGUILayout.ObjectField(glowEffect.glowMaterial, typeof(Material), false); EditorGUILayout.EndHorizontal(); if (glowEffect.glowMode == GlowEffect.GlowMode.Glow || glowEffect.glowMode == GlowEffect.GlowMode.SimpleGlow) { // Glow Shader: EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Replacement Shader", GUILayout.Width(150)); glowEffect.glowReplaceShader = (Shader)EditorGUILayout.ObjectField(glowEffect.glowReplaceShader, typeof(Shader), false); EditorGUILayout.EndHorizontal(); } // Blend Mode: EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Blend Mode", GUILayout.Width(150)); glowEffect.blendMode = (GlowEffect.BlendMode)EditorGUILayout.EnumPopup(glowEffect.blendMode); EditorGUILayout.EndHorizontal(); // Downsample size. Must be a power of two EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Downsample Size", GUILayout.Width(150)); glowEffect.downsampleSize = (int)Mathf.Pow(2, Mathf.RoundToInt(GUILayout.HorizontalSlider((int)Mathf.Log(glowEffect.downsampleSize, 2), 1, 12, GUILayout.MaxWidth(1000)))); EditorGUILayout.LabelField(glowEffect.downsampleSize.ToString(), GUILayout.Width(50)); EditorGUILayout.EndHorizontal(); // Blur iterations EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Blur Iterations", GUILayout.Width(150)); glowEffect.blurIterations = EditorGUILayout.IntSlider(glowEffect.blurIterations, 1, 20); EditorGUILayout.EndHorizontal(); // Blur spread EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Blur Spread", GUILayout.Width(150)); glowEffect.blurSpread = EditorGUILayout.Slider(glowEffect.blurSpread, 0, 3); EditorGUILayout.EndHorizontal(); // Glow strength EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Glow Strength", GUILayout.Width(150)); glowEffect.glowStrength = EditorGUILayout.Slider(glowEffect.glowStrength, 0.5f, 10f); EditorGUILayout.EndHorizontal(); // Glow color multiplier EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Glow Color Multiplier", GUILayout.Width(150)); glowEffect.glowColorMultiplier = EditorGUILayout.ColorField(glowEffect.glowColorMultiplier); EditorGUILayout.EndHorizontal(); // Ignore layers (only applies to standard glow) if (glowEffect.glowMode == GlowEffect.GlowMode.Glow || glowEffect.glowMode == GlowEffect.GlowMode.SimpleGlow) { // Use a serialized property to display the layer mask correctly EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Ignore Layers", GUILayout.Width(150)); var serializedProperty = serializedObject.FindProperty("ignoreLayers"); EditorGUILayout.PropertyField(serializedProperty, new GUIContent()); EditorGUILayout.EndHorizontal(); } if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(glowEffect); } }
public override void OnInspectorGUI() { SimpleMenuCollection menu = (SimpleMenuCollection)target; HUXEditorUtils.BeginSectionBox("Menu settings"); menu.MaxButtons = EditorGUILayout.IntSlider("Num buttons", menu.MaxButtons, 1, 64); HUXEditorUtils.WarningMessage("Changing the number of buttons will erase existing buttons"); menu.DisplayTitle = EditorGUILayout.Toggle("Display Title", menu.DisplayTitle); if (menu.DisplayTitle) { //menu.TitleText.font = (Font)EditorGUILayout.ObjectField("Title font", menu.TitleText.font, typeof(Font), false); menu.Title = EditorGUILayout.TextField("Title", menu.Title); menu.TitleText = HUXEditorUtils.DropDownComponentField <TextMesh>("Title TextMesh", menu.TitleText, menu.transform); } menu.ButtonPrefab = (GameObject)EditorGUILayout.ObjectField("Button prefab", menu.ButtonPrefab, typeof(GameObject), false); menu.ParentCollection = HUXEditorUtils.DropDownComponentField <ObjectCollection>("Collection parent", menu.ParentCollection, menu.transform); if (menu.ButtonPrefab == null) { HUXEditorUtils.ErrorMessage("You must specify a button prefab"); HUXEditorUtils.EndSectionBox(); return; } if (menu.ParentCollection == null) { HUXEditorUtils.ErrorMessage("This menu needs a collection component to work", AddCollection, "Fix"); HUXEditorUtils.EndSectionBox(); return; } bool showIcon = false; bool showText = false; CompoundButtonIcon icon = menu.ButtonPrefab.GetComponent <CompoundButtonIcon>(); showIcon = icon != null; CompoundButtonText text = menu.ButtonPrefab.GetComponent <CompoundButtonText>(); showText = text != null; ButtonIconProfile profile = null; if (icon != null) { profile = icon.Profile; } HUXEditorUtils.BeginSubSectionBox("Buttons"); HUXEditorUtils.DrawSubtleMiniLabel("Up to " + menu.MaxButtons + " allowed. Un-named buttons will be ignored."); SimpleMenuCollectionButton[] buttons = menu.Buttons; HashSet <string> buttonNamesSoFar = new HashSet <string>(); int numButtons = 0; for (int i = 0; i < buttons.Length; i++) { if (!buttons[i].IsEmpty) { numButtons++; } DrawButtonEditor(buttons[i], showIcon, showText, profile, "buttons", i, buttonNamesSoFar); } HUXEditorUtils.EndSubSectionBox(); menu.EditorRefreshButtons(); HUXEditorUtils.BeginSubSectionBox("Menu preview"); HUXEditorUtils.DrawSubtleMiniLabel("An approximation of what the menu will look like."); List <SimpleMenuCollectionButton> buttonsList = new List <SimpleMenuCollectionButton>(buttons); buttonsList.Sort(delegate(SimpleMenuCollectionButton b1, SimpleMenuCollectionButton b2) { return(b1.Index.CompareTo(b2.Index)); }); scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, false, false, GUILayout.MinHeight(previewButtonSizeY * numButtons + 50f)); EditorGUILayout.BeginVertical(); bool drewOneButton = false; foreach (SimpleMenuCollectionButton button in buttonsList) { drewOneButton = DrawPreviewButton(button, showText); } if (!drewOneButton) { HUXEditorUtils.WarningMessage("This state has no buttons due to the options you've chosen. It won't be permitted during play mode."); } EditorGUILayout.EndVertical(); EditorGUILayout.EndScrollView(); HUXEditorUtils.EndSubSectionBox(); HUXEditorUtils.EndSectionBox(); HUXEditorUtils.SaveChanges(target, serializedObject); }
public override void OnInspectorGUI() { AddScriptNameField(m_Sel); m_UndoManager.CheckUndo(); Rect rect; m_FxmPopupManager = GetFxmPopupManager(); // -------------------------------------------------------------- bool bClickButton = false; EditorGUI.BeginChangeCheck(); { // DrawDefaultInspector(); m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag); m_Sel.m_NcSpriteFactoryPrefab = (GameObject)EditorGUILayout.ObjectField(GetHelpContent("m_NcSpriteFactoryPrefab"), m_Sel.m_NcSpriteFactoryPrefab, typeof(GameObject), false, null); // -------------------------------------------------------------- EditorGUILayout.Space(); rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight)); { if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 0, 1), GetHelpContent("Select SpriteFactory"), (m_FxmPopupManager != null))) { m_FxmPopupManager.ShowSelectPrefabPopup(m_Sel, true, 0); } if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 1, 1), GetHelpContent("Clear SpriteFactory"), (m_Sel.m_NcSpriteFactoryPrefab != null))) { bClickButton = true; m_Sel.m_NcSpriteFactoryPrefab = null; } if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 2, 1), GetHelpContent("Open Prefab"), (m_FxmPopupManager != null) && (m_Sel.m_NcSpriteFactoryPrefab != null))) { bClickButton = true; GetFXMakerMain().OpenPrefab(m_Sel.m_NcSpriteFactoryPrefab); return; } GUILayout.Label(""); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); // -------------------------------------------------------------- NcSpriteFactory ncSpriteFactory = (m_Sel.m_NcSpriteFactoryPrefab == null ? null : m_Sel.m_NcSpriteFactoryPrefab.GetComponent <NcSpriteFactory>()); if (ncSpriteFactory != null) { int nSelIndex = EditorGUILayout.IntSlider(GetHelpContent("m_nSpriteFactoryIndex"), m_Sel.m_nSpriteFactoryIndex, 0, ncSpriteFactory.GetSpriteNodeCount() - 1); if (m_Sel.m_nSpriteFactoryIndex != nSelIndex) { m_Sel.SetSpriteFactoryIndex(nSelIndex, m_Sel.m_nFrameIndex, false); } } // -------------------------------------------------------------- if (m_Sel.m_NcSpriteFactoryPrefab != null && m_Sel.m_NcSpriteFactoryPrefab.GetComponent <Renderer>() != null && m_Sel.GetComponent <Renderer>()) { if (m_Sel.m_NcSpriteFactoryPrefab.GetComponent <Renderer>().sharedMaterial != m_Sel.GetComponent <Renderer>().sharedMaterial) { m_Sel.UpdateSpriteMaterial(); } } // -------------------------------------------------------------- m_Sel.m_MeshType = (NcSpriteFactory.MESH_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_MeshType"), m_Sel.m_MeshType); m_Sel.m_AlignType = (NcSpriteFactory.ALIGN_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_AlignType"), m_Sel.m_AlignType); if (m_Sel.m_AlignType == NcSpriteFactory.ALIGN_TYPE.LEFTCENTER) { m_Sel.m_fShowRate = EditorGUILayout.FloatField(GetHelpContent("m_fShowRate"), m_Sel.m_fShowRate); } SetMaxValue(ref m_Sel.m_fShowRate, 1.0f); SetMinValue(ref m_Sel.m_fShowRate, 0); // -------------------------------------------------------------- if (ncSpriteFactory != null && ncSpriteFactory.IsValidFactory()) { // Texture -------------------------------------------------------------- rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(200)); { GUI.Box(rect, ""); GUILayout.Label(""); Rect subRect = rect; // draw texture if (0 < rect.width && m_Sel.GetComponent <Renderer>() != null && m_Sel.GetComponent <Renderer>().sharedMaterial != null && m_Sel.GetComponent <Renderer>().sharedMaterial.mainTexture != null) { int nClickFactoryIndex; int nClickFrameIndex; bClickButton = DrawTrimTexture(subRect, true, m_Sel.GetComponent <Renderer>().sharedMaterial, ncSpriteFactory, m_Sel.m_nSpriteFactoryIndex, m_Sel.m_nFrameIndex, true, out nClickFactoryIndex, out nClickFrameIndex); if (bClickButton) { m_Sel.SetSpriteFactoryIndex(nClickFactoryIndex, nClickFrameIndex, false); } } } EditorGUILayout.EndHorizontal(); } else { m_Sel.m_nSpriteFactoryIndex = -1; } } m_UndoManager.CheckDirty(); // -------------------------------------------------------------- if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain()) { OnEditComponent(); } // --------------------------------------------------------------------- if (GUI.tooltip != "") { m_LastTooltip = GUI.tooltip; } HelpBox(m_LastTooltip); }
public override void Draw(Rect windowRect) { base.Draw(windowRect); EditorGUILayout.Space(); terrain = (Terrain)EditorGUILayout.ObjectField("Terrain", terrain, typeof(Terrain), true); if (splines.Count == 0) { EditorGUILayout.HelpBox("No spline selected! Select an object with a SplineComputer component.", MessageType.Warning); } if (terrain == null) { EditorGUILayout.HelpBox("No terrain selected! You need to select a terrain.", MessageType.Warning); } if (splines.Count == 0 || terrain == null) { return; } if (!init) { init = true; brushPreview = GenerateBrushThumbnail(); } if (heights == null) { GetBase(); } GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); float lastSize = size; size = EditorGUILayout.FloatField("Brush radius", size); if (size < 0f) { size = 0f; } if (lastSize != size) { brushPreview = GenerateBrushThumbnail(); } int lastBlur = feather; int maxFeatherCount = Mathf.Max(heights.GetLength(0) / 64, 2); feather = EditorGUILayout.IntSlider("Feather", feather, 0, maxFeatherCount); if (lastBlur != feather) { brushPreview = GenerateBrushThumbnail(); } GUILayout.EndVertical(); GUILayout.Box("", GUILayout.Width(64), GUILayout.Height(64)); Rect rect = GUILayoutUtility.GetLastRect(); GUI.DrawTexture(rect, brushPreview); GUILayout.EndHorizontal(); offset = EditorGUILayout.FloatField("Height offset", offset); EditorGUILayout.MinMaxSlider(new GUIContent("Spline range"), ref clipFrom, ref clipTo, 0f, 1f); if (GUILayout.Button("Level")) { CarveTerrain(); } GUILayout.BeginHorizontal(); GUILayout.Label("Terrain heightmap:"); GUILayout.Label("Path heightmap:"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Box("", GUILayout.Width((windowRect.width - 10) / 2), GUILayout.Height((windowRect.width - 10) / 2)); rect = GUILayoutUtility.GetLastRect(); GUI.DrawTexture(rect, basePreview); GUILayout.Box("", GUILayout.Width((windowRect.width - 10) / 2), GUILayout.Height((windowRect.width - 10) / 2)); rect = GUILayoutUtility.GetLastRect(); GUI.DrawTexture(rect, drawPreview); GUILayout.EndHorizontal(); if (promptSave) { GUILayout.BeginHorizontal(); if (GUILayout.Button("Revert")) { RevertToBase(); } if (GUILayout.Button("Apply")) { SaveChanges(); } GUILayout.EndHorizontal(); } }
public override void OnInspectorGUI() { MegaFlowMovingSource mod = (MegaFlowMovingSource)target; serializedObject.Update(); #if !UNITY_5 && !UNITY_2017 && !UNITY_2018 && !UNITY_2019 && !UNITY_2020 EditorGUIUtility.LookLikeControls(); #endif EditorGUILayout.PropertyField(_prop_source, new GUIContent("Source")); if (mod.source) { if (mod.source.frames.Count > 1) { EditorGUILayout.IntSlider(_prop_framenum, 0, mod.source.frames.Count - 1); } if (GUILayout.Button("Align")) { mod.transform.position = mod.source.transform.position; mod.transform.rotation = mod.source.transform.rotation; mod.transform.localScale = mod.source.transform.lossyScale; if (mod.target) { mod.transform.parent = mod.target.transform; } } } EditorGUILayout.PropertyField(_prop_flowscale, new GUIContent("Flow Scale")); EditorGUILayout.PropertyField(_prop_target, new GUIContent("Target")); EditorGUILayout.PropertyField(_prop_flowtime, new GUIContent("Flow Time")); EditorGUILayout.PropertyField(_prop_flowtimestep, new GUIContent("Flow dt")); EditorGUILayout.PropertyField(_prop_mindist, new GUIContent("Min Dist")); EditorGUILayout.PropertyField(_prop_drawpath, new GUIContent("Draw Path")); EditorGUILayout.PropertyField(_prop_usefalloff, new GUIContent("Use Falloff")); EditorGUILayout.PropertyField(_prop_falloffcrv, new GUIContent("Falloff Curve")); #if false if (GUILayout.Button("Add Frame")) { mod.frames.Add(new MegaFlowPosFrame()); } for (int i = 0; i < mod.frames.Count; i++) { EditorGUILayout.BeginVertical("box"); mod.frames[i].time = EditorGUILayout.Slider("Alpha", mod.frames[i].time, 0.0f, 1.0f); mod.frames[i].frame = EditorGUILayout.IntSlider("Frame", mod.frames[i].frame, 0, mod.source.frames.Count - 1); if (GUILayout.Button("Delete")) { mod.frames.RemoveAt(i); } EditorGUILayout.EndVertical(); } for (int i = 0; i < mod.frames.Count; i++) { if (i == 0) { mod.frames[i].time = 0.0f; } else { if (mod.frames[i].time < mod.frames[i - 1].time) { mod.frames[i].time = mod.frames[i - 1].time; } } } if (mod.frames.Count > 1) { mod.frames[mod.frames.Count - 1].time = 1.0f; } #endif if (GUI.changed) { serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(target); } }
private void DrawScale() { Owner.scale = EditorGUILayout.IntSlider("Scale", Owner.scale, 0, 8); }
public void DrawSideWindow() { string canvasName = "Node Canvas"; if (canvasCache != null && !string.IsNullOrEmpty(canvasCache.openedCanvasPath)) { canvasName = canvasCache.openedCanvasPath.Substring(canvasCache.openedCanvasPath.LastIndexOf(@"/") + 1); canvasName = canvasName.Replace(".asset", ""); } GUILayout.Label(new GUIContent(canvasName)); if (GUILayout.Button(new GUIContent("Save Canvas", "Saves the Canvas to a Canvas Save File in the Assets Folder"))) { string lastpath = NodeEditor.editorPathLoadSave + "Saves/"; lastpath = GetLastUsedPath(lastpath); string path = EditorUtility.SaveFilePanelInProject("Save Node Canvas", canvasName, "asset", "", lastpath); if (!string.IsNullOrEmpty(path)) { canvasCache.SaveNodeCanvas(path); } /* * string path = EditorUtility.SaveFilePanelInProject ("Save Node Canvas", m_LastLoadedName, "asset", "", NodeEditor.editorPath + "Resources/Saves/"); * if (!string.IsNullOrEmpty(path)) * { * SaveNodeCanvas(path); * * } */ if (m_NodeSelectionWindow != null) { m_NodeSelectionWindow.ReInit(); } } /* * if (GUILayout.Button(new GUIContent("New Canvas", * "Create a copy"))) * { * CreateEditorCopy(); * } */ if (GUILayout.Button(new GUIContent("Load Canvas", "Loads the Canvas from a Canvas Save File in the Assets Folder"))) { string lastpath = NodeEditor.editorPathLoadSave + "Saves/"; lastpath = GetLastUsedPath(lastpath); Debug.Log(" last path for load canvas" + lastpath); string path = EditorUtility.OpenFilePanel("Load Node Canvas", lastpath, "asset"); if (!path.Contains(Application.dataPath)) { if (!string.IsNullOrEmpty(path)) { ShowNotification(new GUIContent("You should select an asset inside your project folder!")); } } else { NodeEditor.curEditorState = null; canvasCache.LoadNodeCanvas(path); canvasCache.NewEditorState(); } NodeEditor.RecalculateAll(canvasCache.nodeCanvas); } if (GUILayout.Button(new GUIContent("New TextureWang", "Create a new TextureWang Canvas"))) { NewTextureWangPopup.Init(this); } if (GUILayout.Button(new GUIContent("Recalculate All", "Initiates complete recalculate. Usually does not need to be triggered manually."))) { NodeEditor.RecalculateAll(canvasCache.nodeCanvas); GUI.changed = false; } if (GUILayout.Button(new GUIContent("Recalculate All Export PNG'S", "Initiates complete recalculate. Usually does not need to be triggered manually."))) { UnityTextureOutput.ms_ExportPNG = true; NodeEditor.RecalculateAll(canvasCache.nodeCanvas); GUI.changed = false; UnityTextureOutput.ms_ExportPNG = false; } // if (GUILayout.Button ("Force Re-Init")) // NodeEditor.ReInit (true); if (GUILayout.Button(new GUIContent("Double All texture Sizes", ""))) { foreach (var n in canvasCache.nodeCanvas.nodes) { if (n is TextureNode) { var tn = n as TextureNode; tn.m_TexWidth *= 2; tn.m_TexHeight *= 2; } } NodeEditor.RecalculateAll(canvasCache.nodeCanvas); } if (GUILayout.Button(new GUIContent("Halve All texture Sizes", ""))) { foreach (var n in canvasCache.nodeCanvas.nodes) { if (n is TextureNode) { var tn = n as TextureNode; tn.m_TexWidth >>= 1; tn.m_TexHeight >>= 1; } } NodeEditor.RecalculateAll(canvasCache.nodeCanvas); } bool changed = GUI.changed; GUI.changed = false; NodeEditorGUI.knobSize = EditorGUILayout.IntSlider(new GUIContent("Handle Size", "The size of the Node Input/Output handles"), NodeEditorGUI.knobSize, 12, 20); canvasCache.editorState.zoom = EditorGUILayout.Slider(new GUIContent("Zoom", "Use the Mousewheel. Seriously."), canvasCache.editorState.zoom, 0.2f, 4); m_OpenAppearance = EditorGUILayout.Foldout(m_OpenAppearance, ""); if (m_OpenAppearance) { Node.m_DropShadowMult = EditorGUILayout.Slider(new GUIContent("DropShadow", ""), Node.m_DropShadowMult, 0.0f, 1); Node.m_DropShadowMult2 = EditorGUILayout.Slider(new GUIContent("DropShadow Wires", ""), Node.m_DropShadowMult2, 0.0f, 1); Node.m_WireSize = EditorGUILayout.Slider(new GUIContent("m_WireSize", ""), Node.m_WireSize, 0.0f, 30); Node.m_WireSize2 = EditorGUILayout.Slider(new GUIContent("WireSize Shadow", ""), Node.m_WireSize2, 0.0f, 50); Node.m_Saturation = EditorGUILayout.Slider(new GUIContent("Saturation", ""), Node.m_Saturation, 0.0f, 1); Node.m_WireColbright = EditorGUILayout.Slider(new GUIContent("m_WireColbright", ""), Node.m_WireColbright, 0.0f, 1); Node.m_DropShadowOffset = EditorGUILayout.Slider(new GUIContent("DropShadowOffset", ""), Node.m_DropShadowOffset, -50.0f, 50); Node.m_DropShadowExpand = EditorGUILayout.Slider(new GUIContent("m_DropShadowExpand", ""), Node.m_DropShadowExpand, 0f, 50); } bool changeView = GUI.changed; GUI.changed = changed; if (canvasCache.nodeCanvas != null) { canvasCache.nodeCanvas.m_DefaultTextureWidth = EditorGUILayout.IntSlider(new GUIContent("Default tex Width", ""), canvasCache.nodeCanvas.m_DefaultTextureWidth, 1, 4096); canvasCache.nodeCanvas.m_DefaultTextureHeight = EditorGUILayout.IntSlider(new GUIContent("Default tex Height", ""), canvasCache.nodeCanvas.m_DefaultTextureHeight, 1, 4096); canvasCache.nodeCanvas.m_DefaultChannelType = (ChannelType)UnityEditor.EditorGUILayout.EnumPopup(new GUIContent("pixel Depth", ""), canvasCache.nodeCanvas.m_DefaultChannelType); } //miked mainNodeCanvas.scaleMode = (ScaleMode)EditorGUILayout.EnumPopup(new GUIContent("ScaleMode", ""), mainNodeCanvas.scaleMode, GUILayout.MaxWidth(200)); // m_OpType = (TexOP)UnityEditor.EditorGUILayout.EnumPopup(new GUIContent("Type", "The type of calculation performed on Input 1"), m_OpType, GUILayout.MaxWidth(200)); // if (mainNodeCanvas != null) { // EditorGUILayout.LabelField("width: " + mainNodeCanvas.m_TexWidth); // EditorGUILayout.LabelField("height: " + mainNodeCanvas.m_TexHeight); } /* * if (NodeEditor.curEditorState == null) * { * Debug.Log("TWWindow has no editor state " + NodeEditor.curEditorState); * } * else if (NodeEditor.curEditorState.selectedNode == null) * { * Debug.Log("TWWindow has no Selected Node " + NodeEditor.curEditorState); * } * else * { * Debug.Log(" Selected Node " + NodeEditor.curEditorState.selectedNode); * } */ if (canvasCache.editorState != null && canvasCache.editorState.selectedNode != null) // if (Event.current.type != EventType.Ignore) { RTEditorGUI.Seperator(); GUILayout.Label(canvasCache.editorState.selectedNode.name); RTEditorGUI.Seperator(); if (canvasCache.editorState.selectedNode is SubTreeNode) { if (GUILayout.Button("Edit Sub Canvas")) { string NodeCanvasPath = AssetDatabase.GUIDToAssetPath((canvasCache.editorState.selectedNode as SubTreeNode).m_CanvasGuid); NodeEditor.curEditorState = null; canvasCache.LoadNodeCanvas(NodeCanvasPath); canvasCache.NewEditorState(); } } if (canvasCache.editorState.selectedNode) { canvasCache.editorState.selectedNode.DrawNodePropertyEditor(); } if (GUI.changed && canvasCache.editorState.selectedNode) { NodeEditor.RecalculateFrom(PriorLoop(canvasCache.editorState.selectedNode)); } else if (changeView) { Repaint(); } } // var assets = UnityEditor.AssetDatabase.FindAssets("NodeCanvas"); // foreach(var x in assets) // GUILayout.Label(new GUIContent("Node Editor (" + x + ")", "Opened Canvas path: " ), NodeEditorGUI.nodeLabelBold); /* * if (m_All == null) * m_All = GetAtPath<NodeCanvas>("Node_Editor-master/Node_Editor/Resources/Saves");//Resources.LoadAll<NodeCanvas>(NodeEditor.editorPath + "Resources/Saves/"); * * scrollPos =EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(300), GUILayout.Height(600)); * guiStyle.fontSize = 20; * guiStyle.fixedHeight = 20; * foreach (var x in m_All) * EditorGUILayout.SelectableLabel("(" + x.name + ")", guiStyle); * EditorGUILayout.EndScrollView(); */ }
protected override bool OnCustomInspector() { var control = target as dfDropdown; if (control == null) { return(false); } dfEditorUtil.DrawSeparator(); if (!isFoldoutExpanded(foldouts, "DropdownList Properties", true)) { return(false); } dfEditorUtil.LabelWidth = 110f; using (dfEditorUtil.BeginGroup("Dropdown List")) { var trigger = EditorGUILayout.ObjectField("Trigger", control.TriggerButton, typeof(dfControl), true) as dfControl; if (trigger != control.TriggerButton) { dfEditorUtil.MarkUndo(control, "Change trigger button"); control.TriggerButton = trigger; } var triggerOnMouse = EditorGUILayout.Toggle("Open on Click", control.OpenOnMouseDown); if (triggerOnMouse != control.OpenOnMouseDown) { dfEditorUtil.MarkUndo(control, "Change trigger action"); control.OpenOnMouseDown = triggerOnMouse; } EditorGUI.BeginChangeCheck(); var useSpacebarToClick = EditorGUILayout.Toggle("Space to Click", control.ClickWhenSpacePressed); if (EditorGUI.EndChangeCheck()) { dfEditorUtil.MarkUndo(control, "Change ClickWhenSpacePressed property"); control.ClickWhenSpacePressed = useSpacebarToClick; } var index = EditorGUILayout.IntSlider("Selected Index", control.SelectedIndex, -1, control.Items.Length - 1); if (index != control.SelectedIndex) { dfEditorUtil.MarkUndo(control, "Change Selected Index"); control.SelectedIndex = index; } } using (dfEditorUtil.BeginGroup("Images And Colors")) { SelectTextureAtlas("Atlas", control, "Atlas", false, true); SelectSprite("Normal", control.Atlas, control, "BackgroundSprite"); SelectSprite("Focus", control.Atlas, control, "FocusSprite", false); SelectSprite("Hover", control.Atlas, control, "HoverSprite", false); SelectSprite("Disabled", control.Atlas, control, "DisabledSprite", false); var backColor = EditorGUILayout.ColorField("Normal Back", control.Color); if (backColor != control.Color) { dfEditorUtil.MarkUndo(control, "Change Background Color"); control.Color = backColor; } backColor = EditorGUILayout.ColorField("Disabled Back", control.DisabledColor); if (backColor != control.DisabledColor) { dfEditorUtil.MarkUndo(control, "Change Background Color"); control.DisabledColor = backColor; } } using (dfEditorUtil.BeginGroup("Text Appearance")) { SelectFontDefinition("Font", control.Atlas, control, "Font", true, true); if (control.Font == null) { return(false); } var textColor = EditorGUILayout.ColorField("Normal Text", control.TextColor); if (textColor != control.TextColor) { dfEditorUtil.MarkUndo(control, "Change Text Color"); control.TextColor = textColor; } var disabledTextColor = EditorGUILayout.ColorField("Disabled", control.DisabledTextColor); if (disabledTextColor != control.DisabledTextColor) { dfEditorUtil.MarkUndo(control, "Change Text Color"); control.DisabledTextColor = disabledTextColor; } var effectiveFontSize = Mathf.CeilToInt(control.Font.FontSize * control.TextScale); EditorGUI.BeginChangeCheck(); effectiveFontSize = EditorGUILayout.IntField("Font Size", effectiveFontSize); if (EditorGUI.EndChangeCheck()) { dfEditorUtil.MarkUndo(control, "Change Font Size"); control.TextScale = (float)effectiveFontSize / (float)control.Font.FontSize; } var padding = dfEditorUtil.EditPadding("Padding", control.TextFieldPadding); if (padding != control.TextFieldPadding) { dfEditorUtil.MarkUndo(control, "Change control Padding"); control.TextFieldPadding = padding; } var shadow = EditorGUILayout.Toggle("Shadow Effect", control.Shadow); if (shadow != control.Shadow) { dfEditorUtil.MarkUndo(control, "Change Shadow Effect"); control.Shadow = shadow; } if (shadow) { var shadowColor = EditorGUILayout.ColorField("Shadow Color", control.ShadowColor); if (shadowColor != control.ShadowColor) { dfEditorUtil.MarkUndo(control, "Change Shadow Color"); control.ShadowColor = shadowColor; } var shadowOffset = dfEditorUtil.EditInt2("Shadow Offset", "X", "Y", control.ShadowOffset); if (shadowOffset != control.ShadowOffset) { dfEditorUtil.MarkUndo(control, "Change Shadow Color"); control.ShadowOffset = shadowOffset; } } } using (dfEditorUtil.BeginGroup("List Appearance")) { SelectSprite("List Background", control.Atlas, control, "ListBackground"); SelectSprite("Item Highlight", control.Atlas, control, "ItemHighlight", false); SelectSprite("Item Hover", control.Atlas, control, "ItemHover", false); } using (dfEditorUtil.BeginGroup("List Options")) { dfPrefabSelectionDialog.FilterCallback filterScrollbar = (item) => { var scrollbar = item.GetComponent <dfScrollbar>(); var scrollAtlas = scrollbar.Atlas; return(dfAtlas.Equals(control.Atlas, scrollAtlas)); }; SelectPrefab <dfScrollbar>("Scroll Bar", control, "ListScrollbar", null, filterScrollbar); var itemHeight = EditorGUILayout.IntField("Item Height", control.ItemHeight); if (itemHeight != control.ItemHeight) { dfEditorUtil.MarkUndo(control, "Adjust List Item Height"); control.ItemHeight = itemHeight; } var listPosition = (dfDropdown.PopupListPosition)EditorGUILayout.EnumPopup("List Position", control.ListPosition); if (listPosition != control.ListPosition) { dfEditorUtil.MarkUndo(control, "Change list position"); control.ListPosition = listPosition; } var maxWidth = EditorGUILayout.IntField("Max List Width", control.MaxListWidth); if (maxWidth != control.MaxListWidth) { dfEditorUtil.MarkUndo(control, "Change max list width"); control.MaxListWidth = maxWidth; } var maxHeight = EditorGUILayout.IntField("Max List Height", control.MaxListHeight); if (maxHeight != control.MaxListHeight) { dfEditorUtil.MarkUndo(control, "Change max list height"); control.MaxListHeight = maxHeight; } var listOffset = dfEditorUtil.EditInt2("Offset", "X", "Y", control.ListOffset); if (listOffset != control.ListOffset) { dfEditorUtil.MarkUndo(control, "Change list offset"); control.ListOffset = listOffset; } var listPadding = dfEditorUtil.EditPadding("Padding", control.ListPadding); if (!listPadding.Equals(control.ListPadding)) { dfEditorUtil.MarkUndo(control, "Modify padding"); control.ListPadding = listPadding; } } using (dfEditorUtil.BeginGroup("List Data")) { EditOptions(control); } return(true); }
public override void OnInspectorGUI() { m_QueuedChanges.Clear(); serializedObject.UpdateIfRequiredOrScript(); // use updated values EditorGUI.BeginChangeCheck(); GUILayout.Space(8); if (GUILayout.Button("Manage Groups", "Minibutton", GUILayout.ExpandWidth(true))) { AddressableAssetsWindow.Init(); } GUILayout.Space(12); m_ProfilesFoldout = EditorGUILayout.Foldout(m_ProfilesFoldout, "Profile"); if (m_ProfilesFoldout) { if (m_AasTarget.profileSettings.profiles.Count > 0) { if (m_CurrentProfileIndex < 0 || m_CurrentProfileIndex >= m_AasTarget.profileSettings.profiles.Count) { m_CurrentProfileIndex = 0; } var profileNames = m_AasTarget.profileSettings.GetAllProfileNames(); int currentProfileIndex = m_CurrentProfileIndex; // Current profile in use was changed by different window if (AddressableAssetSettingsDefaultObject.Settings.profileSettings.profiles[m_CurrentProfileIndex].id != AddressableAssetSettingsDefaultObject.Settings.activeProfileId) { currentProfileIndex = profileNames.IndexOf(AddressableAssetSettingsDefaultObject.Settings.profileSettings.GetProfileName(AddressableAssetSettingsDefaultObject.Settings.activeProfileId)); if (currentProfileIndex != m_CurrentProfileIndex) { m_QueuedChanges.Add(() => m_CurrentProfileIndex = currentProfileIndex); } } currentProfileIndex = EditorGUILayout.Popup(m_ProfileInUse, currentProfileIndex, profileNames.ToArray()); if (currentProfileIndex != m_CurrentProfileIndex) { m_QueuedChanges.Add(() => m_CurrentProfileIndex = currentProfileIndex); } AddressableAssetSettingsDefaultObject.Settings.activeProfileId = AddressableAssetSettingsDefaultObject.Settings.profileSettings.GetProfileId(profileNames[currentProfileIndex]); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Manage Profiles", "Minibutton")) { EditorWindow.GetWindow <ProfileWindow>().Show(true); } EditorGUILayout.EndHorizontal(); } else { EditorGUILayout.LabelField("No valid profiles found"); } } GUILayout.Space(6); m_CatalogFoldout = EditorGUILayout.Foldout(m_CatalogFoldout, "Catalog"); if (m_CatalogFoldout) { bool disableCatalogOnStartup = EditorGUILayout.Toggle(m_CheckForCatalogUpdateOnInit, m_AasTarget.DisableCatalogUpdateOnStartup); if (disableCatalogOnStartup != m_AasTarget.DisableCatalogUpdateOnStartup) { m_QueuedChanges.Add(() => m_AasTarget.DisableCatalogUpdateOnStartup = disableCatalogOnStartup); } string overridePlayerVersion = EditorGUILayout.TextField(m_OverridePlayerVersion, m_AasTarget.OverridePlayerVersion); if (overridePlayerVersion != m_AasTarget.OverridePlayerVersion) { m_QueuedChanges.Add(() => m_AasTarget.OverridePlayerVersion = overridePlayerVersion); } bool bundleLocalCatalog = EditorGUILayout.Toggle(m_BundleLocalCatalog, m_AasTarget.BundleLocalCatalog); if (bundleLocalCatalog != m_AasTarget.BundleLocalCatalog) { m_QueuedChanges.Add(() => m_AasTarget.BundleLocalCatalog = bundleLocalCatalog); } bool optimizeCatalogSize = EditorGUILayout.Toggle(m_OptimizeCatalogSize, m_AasTarget.OptimizeCatalogSize); if (optimizeCatalogSize != m_AasTarget.OptimizeCatalogSize) { m_QueuedChanges.Add(() => m_AasTarget.OptimizeCatalogSize = optimizeCatalogSize); } bool buildRemoteCatalog = EditorGUILayout.Toggle(m_BuildRemoteCatalog, m_AasTarget.BuildRemoteCatalog); if (buildRemoteCatalog != m_AasTarget.BuildRemoteCatalog) { m_QueuedChanges.Add(() => m_AasTarget.BuildRemoteCatalog = buildRemoteCatalog); } if ((m_AasTarget.RemoteCatalogBuildPath != null && m_AasTarget.RemoteCatalogLoadPath != null) && // these will never actually be null, as the accessor initializes them. (buildRemoteCatalog)) { EditorGUILayout.PropertyField(serializedObject.FindProperty("m_RemoteCatalogBuildPath"), m_RemoteCatBuildPath); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_RemoteCatalogLoadPath"), m_RemoteCatLoadPath); } } GUILayout.Space(6); m_GeneralFoldout = EditorGUILayout.Foldout(m_GeneralFoldout, "General"); if (m_GeneralFoldout) { ProjectConfigData.postProfilerEvents = EditorGUILayout.Toggle(m_SendProfilerEvents, ProjectConfigData.postProfilerEvents); bool logResourceManagerExceptions = EditorGUILayout.Toggle(m_LogRuntimeExceptions, m_AasTarget.buildSettings.LogResourceManagerExceptions); if (logResourceManagerExceptions != m_AasTarget.buildSettings.LogResourceManagerExceptions) { m_QueuedChanges.Add(() => m_AasTarget.buildSettings.LogResourceManagerExceptions = logResourceManagerExceptions); } EditorGUILayout.PropertyField(serializedObject.FindProperty("m_CertificateHandlerType"), m_CertificateHandlerType); bool uniqueBundleIds = EditorGUILayout.Toggle(m_UniqueBundles, m_AasTarget.UniqueBundleIds); if (uniqueBundleIds != m_AasTarget.UniqueBundleIds) { m_QueuedChanges.Add(() => m_AasTarget.UniqueBundleIds = uniqueBundleIds); } bool contiguousBundles = EditorGUILayout.Toggle(m_ContiguousBundles, m_AasTarget.ContiguousBundles); if (contiguousBundles != m_AasTarget.ContiguousBundles) { m_QueuedChanges.Add(() => m_AasTarget.ContiguousBundles = contiguousBundles); } var maxWebReqs = EditorGUILayout.IntSlider(m_MaxConcurrentWebRequests, m_AasTarget.MaxConcurrentWebRequests, 1, 1024); if (maxWebReqs != m_AasTarget.MaxConcurrentWebRequests) { m_QueuedChanges.Add(() => m_AasTarget.MaxConcurrentWebRequests = maxWebReqs); } ProjectConfigData.showGroupsAsHierarchy = EditorGUILayout.Toggle(m_groupHierarchyView, ProjectConfigData.showGroupsAsHierarchy); ProjectConfigData.ignoreUnsupportedFilesInBuild = EditorGUILayout.Toggle(m_IgnoreUnsupportedFilesInBuild, ProjectConfigData.ignoreUnsupportedFilesInBuild); } GUILayout.Space(6); m_DataBuildersFoldout = EditorGUILayout.Foldout(m_DataBuildersFoldout, "Build and Play Mode Scripts"); if (m_DataBuildersFoldout) { m_DataBuildersRl.DoLayoutList(); } GUILayout.Space(6); m_GroupTemplateObjectsFoldout = EditorGUILayout.Foldout(m_GroupTemplateObjectsFoldout, "Asset Group Templates"); if (m_GroupTemplateObjectsFoldout) { m_GroupTemplateObjectsRl.DoLayoutList(); } GUILayout.Space(6); m_InitObjectsFoldout = EditorGUILayout.Foldout(m_InitObjectsFoldout, "Initialization Objects"); if (m_InitObjectsFoldout) { m_InitObjectsRl.DoLayoutList(); } if (EditorGUI.EndChangeCheck() || m_QueuedChanges.Count > 0) { Undo.RecordObject(m_AasTarget, "AddressableAssetSettings before changes"); foreach (var change in m_QueuedChanges) { change.Invoke(); } m_AasTarget.SetDirty(AddressableAssetSettings.ModificationEvent.BatchModification, null, true, true); 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); } }
private Vector2 SizeConstructor(EzSS_AspectHelper.Aspects aspect, int width, int height) { int _width = width; int _height = height; if (aspect == EzSS_AspectHelper.Aspects.aspect_2_3 || aspect == EzSS_AspectHelper.Aspects.aspect_3_4 || aspect == EzSS_AspectHelper.Aspects.aspect_3_5 || aspect == EzSS_AspectHelper.Aspects.aspect_4_5 || aspect == EzSS_AspectHelper.Aspects.aspect_9_16 || aspect == EzSS_AspectHelper.Aspects.aspect_10_16) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Width:", GUILayout.Width(45)); rect = EditorGUILayout.BeginHorizontal(); GUI.Box(rect, GUIContent.none); EditorGUILayout.LabelField(_width.ToString()); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Height:", GUILayout.Width(45)); _height = EditorGUILayout.IntSlider(_height, minSize, maxSize); EditorGUILayout.EndHorizontal(); if (useMockup && mockupImage != null) { _width = Mathf.RoundToInt(_height / (mockupFixedSize.y / mockupFixedSize.x)); } else { _width = Mathf.RoundToInt((float)_height * EzSS_AspectHelper.AspectsResults[aspect]); } } else if (aspect == EzSS_AspectHelper.Aspects.aspect_3_2 || aspect == EzSS_AspectHelper.Aspects.aspect_4_3 || aspect == EzSS_AspectHelper.Aspects.aspect_5_3 || aspect == EzSS_AspectHelper.Aspects.aspect_5_4 || aspect == EzSS_AspectHelper.Aspects.aspect_16_9 || aspect == EzSS_AspectHelper.Aspects.aspect_16_10) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Width:", GUILayout.Width(45)); _width = EditorGUILayout.IntSlider(_width, minSize, maxSize); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Height:", GUILayout.Width(45)); rect = EditorGUILayout.BeginHorizontal(); GUI.Box(rect, GUIContent.none); EditorGUILayout.LabelField(_height.ToString()); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); if (useMockup && mockupImage != null) { if (mockupCategory == MockupCategories.computer) { _height = Mathf.RoundToInt(_width / (mockupFixedSize.x / mockupFixedSize.y)); } else { _height = Mathf.RoundToInt(_width / (mockupFixedSize.y / mockupFixedSize.x)); } } else { _height = Mathf.RoundToInt(_width / EzSS_AspectHelper.AspectsResults[aspect]); } } else { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Width:", GUILayout.Width(45)); _width = EditorGUILayout.IntSlider(_width, minSize, maxSize); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Height:", GUILayout.Width(45)); _height = EditorGUILayout.IntSlider(_height, minSize, maxSize); EditorGUILayout.EndHorizontal(); } return(new Vector2(_width, _height)); }
//the visual interface of the map editor private void OnGUI() { //First Header GUILayout.Label("Update Map Functions", EditorStyles.boldLabel); //Update Buttons, put on the same row GUILayout.BeginHorizontal(); if (GUILayout.Button("Generate New Map")) { GenerateNewMap(); } if (GUILayout.Button("Refresh Current Map")) { RefreshCurrentMap(); } if (GUILayout.Button("Discard Changes")) { DiscardChanges(); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); //Second Header, for the map specifiactions (dimensions, tiles, etc) EditorGUILayout.BeginHorizontal(); GUILayout.Label("Map Specifications", EditorStyles.boldLabel); //Default Tile if (Filler == null) { Filler = AssetDatabase.LoadAssetAtPath <Terrain>("Assets/Prefabs/Terrain/Plain.prefab"); } Filler = EditorGUILayout.ObjectField("Default Tile", Filler, typeof(Terrain), true) as Terrain; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); //Dimensions Width = EditorGUILayout.IntSlider("Width", Width, 5, 40); Height = EditorGUILayout.IntSlider("Height", Height, 5, 40); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); //Selected Terrain Interface int x = -1; int y = -1; string selected = "None"; if (buttonIndex >= 0 && buttonIndex < Buttons.Length) { if (Buttons[buttonIndex].tooltip != "") { x = int.Parse(Buttons[buttonIndex].tooltip); y = x % 100; x /= 100; selected = Buttons[buttonIndex].text; } } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Selected Terrain: " + selected); if (x >= 0 && x < TerrainManip.GetLength(0) && y >= 0 && y < TerrainManip.GetLength(1)) { Terrain temp = TerrainManip[x, y]; temp.Type = (Terrain.Tile)EditorGUILayout.EnumPopup("New Type:", temp.Type); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); //Map Grid, for changing a tile and the individual properties of a tile scroll = EditorGUILayout.BeginScrollView(scroll); Buttons = new GUIContent[Width * Height]; int k = 0; for (int i = Height - 1; i >= 0; i--) { for (int j = 0; j < Width; j++) { string txt = ""; Texture spr = new Texture(); string ttp = ""; if (j < TerrainManip.GetLength(0) && i < TerrainManip.GetLength(1)) { txt = "(" + i + ", " + j + ")"; spr = TerrainManip[j, i].GetComponent <SpriteRenderer>().sprite.texture; int num = (j * 100 + i); ttp = num.ToString(); //ttp.PadLeft(4, '0'); } Buttons[k] = new GUIContent(txt, spr, ttp); k++; } } buttonIndex = GUILayout.SelectionGrid(buttonIndex, Buttons, Width); EditorGUILayout.EndScrollView(); }
private string saveAtPath = ""; // Save the path that the picture will be saved private void BasicSetupGUI() { // Camera EZ_Style.Header("Camera", false, false); cameraType = (CameraType)EditorGUILayout.EnumPopup("Camera Type:", cameraType); // Camera selection for each type if (cameraType == CameraType.single) { camera = EditorGUILayout.ObjectField("Camera:", camera, typeof(Camera), true, null) as Camera; } else { EditorGUILayout.HelpBox(EzSS_Messages.INFO_03, MessageType.Info); target = this; serializedObject = new SerializedObject(target); property = serializedObject.FindProperty("cameras"); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(property, true); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } } EZ_Style.Footer(); // Encode type EZ_Style.Header("Encode", false, false); encodeType = (EncodeType)EditorGUILayout.EnumPopup("Encode Type:", encodeType); if (encodeType == EncodeType.JPG) { jpgQuality = EditorGUILayout.IntSlider("Quality", jpgQuality, 1, 100); } EZ_Style.Footer(); // Name prefix and configuration EZ_Style.Header("Name", false, false); fileNamePrefix = EditorGUILayout.TextField("Screenshot Prefix:", fileNamePrefix); useDate = EditorGUILayout.Toggle("Use Date:", useDate); useTime = EditorGUILayout.Toggle("Use Time:", useTime); // Cofigurates the name and display it finalFileName = fileNamePrefix; if (useDate) { finalFileName = finalFileName + "_" + DateTime.Now.ToString("yy-MMM-dd"); } if (useTime) { finalFileName = finalFileName + "-" + DateTime.Now.ToString("HH-mm-ss"); } EditorGUILayout.LabelField("File Name:"); EZ_Style.BeginHorizontalRectBox(); EditorGUILayout.LabelField(finalFileName); EZ_Style.EndHorizontalRectBox(); EZ_Style.Footer(); // Save at EZ_Style.Header("Save at Destination", false, false); // Set the path to save the image EditorGUILayout.LabelField("Save at:"); EZ_Style.rect = EditorGUILayout.BeginVertical(); GUI.Box(EZ_Style.rect, GUIContent.none); if (string.IsNullOrEmpty(saveAtPath)) { EditorGUILayout.LabelField("Browse location using the button bellow"); } else { EditorGUILayout.LabelField(saveAtPath); } EditorGUILayout.EndVertical(); // Path buttons EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Browse")) { saveAtPath = EditorUtility.SaveFolderPanel("Save At", saveAtPath, Application.dataPath); } if (GUILayout.Button("Open Folder")) { Application.OpenURL("file://" + saveAtPath); } EditorGUILayout.EndHorizontal(); EZ_Style.Footer(); }
public override void OnInspectorGUI() { EditorGUILayout.Separator(); GUI.skin.label.alignment = TextAnchor.MiddleCenter; GUILayout.Label(_headerTexture, GUILayout.ExpandWidth(true)); GUI.skin.label.alignment = TextAnchor.MiddleLeft; EditorGUILayout.BeginVertical(blackStyle); EditorGUILayout.BeginHorizontal(); DrawTitleLabel("Grid Configuration"); GUILayout.FlexibleSpace(); if (GUILayout.Button("Help")) { EditorUtility.DisplayDialog("Grids 2D System", "Grids 2D is an advanced grid generator for Unity.\n\nFor a complete description of the options, please refer to the documentation guide (PDF) included in the asset.\nWe also invite you to visit and sign up on our support forum on kronnect.com where you can post your questions/requests.\n\nThanks for purchasing! Please rate Grids 2D on the Asset Store! Thanks.", "Close"); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Topology", GUILayout.Width(120)); grid.gridTopology = (GRID_TOPOLOGY)EditorGUILayout.IntPopup((int)grid.gridTopology, topologyOptions, topologyOptionsValues); EditorGUILayout.EndHorizontal(); if (grid.gridTopology == GRID_TOPOLOGY.Irregular) { EditorGUILayout.BeginHorizontal(); GUILayout.Label("Cells (aprox.)", GUILayout.Width(120)); grid.numCells = EditorGUILayout.IntSlider(grid.numCells, 2, Grid2D.MAX_CELLS); EditorGUILayout.EndHorizontal(); } else { EditorGUILayout.BeginHorizontal(); GUILayout.Label("Columns", GUILayout.Width(120)); grid.columnCount = EditorGUILayout.IntSlider(grid.columnCount, 2, Grid2D.MAX_CELLS_SQRT); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Rows", GUILayout.Width(120)); grid.rowCount = EditorGUILayout.IntSlider(grid.rowCount, 2, Grid2D.MAX_CELLS_SQRT); EditorGUILayout.EndHorizontal(); } if (grid.gridTopology == GRID_TOPOLOGY.Hexagonal) { EditorGUILayout.BeginHorizontal(); GUILayout.Label("Regular Hexes", GUILayout.Width(120)); grid.regularHexagons = EditorGUILayout.Toggle(grid.regularHexagons); EditorGUILayout.EndHorizontal(); if (grid.regularHexagons) { EditorGUILayout.BeginHorizontal(); GUILayout.Label(" Hex Size", GUILayout.Width(120)); grid.hexSize = EditorGUILayout.FloatField(grid.hexSize); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); GUILayout.Label("Even Layout", GUILayout.Width(120)); grid.evenLayout = EditorGUILayout.Toggle(grid.evenLayout); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); GUILayout.Label("Curvature", GUILayout.Width(120)); if (grid.numCells > Grid2D.MAX_CELLS_FOR_CURVATURE) { DrawInfoLabel("not available with >" + Grid2D.MAX_CELLS_FOR_CURVATURE + " cells"); } else { grid.gridCurvature = EditorGUILayout.Slider(grid.gridCurvature, 0, 0.1f); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Relaxation", GUILayout.Width(120)); if (grid.gridTopology != GRID_TOPOLOGY.Irregular) { DrawInfoLabel("only available with irregular topology"); } else if (grid.numCells > Grid2D.MAX_CELLS_FOR_RELAXATION) { DrawInfoLabel("not available with >" + Grid2D.MAX_CELLS_FOR_RELAXATION + " cells"); } else { grid.gridRelaxation = EditorGUILayout.IntSlider(grid.gridRelaxation, 1, 32); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Visibility Mask", "Alpha channel is used to determine cell visibility (0 = cell is not visible)"), GUILayout.Width(120)); grid.gridMask = (Texture2D)EditorGUILayout.ObjectField(grid.gridMask, typeof(Texture2D), true); EditorGUILayout.EndHorizontal(); if (CheckTextureImportSettings(grid.gridMask)) { grid.ReloadGridMask(); } EditorGUILayout.BeginHorizontal(); GUILayout.Label("Seed", GUILayout.Width(120)); grid.seed = EditorGUILayout.IntSlider(grid.seed, 1, 10000); if (GUILayout.Button("Redraw")) { grid.Redraw(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Territories", GUILayout.Width(120)); grid.enableTerritories = EditorGUILayout.Toggle(grid.enableTerritories); EditorGUILayout.EndHorizontal(); GUI.enabled = grid.enableTerritories; EditorGUILayout.BeginHorizontal(); GUILayout.Label(" Count", GUILayout.Width(120)); grid.numTerritories = EditorGUILayout.IntSlider(grid.numTerritories, 1, Mathf.Min(grid.numCells, Grid2D.MAX_TERRITORIES)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent(" Region Texture", "Quickly create territories assigning a color texture in which each territory corresponds to a color."), GUILayout.Width(120)); grid.territoriesTexture = (Texture2D)EditorGUILayout.ObjectField(grid.territoriesTexture, typeof(Texture2D), true); if (grid.territoriesTexture != null) { EditorGUILayout.EndHorizontal(); CheckTextureImportSettings(grid.territoriesTexture); EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent(" Neutral Color", "Color to be ignored."), GUILayout.Width(120)); grid.territoriesTextureNeutralColor = EditorGUILayout.ColorField(grid.territoriesTextureNeutralColor, GUILayout.Width(50)); EditorGUILayout.Space(); if (GUILayout.Button("Generate Territories", GUILayout.Width(120))) { if (grid.territoriesTexture == null) { EditorUtility.DisplayDialog("Missing territories texture!", "Assign a color texture to the territories texture slot.", "Ok"); } else { grid.CreateTerritories(grid.territoriesTexture, grid.territoriesTextureNeutralColor); } } } EditorGUILayout.EndHorizontal(); GUI.enabled = true; int cellsCreated = grid.cells == null ? 0 : grid.cells.Count; int territoriesCreated = grid.territories == null ? 0 : grid.territories.Count; EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); DrawInfoLabel("Cells Created: " + cellsCreated + " / Territories Created: " + territoriesCreated + " / Vertex Count: " + grid.lastVertexCount); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.BeginVertical(blackStyle); DrawTitleLabel("Grid Positioning"); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Hide Objects", GUILayout.Width(120)); if (GUILayout.Button("Toggle Grid")) { grid.gameObject.SetActive(!grid.gameObject.activeSelf); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Depth Offset", GUILayout.Width(120)); grid.gridDepthOffset = EditorGUILayout.IntSlider(grid.gridDepthOffset, -10, -1); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.BeginVertical(blackStyle); DrawTitleLabel("Grid Appearance"); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Show Territories", GUILayout.Width(120)); grid.showTerritories = EditorGUILayout.Toggle(grid.showTerritories); if (grid.showTerritories) { GUILayout.Label("Frontier Color", GUILayout.Width(120)); grid.territoryFrontiersColor = EditorGUILayout.ColorField(grid.territoryFrontiersColor, GUILayout.Width(50)); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label(" Highlight Color", GUILayout.Width(120)); grid.territoryHighlightColor = EditorGUILayout.ColorField(grid.territoryHighlightColor, GUILayout.Width(50)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label(" Colorize Territories", GUILayout.Width(120)); grid.colorizeTerritories = EditorGUILayout.Toggle(grid.colorizeTerritories); GUILayout.Label("Alpha"); grid.colorizedTerritoriesAlpha = EditorGUILayout.Slider(grid.colorizedTerritoriesAlpha, 0.0f, 1.0f); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label(" Outer Borders", GUILayout.Width(120)); grid.showTerritoriesOuterBorders = EditorGUILayout.Toggle(grid.showTerritoriesOuterBorders); GUILayout.Label(new GUIContent("Internal Territories", "Allows territories to be contained by other territories."), GUILayout.Width(110)); grid.allowTerritoriesInsideTerritories = EditorGUILayout.Toggle(grid.allowTerritoriesInsideTerritories); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Show Cells", GUILayout.Width(120)); grid.showCells = EditorGUILayout.Toggle(grid.showCells); if (grid.showCells) { GUILayout.Label("Border Color", GUILayout.Width(120)); grid.cellBorderColor = EditorGUILayout.ColorField(grid.cellBorderColor, GUILayout.Width(50)); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label(" Highlight Color", GUILayout.Width(120)); grid.cellHighlightColor = EditorGUILayout.ColorField(grid.cellHighlightColor, GUILayout.Width(50)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Highlight Fade", GUILayout.Width(120)); grid.highlightFadeAmount = EditorGUILayout.Slider(grid.highlightFadeAmount, 0.0f, 1.0f); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Canvas Texture", GUILayout.Width(120)); grid.canvasTexture = (Texture2D)EditorGUILayout.ObjectField(grid.canvasTexture, typeof(Texture2D), true); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.BeginVertical(blackStyle); DrawTitleLabel("Grid Behaviour"); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Selection Mode", GUILayout.Width(120)); grid.highlightMode = (HIGHLIGHT_MODE)EditorGUILayout.Popup((int)grid.highlightMode, selectionModeOptions); EditorGUILayout.EndHorizontal(); if (grid.highlightMode == HIGHLIGHT_MODE.Cells) { EditorGUILayout.BeginHorizontal(); GUILayout.Label(" Include Invisible Cells", GUILayout.Width(120)); grid.cellHighlightNonVisible = EditorGUILayout.Toggle(grid.cellHighlightNonVisible); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); GUILayout.Label("Overlay Mode", GUILayout.Width(120)); grid.overlayMode = (OVERLAY_MODE)EditorGUILayout.Popup((int)grid.overlayMode, overlayModeOptions); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Respect Other UI", GUILayout.Width(120)); grid.respectOtherUI = EditorGUILayout.Toggle(grid.respectOtherUI); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.BeginVertical(blackStyle); DrawTitleLabel("Path Finding"); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Algorithm", GUILayout.Width(120)); grid.pathFindingHeuristicFormula = (Grids2D.PathFinding.HeuristicFormula)EditorGUILayout.EnumPopup(grid.pathFindingHeuristicFormula); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Max Search Cost", GUILayout.Width(120)); grid.pathFindingMaxCost = EditorGUILayout.IntField(grid.pathFindingMaxCost, GUILayout.Width(100)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Max Steps", GUILayout.Width(120)); grid.pathFindingMaxSteps = EditorGUILayout.IntField(grid.pathFindingMaxSteps, GUILayout.Width(100)); EditorGUILayout.EndHorizontal(); if (grid.gridTopology == GRID_TOPOLOGY.Box) { EditorGUILayout.BeginHorizontal(); GUILayout.Label("Use Diagonals", GUILayout.Width(120)); grid.pathFindingUseDiagonals = EditorGUILayout.Toggle(grid.pathFindingUseDiagonals, GUILayout.Width(40)); GUILayout.Label("Heavy Diagonals", GUILayout.Width(120)); grid.pathFindingHeavyDiagonals = EditorGUILayout.Toggle(grid.pathFindingHeavyDiagonals, GUILayout.Width(40)); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.BeginVertical(blackStyle); EditorGUILayout.BeginHorizontal(); DrawTitleLabel("Grid Editor"); GUILayout.FlexibleSpace(); if (GUILayout.Button("Export Settings")) { if (EditorUtility.DisplayDialog("Export Grid Settings", "This option will add a Grid Config component to this game object with current cell settings. You can restore this configuration just enabling this new component.", "Ok", "Cancel")) { CreatePlaceholder(); } } if (GUILayout.Button("Reset")) { if (EditorUtility.DisplayDialog("Reset Grid", "Reset cells to their default values?", "Ok", "Cancel")) { ResetCells(); GUIUtility.ExitGUI(); return; } } EditorGUILayout.EndHorizontal(); if (cellSelectedIndex < 0 || cellSelectedIndex >= grid.cells.Count) { GUILayout.Label("Click on a cell in Scene View to edit its properties."); } else { EditorGUILayout.BeginHorizontal(); GUILayout.Label("Selected Cell", GUILayout.Width(120)); GUILayout.Label(cellSelectedIndex.ToString(), GUILayout.Width(120)); EditorGUILayout.EndHorizontal(); bool needsRedraw = false; EditorGUILayout.BeginHorizontal(); GUILayout.Label(" Visible", GUILayout.Width(120)); Cell selectedCell = grid.cells [cellSelectedIndex]; bool cellVisible = selectedCell.visible; selectedCell.visible = EditorGUILayout.Toggle(cellVisible); if (selectedCell.visible != cellVisible) { needsRedraw = true; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label(" Tag", GUILayout.Width(120)); cellTag = EditorGUILayout.IntField(cellTag, GUILayout.Width(60)); if (cellTag == selectedCell.tag) { GUI.enabled = false; } if (GUILayout.Button("Set Tag", GUILayout.Width(60))) { grid.CellSetTag(cellSelectedIndex, cellTag); } GUI.enabled = true; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label(" Territory Index", GUILayout.Width(120)); cellTerritoryIndex = EditorGUILayout.IntField(cellTerritoryIndex, GUILayout.Width(40)); if (cellTerritoryIndex == selectedCell.territoryIndex) { GUI.enabled = false; } if (GUILayout.Button("Set Territory", GUILayout.Width(100)) && cellTerritoryIndex != grid.cells [cellSelectedIndex].territoryIndex) { grid.CellSetTerritory(cellSelectedIndex, cellTerritoryIndex); needsRedraw = true; } GUI.enabled = true; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label(" Color", GUILayout.Width(120)); cellColor = EditorGUILayout.ColorField(cellColor, GUILayout.Width(40)); GUILayout.Label(" Texture", GUILayout.Width(60)); cellTextureIndex = EditorGUILayout.IntField(cellTextureIndex, GUILayout.Width(40)); if (grid.CellGetColor(cellSelectedIndex) == cellColor && grid.CellGetTextureIndex(cellSelectedIndex) == cellTextureIndex) { GUI.enabled = false; } if (GUILayout.Button("Set", GUILayout.Width(40))) { grid.CellToggle(cellSelectedIndex, true, cellColor, false, cellTextureIndex); needsRedraw = true; } GUI.enabled = true; if (GUILayout.Button("Clear", GUILayout.Width(40))) { grid.CellHide(cellSelectedIndex); needsRedraw = true; } EditorGUILayout.EndHorizontal(); if (needsRedraw) { RefreshGrid(); GUIUtility.ExitGUI(); return; } } EditorGUILayout.BeginHorizontal(); GUILayout.Label("Textures", GUILayout.Width(120)); EditorGUILayout.EndHorizontal(); if (toggleButtonStyleNormal == null) { toggleButtonStyleNormal = "Button"; toggleButtonStyleToggled = new GUIStyle(toggleButtonStyleNormal); toggleButtonStyleToggled.normal.background = toggleButtonStyleToggled.active.background; } int textureMax = grid.textures.Length - 1; while (textureMax >= 1 && grid.textures [textureMax] == null) { textureMax--; } textureMax++; if (textureMax >= grid.textures.Length) { textureMax = grid.textures.Length - 1; } for (int k = 1; k <= textureMax; k++) { EditorGUILayout.BeginHorizontal(); GUILayout.Label(" " + k.ToString(), GUILayout.Width(40)); grid.textures [k] = (Texture2D)EditorGUILayout.ObjectField(grid.textures [k], typeof(Texture2D), false); if (grid.textures [k] != null) { if (GUILayout.Button(new GUIContent("T", "Texture mode - if enabled, you can paint several cells just clicking over them."), textureMode == k ? toggleButtonStyleToggled : toggleButtonStyleNormal, GUILayout.Width(20))) { textureMode = textureMode == k ? 0 : k; } if (GUILayout.Button(new GUIContent("X", "Remove texture"), GUILayout.Width(20))) { if (EditorUtility.DisplayDialog("Remove texture", "Are you sure you want to remove this texture?", "Yes", "No")) { grid.textures [k] = null; GUIUtility.ExitGUI(); return; } } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); if (grid.isDirty) { #if UNITY_5_6_OR_NEWER serializedObject.UpdateIfRequiredOrScript(); #else serializedObject.UpdateIfDirtyOrScript(); #endif isDirty.boolValue = false; serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(target); // Hide mesh in Editor HideEditorMesh(); SceneView.RepaintAll(); } }
public override void OnInspectorGUI() { myLoc.Update(); //GPS Emulator EditorGUILayout.Space(); EditorGUILayout.PropertyField(key, new GUIContent("Maps AppKey")); EditorGUILayout.PropertyField(simGPS, new GUIContent("GPS Emulator")); EditorGUI.indentLevel++; if (simGPS.boolValue) { //Emulator Pointer Speed EditorGUILayout.PropertyField(userSpeed, new GUIContent("Pointer Speed"), GUILayout.MaxWidth(250)); EditorGUILayout.PropertyField(realSpeed, new GUIContent("Realistic Speed"), GUILayout.MaxWidth(250)); EditorGUILayout.HelpBox("On Emulator Mode use WASD or arrow keys to navigate.", MessageType.Info); EditorGUILayout.Space(); } EditorGUI.indentLevel--; //Latitude / Longitude EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(fixLat, new GUIContent("Latitude (decimal)"), GUILayout.Width(250)); EditorGUILayout.LabelField(dmsLat.stringValue); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(fixLon, new GUIContent("Longitude (decimal)"), GUILayout.Width(250)); EditorGUILayout.LabelField(dmsLon.stringValue); EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField("Heading(Read Only)", (Mathf.Round(heading.floatValue)).ToString(), GUILayout.Width(250)); EditorGUILayout.Space(); //Zoom Control showZoom = EditorGUILayout.Foldout(showZoom, "Zoom Levels"); EditorGUILayout.Space(); if (showZoom) { EditorGUI.indentLevel++; EditorGUILayout.IntSlider(zoom, 0, 20, new GUIContent("Default/Current")); EditorGUILayout.IntSlider(minZoom, 0, 20, new GUIContent("Min.")); EditorGUILayout.IntSlider(maxZoom, 0, 20, new GUIContent("Max.")); EditorGUILayout.Space(); EditorGUI.indentLevel--; } //MapQuest MapType index.intValue = EditorGUILayout.Popup("Maptype", index.intValue, maptype); EditorGUILayout.Space(); //3D Perspective Camera View EditorGUILayout.PropertyField(triDView, new GUIContent("3D View")); EditorGUI.indentLevel++; //Camera Distance to User //3D if (triDView.boolValue == true) { EditorGUILayout.Slider(camDist, 1, 100, new GUIContent("Camera Dist")); EditorGUILayout.IntSlider(camAngle, 1, 89, new GUIContent("Camera Angle")); } //2D else { //Camera Height from Map EditorGUILayout.Slider(camDist, 1, 20, new GUIContent("Camera Height")); } //Fixed Pointer Aspect if (triDView.boolValue == false) { EditorGUILayout.PropertyField(fixPointer, new GUIContent("Fixed Pointer Aspect"), GUILayout.Width(250)); } EditorGUI.indentLevel--; //Auto Center EditorGUILayout.PropertyField(autoCenter); //User Interface Buttons EditorGUILayout.PropertyField(buttons, new GUIContent("GUI Buttons")); EditorGUILayout.Space(); //Additional Config Options if (!simGPS.boolValue) { EditorGUILayout.PropertyField(updateRate, new GUIContent("Pointer Update Rate"), GUILayout.MaxWidth(200)); EditorGUILayout.PropertyField(maxWait, new GUIContent("GPS Fix Timeout"), GUILayout.MaxWidth(200)); } EditorGUILayout.PropertyField(initTime, new GUIContent("Init. Time"), GUILayout.MaxWidth(200)); EditorGUILayout.Space(); if (simGPS.boolValue) { EditorGUILayout.HelpBox("Deactivate the GPS emulator before building for mobile devices.", MessageType.Warning); } myLoc.ApplyModifiedProperties(); }
void OnGUI() { m_scrollPos = EditorGUILayout.BeginScrollView(m_scrollPos, GUILayout.Height(Screen.height)); float cachedWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 100; EditorGUILayout.BeginVertical(m_contentStyle); // build button EditorGUILayout.BeginHorizontal(); EditorGUI.BeginDisabledGroup(m_allTextures.Count <= 0); if (GUILayout.Button("Build Array", "prebutton", GUILayout.Height(20))) { bool showWarning = false; for (int i = 0; i < m_allTextures.Count; i++) { if (m_allTextures[i].width != m_sizes[m_selectedSizeX] || m_allTextures[i].height != m_sizes[m_selectedSizeY]) { showWarning = true; } } if (!showWarning) { m_message = string.Empty; BuildArray(); } else if (EditorUtility.DisplayDialog("Warning!", "Some textures need to be resized to fit the selected size. Do you want to continue?", "Yes", "No")) { m_message = string.Empty; BuildArray(); } } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(m_lastSaved == null); GUIContent icon = EditorGUIUtility.IconContent("icons/d_ViewToolZoom.png"); if (GUILayout.Button(icon, "prebutton", GUILayout.Width(28), GUILayout.Height(20))) { EditorGUIUtility.PingObject(m_lastSaved); } EditorGUI.EndDisabledGroup(); EditorGUILayout.EndHorizontal(); // message if (!string.IsNullOrEmpty(m_message)) { if (GUILayout.Button("BUILD REPORT (click to hide):\n\n" + m_message, "helpbox")) { m_message = string.Empty; } } // options EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Size"); EditorGUIUtility.labelWidth = 16; m_selectedSizeX = EditorGUILayout.Popup("X", m_selectedSizeX, m_sizesStr); EditorGUI.BeginDisabledGroup(m_lockRatio); m_selectedSizeY = EditorGUILayout.Popup("Y", m_lockRatio ? m_selectedSizeX : m_selectedSizeY, m_sizesStr); EditorGUI.EndDisabledGroup(); EditorGUIUtility.labelWidth = 100; m_lockRatio = GUILayout.Toggle(m_lockRatio, "L", "minibutton", GUILayout.Width(18)); EditorGUILayout.EndHorizontal(); m_linearMode = EditorGUILayout.Toggle("Linear", m_linearMode); m_mipMaps = EditorGUILayout.Toggle("Mip Maps", m_mipMaps); m_wrapMode = (TextureWrapMode)EditorGUILayout.EnumPopup("Wrap Mode", m_wrapMode); m_filterMode = (FilterMode)EditorGUILayout.EnumPopup("Filter Mode", m_filterMode); m_anisoLevel = EditorGUILayout.IntSlider("Aniso Level", m_anisoLevel, 0, 16); m_selectedFormat = EditorGUILayout.Popup("Format", m_selectedFormat, m_formatsStr); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Path and Name"); EditorGUILayout.BeginHorizontal(); m_pathButtonContent.text = m_folderPath; Vector2 buttonSize = m_pathButtonStyle.CalcSize(m_pathButtonContent); if (GUILayout.Button(m_pathButtonContent, m_pathButtonStyle, GUILayout.MaxWidth(Mathf.Min(Screen.width * 0.5f, buttonSize.x)))) { string folderpath = EditorUtility.OpenFolderPanel("Save Texture Array to folder", "Assets/", ""); folderpath = FileUtil.GetProjectRelativePath(folderpath); if (string.IsNullOrEmpty(folderpath)) { m_folderPath = "Assets/"; } else { m_folderPath = folderpath + "/"; } } m_fileName = EditorGUILayout.TextField(m_fileName, GUILayout.ExpandWidth(true)); EditorGUILayout.LabelField(".asset", GUILayout.MaxWidth(40)); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); // list EditorGUILayout.Separator(); if (m_listTextures != null) { m_listTextures.DoLayoutList(); } GUILayout.Space(20); EditorGUILayout.EndVertical(); EditorGUIUtility.labelWidth = cachedWidth; EditorGUILayout.EndScrollView(); }
public override void OnInspectorGUI() { EditorGUIUtility.LookLikeControls(); BuildingCreation building_creation = (BuildingCreation)target as BuildingCreation; EditorGUILayout.BeginHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.PrefixLabel("L-System Axiom"); building_creation.axiom = EditorGUILayout.TextField(building_creation.axiom); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.PrefixLabel("L-System Production Rule"); building_creation.productionRule = EditorGUILayout.TextField(building_creation.productionRule); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.PrefixLabel("L-System Expansion"); building_creation.expansions = EditorGUILayout.IntSlider(building_creation.expansions, 1, 5); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.PrefixLabel("L-System Height Max"); building_creation.heightMax = EditorGUILayout.Slider(building_creation.heightMax, 3, 10); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.PrefixLabel("L-System Height Min"); building_creation.heightMin = EditorGUILayout.Slider(building_creation.heightMin, 0.5f, 5); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.PrefixLabel("Generate All Buildings"); building_creation.generateAllBuildings = EditorGUILayout.Toggle(building_creation.generateAllBuildings); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); building_creation.buildingsToGenerate = (int)EditorGUILayout.IntSlider("Buildings to Generate", building_creation.buildingsToGenerate, 1, number_of_buildings); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); building_creation.scalingFactor = (float)EditorGUILayout.Slider("Scaling Factor", building_creation.scalingFactor, 1, 100); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); Rect startButton = EditorGUILayout.BeginHorizontal(); startButton.x = startButton.width / 2 - 100; startButton.width = 200; startButton.height = 18; if (!enter) { setNumberOfBuildings(); enter = true; } if (GUI.Button(startButton, "Create Buildings")) { enter = false; building_creation.createBuilding(); DestroyImmediate(building_creation); GUIUtility.ExitGUI(); } if (GUI.changed) { EditorUtility.SetDirty(building_creation); if (destroy) { } } }
static void VSCodePreferencesItem() { if (EditorApplication.isCompiling) { EditorGUILayout.HelpBox("Please wait for Unity to finish compiling. \nIf the window doesn't refresh, simply click on the window or move it around to cause a repaint to happen.", MessageType.Warning); return; } EditorGUILayout.BeginVertical(); EditorGUILayout.HelpBox("Support development of this plugin, follow @reapazor and @dotbunny on Twitter.", MessageType.Info); EditorGUI.BeginChangeCheck(); Enabled = EditorGUILayout.Toggle(new GUIContent("Enable Integration", "Should the integration work its magic for you?"), Enabled); #if !UNITY_4_0 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 && !UNITY_4_6 && !UNITY_4_7 CodePath = EditorGUILayout.DelayedTextField(new GUIContent("VS Code Path", "Full path to the Micosoft Visual Studio code executable."), CodePath); #else CodePath = EditorGUILayout.TextField(new GUIContent("VS Code Path", "Full path to the Micosoft Visual Studio code executable."), CodePath); #endif UseUnityDebugger = EditorGUILayout.Toggle(new GUIContent("Use Unity Debugger", "Should the integration integrate with Unity's VSCode Extension (must be installed)."), UseUnityDebugger); EditorGUILayout.Space(); RevertExternalScriptEditorOnExit = EditorGUILayout.Toggle(new GUIContent("Revert Script Editor On Unload", "Should the external script editor setting be reverted to its previous setting on project unload? This is useful if you do not use Code with all your projects."), RevertExternalScriptEditorOnExit); Debug = EditorGUILayout.Toggle(new GUIContent("Output Messages To Console", "Should informational messages be sent to Unity's Console?"), Debug); WriteLaunchFile = EditorGUILayout.Toggle(new GUIContent("Always Write Launch File", "Always write the launch.json settings when entering play mode?"), WriteLaunchFile); EditorGUILayout.Space(); AutomaticUpdates = EditorGUILayout.Toggle(new GUIContent("Automatic Updates", "Should the plugin automatically update itself?"), AutomaticUpdates); UpdateTime = EditorGUILayout.IntSlider(new GUIContent("Update Timer (Days)", "After how many days should updates be checked for?"), UpdateTime, 1, 31); EditorGUILayout.Space(); EditorGUILayout.Space(); if (EditorGUI.EndChangeCheck()) { UpdateUnityPreferences(Enabled); //UnityEditor.PreferencesWindow.Read // TODO: Force Unity To Reload Preferences // This seems to be a hick up / issue if (VSCode.Debug) { if (Enabled) { UnityEngine.Debug.Log("[VSCode] Integration Enabled"); } else { UnityEngine.Debug.Log("[VSCode] Integration Disabled"); } } } if (GUILayout.Button(new GUIContent("Force Update", "Check for updates to the plugin, right NOW!"))) { CheckForUpdate(); EditorGUILayout.EndVertical(); return; } if (GUILayout.Button(new GUIContent("Write Workspace Settings", "Output a default set of workspace settings for VSCode to use, ignoring many different types of files."))) { WriteWorkspaceSettings(); EditorGUILayout.EndVertical(); return; } EditorGUILayout.Space(); if (UseUnityDebugger) { EditorGUILayout.HelpBox("In order for the \"Use Unity Debuggger\" option to function above, you need to have installed the Unity Debugger Extension for Visual Studio Code. You can do this by simply clicking the button below and it will take care of the rest.", MessageType.Warning); if (GUILayout.Button(new GUIContent("Install Unity Debugger", "Install the Unity Debugger Extension into Code"))) { InstallUnityDebugger(); EditorGUILayout.EndVertical(); return; } } GUILayout.FlexibleSpace(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label( new GUIContent( string.Format("{0:0.00}", Version) + VersionCode, "GitHub's Version @ " + string.Format("{0:0.00}", GitHubVersion))); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); }
/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(IPropertyValueEntry <int> entry, RangeAttribute attribute, GUIContent label) { entry.SmartValue = label == null? EditorGUILayout.IntSlider(entry.SmartValue, (int)attribute.min, (int)attribute.max) : EditorGUILayout.IntSlider(label, entry.SmartValue, (int)attribute.min, (int)attribute.max); }
private void StartingPanel() { EditorGUILayout.IntSlider(startingPanel, 0, numberOfPanels - 1, new GUIContent("Starting Panel", "The number of the panel that will be displayed first, based on a 0-indexed array.")); }
void OnGUI() { GUILayout.Label("Where do you want the rendered image?", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); EditorGUILayout.TextField(path, GUILayout.ExpandWidth(false)); if (GUILayout.Button("Browse", GUILayout.ExpandWidth(false))) { path = EditorUtility.SaveFolderPanel("Path to Save Images", path, Application.dataPath); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Set Specific Resolution to Render", EditorStyles.boldLabel); resWidth = EditorGUILayout.IntField("Pixel Width", resWidth); resHeight = EditorGUILayout.IntField("Pixel Height", resHeight); myCamera = Camera.main; EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Default 8K Size", GUILayout.MinHeight(40), GUILayout.MaxWidth(155))) { resWidth = 7680; resHeight = 4320; scale = 1; } if (GUILayout.Button("4K", GUILayout.MinHeight(40), GUILayout.MaxWidth(155))) { resWidth = 3840; resHeight = 2160; scale = 1; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("2K", GUILayout.MinHeight(40), GUILayout.MaxWidth(155))) { resWidth = 2040; resHeight = 1080; scale = 1; } if (GUILayout.Button("1K", GUILayout.MinHeight(40), GUILayout.MaxWidth(155))) { resWidth = 1024; resHeight = 512; scale = 1; } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Set To Game Window", GUILayout.MinHeight(40))) { resWidth = (int)Handles.GetMainGameViewSize().y; resHeight = (int)Handles.GetMainGameViewSize().x; } scale = EditorGUILayout.IntSlider("Scale", scale, 1, 8); EditorGUILayout.Space(); //EditorGUILayout.LabelField ("Screenshot render will be: " + resWidth*scale + " x " + resHeight*scale + " px", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Render: \n" + resWidth * scale + " x " + resHeight * scale + " px", GUILayout.MinHeight(70))) { if (path == "") { path = EditorUtility.SaveFolderPanel("Path to Save Images", path, Application.dataPath); Debug.Log("Path Set"); TakeHiResShot(); } else { TakeHiResShot(); } } if (GUILayout.Button("Open Screenshot \nLocation", GUILayout.MinHeight(70), GUILayout.MaxWidth(130))) { Application.OpenURL("file://" + path); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); if (takeHiResShot) { int resWidthN = resWidth * scale; int resHeightN = resHeight * scale; RenderTexture rt = new RenderTexture(resWidthN, resHeightN, 24); myCamera.targetTexture = rt; TextureFormat tFormat; if (isTransparent) { tFormat = TextureFormat.ARGB32; } else { tFormat = TextureFormat.RGB24; } Texture2D screenShot = new Texture2D(resWidthN, resHeightN, tFormat, false); myCamera.Render(); RenderTexture.active = rt; screenShot.ReadPixels(new Rect(0, 0, resWidthN, resHeightN), 0, 0); myCamera.targetTexture = null; RenderTexture.active = null; byte[] bytes = screenShot.EncodeToPNG(); string filename = ScreenShotName(resWidthN, resHeightN); System.IO.File.WriteAllBytes(filename, bytes); Debug.Log(string.Format("Took screenshot to: {0}", filename)); Application.OpenURL(filename); takeHiResShot = false; } }
private void DisplayClips() { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); GUI.contentColor = DTGUIHelper.BrightButtonColor; if (GUILayout.Button("All", EditorStyles.toolbarButton, GUILayout.Width(36))) { foreach (var t in FilteredClips) { t.IsSelected = true; } } if (GUILayout.Button("None", EditorStyles.toolbarButton, GUILayout.Width(36))) { foreach (var t in _clipList.AudioInfor) { t.IsSelected = false; } } GUI.contentColor = DTGUIHelper.BrightButtonColor; GUILayout.Space(6); var columnPrefix = ColumnPrefix(ClipSortColumn.Name); if (GUILayout.Button(new GUIContent(columnPrefix + "Clip Name", "Click to sort by Clip Name"), EditorStyles.toolbarButton, GUILayout.Width(156))) { ChangeSortColumn(ClipSortColumn.Name); } columnPrefix = ColumnPrefix(ClipSortColumn.Bitrate); if (GUILayout.Button(new GUIContent(columnPrefix + "Compression (kbps)", "Click to sort by Compression Bitrate"), EditorStyles.toolbarButton, GUILayout.Width(214))) { ChangeSortColumn(ClipSortColumn.Bitrate); } columnPrefix = ColumnPrefix(ClipSortColumn.Is3D); if (GUILayout.Button(new GUIContent(columnPrefix + "3D", "Click to sort by 3D"), EditorStyles.toolbarButton, GUILayout.Width(36))) { ChangeSortColumn(ClipSortColumn.Is3D); } columnPrefix = ColumnPrefix(ClipSortColumn.ForceMono); if (GUILayout.Button(new GUIContent(columnPrefix + "Force Mono", "Click to sort by Force Mono"), EditorStyles.toolbarButton, GUILayout.Width(80))) { ChangeSortColumn(ClipSortColumn.ForceMono); } columnPrefix = ColumnPrefix(ClipSortColumn.AudioFormat); if (GUILayout.Button(new GUIContent(columnPrefix + "Audio Format", "Click to sort by Audio Format"), EditorStyles.toolbarButton, GUILayout.Width(144))) { ChangeSortColumn(ClipSortColumn.AudioFormat); } columnPrefix = ColumnPrefix(ClipSortColumn.LoadType); if (GUILayout.Button(new GUIContent(columnPrefix + "Load Type", "Click to sort by Load Type"), EditorStyles.toolbarButton, GUILayout.Width(182))) { ChangeSortColumn(ClipSortColumn.LoadType); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); if (FilteredClips.Count == 0) { DTGUIHelper.ShowLargeBarAlert("You have filtered all clips out."); return; } _scrollPos = GUI.BeginScrollView(new Rect(0, 123, 896, 485), _scrollPos, new Rect(0, 124, 880, 24 * FilteredClips.Count + 4)); foreach (var aClip in FilteredClips) { // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression if (aClip.IsSelected) { GUI.backgroundColor = DTGUIHelper.BrightButtonColor; } else { GUI.backgroundColor = Color.white; } EditorGUILayout.BeginHorizontal(EditorStyles.miniButtonMid); // miniButtonMid, numberField, textField EditorGUILayout.BeginHorizontal(); var wasSelected = aClip.IsSelected; aClip.IsSelected = GUILayout.Toggle(aClip.IsSelected, ""); if (aClip.IsSelected) { if (!wasSelected) { SelectClip(aClip); } } var bitrateChanged = !aClip.OrigCompressionBitrate.Equals(aClip.CompressionBitrate); var is3DChanged = !aClip.OrigIs3D.Equals(aClip.Is3D); var isMonoChanged = !aClip.OrigForceMono.Equals(aClip.ForceMono); var isFormatChanged = !aClip.OrigFormat.Equals(aClip.Format); var isLoadTypeChanged = !aClip.OrigLoadType.Equals(aClip.LoadType); var hasChanged = bitrateChanged || is3DChanged || isMonoChanged || isFormatChanged || isLoadTypeChanged; if (!hasChanged) { ShowDisabledColors(); } else { GUI.contentColor = DTGUIHelper.BrightButtonColor; } if (GUILayout.Button(new GUIContent("Revert"), EditorStyles.toolbarButton, GUILayout.Width(45))) { if (!hasChanged) { DTGUIHelper.ShowAlert("This clip's properties have not changed."); } else { RevertChanges(aClip); } } RevertColor(); GUILayout.Space(10); GUILayout.Label(new GUIContent(aClip.Name, aClip.FullPath), GUILayout.Width(150)); GUILayout.Space(10); MaybeShowChangedColors(bitrateChanged); var oldBitrate = aClip.CompressionBitrate; var bitRate = (int)(aClip.CompressionBitrate * .001f); aClip.CompressionBitrate = EditorGUILayout.IntSlider("", bitRate, 32, 256, GUILayout.Width(202)) * 1000; if (oldBitrate != aClip.CompressionBitrate) { aClip.IsSelected = true; SelectClip(aClip); } RevertColor(); GUILayout.Space(12); MaybeShowChangedColors(is3DChanged); var old3D = aClip.Is3D; aClip.Is3D = GUILayout.Toggle(aClip.Is3D, ""); if (old3D != aClip.Is3D) { aClip.IsSelected = true; SelectClip(aClip); } RevertColor(); GUILayout.Space(36); MaybeShowChangedColors(isMonoChanged); var oldMono = aClip.ForceMono; aClip.ForceMono = GUILayout.Toggle(aClip.ForceMono, "", GUILayout.Width(40)); if (oldMono != aClip.ForceMono) { aClip.IsSelected = true; SelectClip(aClip); } RevertColor(); GUILayout.Space(10); MaybeShowChangedColors(isFormatChanged); var oldFmt = aClip.Format; aClip.Format = (AudioImporterFormat)EditorGUILayout.EnumPopup(aClip.Format, GUILayout.Width(136)); if (oldFmt != aClip.Format) { aClip.IsSelected = true; SelectClip(aClip); } RevertColor(); GUILayout.Space(6); MaybeShowChangedColors(isLoadTypeChanged); var oldLoad = aClip.LoadType; aClip.LoadType = (AudioImporterLoadType)EditorGUILayout.EnumPopup(aClip.LoadType, GUILayout.Width(140)); if (oldLoad != aClip.LoadType) { aClip.IsSelected = true; SelectClip(aClip); } RevertColor(); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); RevertColor(); } GUI.EndScrollView(); }
void DoRecord() { var instance = LuaDeepProfilerSetting.Instance; if (!instance.isRecord) { return; } EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); bool state = instance.isStartRecord; instance.isStartRecord = GUILayout.Toggle(instance.isStartRecord, "StartRecord", EditorStyles.toolbarButton, GUILayout.Height(30)); if (!state && instance.isStartRecord) { m_TreeView.Clear(true); m_luaRefScrollView.ClearRefInfo(true); NetWorkServer.SendCmd(0); } if (state && !instance.isStartRecord) { m_TreeView.LoadHistoryCurve(); } int count = m_TreeView.history.Count - 1; int delta = Mathf.Max(0, count - m_lastCount); if (delta != 0) { endFrame = count; } int oldStartFrame = startFrame; GUILayout.Label("start", EditorStyles.toolbarButton, GUILayout.Height(30), GUILayout.Width(45)); startFrame = EditorGUILayout.IntSlider(startFrame, 0, count, GUILayout.Width(150)); if (GUILayout.Button("<< ", EditorStyles.toolbarButton, GUILayout.Height(30), GUILayout.Width(30))) { startFrame = m_TreeView.GetPreProgramFrame(startFrame); endFrame = startFrame; } if (GUILayout.Button("< ", EditorStyles.toolbarButton, GUILayout.Height(30), GUILayout.Width(30))) { startFrame = Mathf.Max(startFrame - 1, 0); } if (GUILayout.Button(" >", EditorStyles.toolbarButton, GUILayout.Height(30), GUILayout.Width(30))) { startFrame = Mathf.Min(startFrame + 1, count); } if (GUILayout.Button(" >>", EditorStyles.toolbarButton, GUILayout.Height(30), GUILayout.Width(30))) { startFrame = m_TreeView.GetNextProgramFrame(startFrame); endFrame = startFrame; } int oldEndFrame = endFrame; GUILayout.Space(15); GUILayout.Label("end", EditorStyles.toolbarButton, GUILayout.Height(30), GUILayout.Width(45)); endFrame = EditorGUILayout.IntSlider(endFrame, 0, count, GUILayout.Width(150)); if (GUILayout.Button("<< ", EditorStyles.toolbarButton, GUILayout.Height(30), GUILayout.Width(30))) { endFrame = m_TreeView.GetPreProgramFrame(endFrame); startFrame = endFrame; } if (GUILayout.Button("< ", EditorStyles.toolbarButton, GUILayout.Height(30), GUILayout.Width(30))) { endFrame = Mathf.Max(endFrame - 1, 0); } if (GUILayout.Button(" >", EditorStyles.toolbarButton, GUILayout.Height(30), GUILayout.Width(30))) { endFrame = Mathf.Min(endFrame + 1, count); } if (GUILayout.Button(" >>", EditorStyles.toolbarButton, GUILayout.Height(30), GUILayout.Width(30))) { endFrame = m_TreeView.GetNextProgramFrame(endFrame); startFrame = endFrame; } GUILayout.Space(25); GUILayout.Label("capture lua gc", EditorStyles.toolbarButton, GUILayout.Height(30), GUILayout.Width(80)); LuaDeepProfilerSetting.Instance.captureLuaGC = EditorGUILayout.IntField(LuaDeepProfilerSetting.Instance.captureLuaGC, GUILayout.Height(16), GUILayout.Width(50)); LuaDeepProfilerSetting.Instance.captureLuaGC = Mathf.Max(0, LuaDeepProfilerSetting.Instance.captureLuaGC); GUILayout.Label("capture mono gc", EditorStyles.toolbarButton, GUILayout.Height(30), GUILayout.Width(100)); LuaDeepProfilerSetting.Instance.captureMonoGC = EditorGUILayout.IntField(LuaDeepProfilerSetting.Instance.captureMonoGC, GUILayout.Height(16), GUILayout.Width(50)); LuaDeepProfilerSetting.Instance.captureMonoGC = Mathf.Max(0, LuaDeepProfilerSetting.Instance.captureMonoGC); GUILayout.Label("capture frame rate", EditorStyles.toolbarButton, GUILayout.Height(30), GUILayout.Width(100)); LuaDeepProfilerSetting.Instance.captureFrameRate = EditorGUILayout.IntField(LuaDeepProfilerSetting.Instance.captureFrameRate, GUILayout.Height(16), GUILayout.Width(40)); LuaDeepProfilerSetting.Instance.captureFrameRate = Mathf.Max(0, LuaDeepProfilerSetting.Instance.captureFrameRate); m_lastCount = count; GUILayout.Space(25); GUILayout.FlexibleSpace(); if (oldStartFrame != startFrame || oldEndFrame != endFrame) { m_TreeView.ReLoadSamples(startFrame, endFrame); int startGameFrame = m_TreeView.GetFrameCount(startFrame); int endGameFrame = m_TreeView.GetFrameCount(endFrame); m_luaRefScrollView.LoadHistory(startGameFrame, endGameFrame); if (EditorApplication.isPlaying) { EditorApplication.isPaused = true; } } bool isSave = GUILayout.Button("Save", EditorStyles.toolbarButton, GUILayout.Height(30), GUILayout.Width(50)); if (isSave) { m_TreeView.SaveHisotry(); } bool isLoad = GUILayout.Button("Load", EditorStyles.toolbarButton, GUILayout.Height(30), GUILayout.Width(50)); if (isLoad) { m_TreeView.LoadHistory(); } GUILayout.Space(10); EditorGUILayout.EndHorizontal(); }