/// <summary> /// Draws the "Brush Name" input field. /// </summary> /// <remarks> /// <para>User input is a shared property that is stored under the key /// <see cref="BrushCreatorSharedPropertyKeys.BrushName"/>.</para> /// </remarks> protected void DrawBrushNameField() { ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Name:")); GUI.SetNextControlName(this.Context.PrimaryAssetNameControlName); string brushName = this.Context.GetSharedProperty(BrushCreatorSharedPropertyKeys.BrushName, ""); brushName = EditorGUILayout.TextField(brushName).Trim(); this.Context.SetSharedProperty(BrushCreatorSharedPropertyKeys.BrushName, brushName); RotorzEditorGUI.MiniFieldDescription(TileLang.Text("Must start with alphanumeric character (A-Z a-z 0-9) and can contain hyphens (-), underscores (_) and spaces.")); }
/// <inheritdoc/> public override void OnGUI() { GUILayout.Label(TileLang.Text("Create new brush that is based upon an existing brush to override properties and materials."), EditorStyles.wordWrappedLabel); GUILayout.Space(10f); this.DrawBrushNameField(); GUILayout.Space(10f); ExtraEditorGUI.AbovePrefixLabel(TileLang.Text("Select target brush to create an alias of:")); var targetBrush = this.Context.GetSharedProperty <Brush>(BrushCreatorSharedPropertyKeys.TargetBrush); targetBrush = RotorzEditorGUI.BrushField(targetBrush, false); this.Context.SetSharedProperty(BrushCreatorSharedPropertyKeys.TargetBrush, targetBrush); RotorzEditorGUI.MiniFieldDescription(TileLang.Text("Note: You cannot create an alias of another alias brush.")); }
protected virtual void DrawTilesetBrushInfoActions() { this.DrawProceduralField(this.TilesetBrush, this.TilesetBrush.Tileset); if (this.TilesetBrush.Tileset.GetTileMesh(this.TilesetBrush.tileIndex) != null) { RotorzEditorGUI.MiniFieldDescription(TileLang.Text("Non-procedural mesh has been generated.")); } else if (!this.TilesetBrush.IsProcedural) { EditorGUILayout.HelpBox(TileLang.Text("Non-procedural mesh asset is missing."), MessageType.Warning, true); if (GUILayout.Button(TileLang.ParticularText("Action", "Repair"))) { // Ensure that required procedural mesh exists! if (BrushUtility.EnsureTilesetMeshExists(this.TilesetBrush.Tileset, this.TilesetBrush.tileIndex)) { AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(this.TilesetBrush.Tileset.tileMeshAsset)); } GUIUtility.ExitGUI(); } } }
/// <inheritdoc/> public override void OnExtendedPropertiesGUI() { using (var content = ControlContent.WithTrailableTip( TileLang.ParticularText("Property", "Always Add Container"), TileLang.Text("Add tile container object even when not needed by brush.") )) { if (this.AutotileBrush.IsProcedural) { this.AutotileBrush.alwaysAddContainer = EditorGUILayout.ToggleLeft(content, this.AutotileBrush.alwaysAddContainer); ExtraEditorGUI.TrailingTip(content); if (this.brushAttachPrefabTick) { ExtraEditorGUI.SeparatorLight(); } } } using (var content = ControlContent.WithTrailableTip( TileLang.ParticularText("Property", "Attach Prefab"), TileLang.Text("Additional game objects can be painted by attaching a prefab.") )) { bool newAttachPrefabTick = EditorGUILayout.ToggleLeft(content, this.brushAttachPrefabTick); if (!newAttachPrefabTick) { ExtraEditorGUI.TrailingTip(content); } // Has state of prefab tick changed? if (newAttachPrefabTick != this.brushAttachPrefabTick) { this.brushAttachPrefabTick = newAttachPrefabTick; // Should attachment be cleared? if (!this.brushAttachPrefabTick) { TilesetBrush.attachPrefab = null; } } } if (this.brushAttachPrefabTick) { ++EditorGUI.indentLevel; this.TilesetBrush.attachPrefab = EditorGUILayout.ObjectField(TilesetBrush.attachPrefab, typeof(GameObject), false) as GameObject; GUILayout.Space(3); this.OnExtendedGUI_ScaleMode(); --EditorGUI.indentLevel; } ExtraEditorGUI.SeparatorLight(marginBottom: 2); float restoreLabelWidth = EditorGUIUtility.labelWidth; float restoreFieldWidth = EditorGUIUtility.fieldWidth; bool autoInitCollider = false; EditorGUIUtility.labelWidth = 70; EditorGUIUtility.fieldWidth = 1; GUILayout.BeginHorizontal(); { GUILayout.BeginVertical(); { RotorzEditorGUI.MiniFieldDescription(TileLang.Text("Edge Tiles")); using (var content = ControlContent.Basic( TileLang.ParticularText("Flaggable", "Solid Flag"), TileLang.Text("Solid flag can be used to assist with user defined collision detection or pathfinding.") )) { this.AutotileBrush.SolidFlag = EditorGUILayout.ToggleLeft(content, this.AutotileBrush.SolidFlag); } using (var content = ControlContent.Basic( TileLang.ParticularText("Property", "Add Collider"), TileLang.Text("Automatically adds box collider to painted tile.") )) { EditorGUI.BeginChangeCheck(); this.AutotileBrush.addCollider = EditorGUILayout.ToggleLeft(content, this.AutotileBrush.addCollider); autoInitCollider |= (EditorGUI.EndChangeCheck() && this.AutotileBrush.addCollider); } } GUILayout.EndVertical(); GUILayout.BeginVertical(); { RotorzEditorGUI.MiniFieldDescription(TileLang.Text("Inner Tiles")); using (var content = ControlContent.Basic( TileLang.ParticularText("Flaggable", "Solid Flag"), TileLang.Text("Solid flag can be used to assist with user defined collision detection or pathfinding.") )) { this.AutotileBrush.InnerSolidFlag = EditorGUILayout.ToggleLeft(content, this.AutotileBrush.InnerSolidFlag); } using (var content = ControlContent.Basic( TileLang.ParticularText("Property", "Add Collider"), TileLang.Text("Automatically adds box collider to painted tile.") )) { EditorGUI.BeginChangeCheck(); this.AutotileBrush.addInnerCollider = EditorGUILayout.ToggleLeft(content, this.AutotileBrush.addInnerCollider); autoInitCollider |= (EditorGUI.EndChangeCheck() && this.AutotileBrush.addInnerCollider); } } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); if (autoInitCollider) { this.AutotileBrush.colliderType = BrushUtility.AutomaticColliderType; } if (this.AutotileBrush.addCollider || this.AutotileBrush.addInnerCollider) { ++EditorGUI.indentLevel; this.AutotileBrush.colliderType = (ColliderType)EditorGUILayout.EnumPopup(this.AutotileBrush.colliderType); --EditorGUI.indentLevel; } EditorGUIUtility.labelWidth = restoreLabelWidth; EditorGUIUtility.fieldWidth = restoreFieldWidth; if (ControlContent.TrailingTipsVisible) { ExtraEditorGUI.TrailingTip(TileLang.Text("Edge and Inner 'solid' flag can be used for custom collision detection. Avoid inner colliders where possible.")); } }