Skip to content

Commit

Permalink
Added hierarchy view icons and tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
DiogoDeAndrade committed Mar 22, 2023
1 parent 4865534 commit 5e6c749
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 202 deletions.
316 changes: 120 additions & 196 deletions Assets/OkapiKit/Samples/Asteroids/Asteroids.unity

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Assets/OkapiKit/Scripts/Actions/ActionChangeScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ActionChangeScene : Action

public override string GetRawDescription(string ident, GameObject gameObject)
{
return $"{GetPreconditionsString(gameObject)} switches to scene {sceneName}";
return $"{GetPreconditionsString(gameObject)}switches to scene {sceneName}";
}

public override void Execute()
Expand Down
21 changes: 21 additions & 0 deletions Assets/OkapiKit/Scripts/Editor/GUIUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ static public Rect DrawOutlineLabel(string text, GUIStyle style, Color outlineCo

static Dictionary<string, GUIStyle> styles;

static public GUIStyle GetTooltipTextStyle()
{
if (styles == null) styles = new Dictionary<string, GUIStyle>();

GUIStyle titleStyle;
styles.TryGetValue("TooltipTextStyle", out titleStyle);
if (titleStyle == null)
{
titleStyle = new GUIStyle(GUI.skin.label);
titleStyle.fontSize = 12;
titleStyle.fixedHeight = 12;
titleStyle.clipping = TextClipping.Overflow;
titleStyle.alignment = TextAnchor.UpperLeft;
titleStyle.normal.textColor = new Color(0.3f, 0.3f, 0.3f, 1.0f);
titleStyle.hover.textColor = new Color(0.3f, 0.3f, 0.3f, 1.0f);
titleStyle.wordWrap = true;
styles.Add("TooltipTextStyle", titleStyle);
}
return titleStyle;
}

static public GUIStyle GetActionDelayTextStyle()
{
if (styles == null) styles = new Dictionary<string, GUIStyle>();
Expand Down
6 changes: 5 additions & 1 deletion Assets/OkapiKit/Scripts/Editor/HypertaggedObjectEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ protected override GUIStyle GetExplanationStyle()

protected override string GetTitle()
{
return (target as HypertaggedObject).GetTagString();
string ret = (target as HypertaggedObject).GetTagString();

if (ret == "") return "Hypertag";

return ret;
}

protected override Texture2D GetIcon()
Expand Down
24 changes: 24 additions & 0 deletions Assets/OkapiKit/Scripts/Hypertag/HypertagExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,28 @@ public static bool HasHypertag(this GameObject go, Hypertag tag)

return false;
}

public static Hypertag[] GetTags(this GameObject go)
{
var hos = go.GetComponent<HypertaggedObject>();

if (hos == null)
{
return null;
}

return hos.GetTags();
}

public static string GetTagsString(this GameObject go)
{
var ret = new List<Hypertag>();
var hos = go.GetComponent<HypertaggedObject>();
if (hos == null)
{
return "";
}

return hos.GetTagString();
}
}
5 changes: 4 additions & 1 deletion Assets/OkapiKit/Scripts/Hypertag/HypertaggedObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
using UnityEngine;
using NaughtyAttributes;

[DisallowMultipleComponent]
public class HypertaggedObject : OkapiElement
{
[SerializeField]
private List<Hypertag> hypertags;

public Hypertag[] GetTags() { return hypertags.ToArray(); }

public string GetTagString()
{
if ((hypertags == null) || (hypertags.Count == 0)) return "Hypertag";
if ((hypertags == null) || (hypertags.Count == 0)) return "";

string ret = "";
foreach (var tag in hypertags)
Expand Down
2 changes: 1 addition & 1 deletion Assets/OkapiKit/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.videojogoslusofona.okapikit",
"displayName": "OkapiKit",
"version": "1.3.3",
"version": "1.5.0",
"unity": "2021.3",
"description": "OkapiKit is a toolkit for creation of simple games without code.",
"keywords": [ "kit" ],
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ several Okapi Kit components (identifiable by the large title). We have a moveme
as targets for operations), we have a collision Trigger (with the text that explains when it triggers,
and what happens), and finally we have several Action scripts (used by the Triggers), that also explain what they're doing.

There's also some icons on the Hierarchy view, indicating which type of Okapi object that objects has:

![InspectorImage](Screenshots/hierarchy01.png)

Placing the mouse cursor on top of any of the icons will display additional information. For example, here we placed the
cursor on top of the Trigger icon (blue dot) on the LevelManager object and we can see all the triggers that it has.

![InspectorImage](Screenshots/hierarchy02.png)

#
# Licenses

Expand Down
2 changes: 0 additions & 2 deletions Todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

Usability:
----------
- Enable drag/drop of action into actions (ActionRandom, Triggers)
- Highlight action by clicking/scroll there (not sure if possible)
- How to make simple actions more accessible? (see Simple Usage)
- Add a tree view to explore objects in the games
Expand Down Expand Up @@ -53,7 +52,6 @@ Games:
- Add animations to Commando game
- Create FlagCatcher game
- Create UI game (strategy, need to think about this a lot)
- Create Platformer (movement system, IsGrounded test)
- Create SpyGame (add AI system - StateMachine)
- Create Driving (add AI system - Markov chains)
- Create Commando 2 game (add AI system - 2d path finding)
Expand Down

0 comments on commit 5e6c749

Please sign in to comment.