Skip to content

Commit

Permalink
Add icon to behavior target button, align with panel title
Browse files Browse the repository at this point in the history
  • Loading branch information
vanjac committed Jul 20, 2024
1 parent e539579 commit 001fddc
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions Assets/VoxelEditor/GUI/PropertiesGUI.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

Expand Down Expand Up @@ -354,7 +354,6 @@ private void EntityPropertiesGUI() {
TutorialGUI.TutorialHighlight("add behavior");
if (GUILayout.Button(GUIUtils.PadContent(StringSet.AddBehavior, IconSet.newItem))) {
NewBehaviorGUI behaviorMenu = gameObject.AddComponent<NewBehaviorGUI>();
behaviorMenu.title = StringSet.AddBehavior;
behaviorMenu.self = singleSelectedEntity;
behaviorMenu.voxelArray = voxelArray;
behaviorMenu.handler = (PropertiesObjectType behaviorType) => {
Expand Down Expand Up @@ -498,6 +497,13 @@ public class NewBehaviorGUI : GUIPanel {
private Entity targetEntity;
private bool targetEntityIsActivator = false;

public static readonly System.Lazy<GUIStyle> titleStyle = new System.Lazy<GUIStyle>(
() => new GUIStyle(GUI.skin.label) {
alignment = TextAnchor.MiddleCenter,
// TODO: very ugly
fixedHeight = IconSet.target.height + GUI.skin.button.padding.top * 2,
});

public override Rect GetRect(Rect safeRect, Rect screenRect) {
if (entityPicker != null || typePicker == null) {
// move panel offscreen
Expand Down Expand Up @@ -565,15 +571,19 @@ public override void WindowGUI() {
} else if (targetEntity != null) {
targetButtonText = StringSet.TargetEntity(targetEntity.ToString(StringSet));
}
GUILayout.BeginHorizontal();
GUILayout.Label(StringSet.AddBehavior, titleStyle.Value);
TutorialGUI.TutorialHighlight("behavior target");
if (GUIUtils.HighlightedButton(targetButtonText)) {
if (GUIUtils.HighlightedButton(GUIUtils.PadContent(targetButtonText, IconSet.target), null,
targetEntity != null || targetEntityIsActivator, GUILayout.ExpandWidth(false))) {
entityPicker = PropertyGUIs.BehaviorTargetPicker(gameObject, voxelArray, self, value => {
targetEntity = value.targetEntity.entity;
targetEntityIsActivator = value.targetEntityIsActivator;
UpdateBehaviorList();
});
}
TutorialGUI.ClearHighlight();
GUILayout.EndHorizontal();
if (typePicker != null) {
typePicker.scroll = scroll;
typePicker.WindowGUI();
Expand Down

0 comments on commit 001fddc

Please sign in to comment.