Skip to content

Commit

Permalink
Updated readme
Browse files Browse the repository at this point in the history
Added Probe display on hierarchy
Improved tooltip on Movement components
  • Loading branch information
DiogoDeAndrade committed Mar 22, 2023
1 parent 792e728 commit e7ec7f1
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Assets/OkapiKit/Samples/Snippets/Probe.unity
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
_showInfo: 1
_explanation: ' switches to scene Snippets'
_explanation: Switches to scene Snippets
description:
enableAction: 1
hasTags: 0
Expand All @@ -175,7 +175,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
_showInfo: 1
_explanation: "When key Escape is pressed:\n switches to scene Snippets\n"
_explanation: "When key Escape is pressed:\n switches to scene Snippets\n"
description:
enableTrigger: 1
allowRetrigger: 1
Expand Down
31 changes: 22 additions & 9 deletions Assets/OkapiKit/Scripts/Editor/OkapiDisplayHierarchy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private static void HierarchyItemCB(int instanceID, Rect selectionRect)
{
if (selectionRect.width < 200) return;

float controlsWidth = 5 * 10;
float controlsWidth = 6 * 10;
float xBase = selectionRect.x + selectionRect.width - controlsWidth;

if (selectionRect.Contains(Event.current.mousePosition))
Expand All @@ -31,15 +31,14 @@ private static void HierarchyItemCB(int instanceID, Rect selectionRect)
var triggers = go.GetComponents<Trigger>();
var actions = go.GetComponents<Action>();
var path = go.GetComponent<Path>();
var probes = go.GetComponents<Probe>();

if (variable) DrawCircle(xBase, selectionRect.y, GUIUtils.ColorFromHex("#fffaa7"));
if (movement) DrawCircle(xBase + 10, selectionRect.y, GUIUtils.ColorFromHex("#ffcaca"));
if ((triggers != null) && (triggers.Length > 0)) DrawCircle(xBase + 20, selectionRect.y, GUIUtils.ColorFromHex("#D0FFFF"));
if ((actions != null) && (actions.Length > 0))
{
DrawCircle(xBase + 30, selectionRect.y, GUIUtils.ColorFromHex("#D7E8BA"));
}
if (path) DrawCircle(xBase + 40, selectionRect.y, GUIUtils.ColorFromHex("#ff8040"));
if ((actions != null) && (actions.Length > 0)) DrawCircle(xBase + 30, selectionRect.y, GUIUtils.ColorFromHex("#D7E8BA"));
if ((probes != null) && (probes.Length > 0)) DrawCircle(xBase + 40, selectionRect.y, GUIUtils.ColorFromHex("#ffd283"));
if (path) DrawCircle(xBase + 50, selectionRect.y, GUIUtils.ColorFromHex("#ff8040"));

var tags = go.GetTagsString();
if (tags != "")
Expand All @@ -49,13 +48,14 @@ private static void HierarchyItemCB(int instanceID, Rect selectionRect)
}

if ((variable) && (HasTooltip(xBase, selectionRect.y))) SetTooltip(GUIUtils.ColorFromHex("#fffaa7"), "Variable", $"{variable.name}");
if ((movement) && (HasTooltip(xBase + 10, selectionRect.y))) SetTooltip(GUIUtils.ColorFromHex("#ffcaca"), "Movement", $"Movement: {movement.GetTitle()}");
if ((movement) && (HasTooltip(xBase + 10, selectionRect.y))) SetTooltip(GUIUtils.ColorFromHex("#ffcaca"), $"{movement.GetTitle()}", $"Movement: {movement.UpdateExplanation()}");
if ((triggers != null) && (triggers.Length > 0) && (HasTooltip(xBase + 20, selectionRect.y)))
{
string tooltip = "";
for (int i = 0; i < triggers.Length; i++)
{
if (tooltip != "") tooltip += "\n---------------\n";
if (tooltip != "") tooltip += $"\n";
tooltip += $"Trigger {i + 1}:\n";
tooltip += triggers[i].UpdateExplanation();
}
tooltip.Remove(tooltip.Length - 1);
Expand All @@ -73,7 +73,20 @@ private static void HierarchyItemCB(int instanceID, Rect selectionRect)

SetTooltip(GUIUtils.ColorFromHex("#D7E8BA"), "Actions", tooltip);
}
if ((path) && (HasTooltip(xBase + 40, selectionRect.y))) SetTooltip(GUIUtils.ColorFromHex("#ffcaca"), "Path", "");
if ((probes != null) && (probes.Length > 0) && (HasTooltip(xBase + 40, selectionRect.y)))
{
string tooltip = "";
for (int i = 0; i < probes.Length; i++)
{
if (tooltip != "") tooltip += $"\n\n";
tooltip += $"Probe {i + 1}:\n";
tooltip += probes[i].UpdateExplanation();
}
tooltip.Remove(tooltip.Length - 1);

SetTooltip(GUIUtils.ColorFromHex("#d1d283"), "Probes", tooltip);
}
if ((path) && (HasTooltip(xBase + 50, selectionRect.y))) SetTooltip(GUIUtils.ColorFromHex("#ffcaca"), "Path", "");

if (tags != "")
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/OkapiKit/Scripts/Editor/OkapiTooltipWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void Show(Color color, string text)
size.y = lines.Length * (style.fixedHeight + 2);

size.x += 10;
size.y += 10;
size.y += 15;

var newPos = GUIUtility.GUIToScreenPoint(Event.current.mousePosition);
newPos.x -= 5;
Expand Down
2 changes: 2 additions & 0 deletions Assets/OkapiKit/Scripts/Editor/ProbeEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public override void OnInspectorGUI()
EditorGUILayout.PropertyField(propTags, new GUIContent("Tags"));
EditorGUILayout.PropertyField(propTargetTransform, new GUIContent("Target Transform"));

EditorGUILayout.PropertyField(propDescription, new GUIContent("Description"));

EditorGUI.EndChangeCheck();

serializedObject.ApplyModifiedProperties();
Expand Down
1 change: 1 addition & 0 deletions Assets/OkapiKit/Scripts/Systems/Probe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public string GetTags()

return desc;
}

public override string GetRawDescription(string ident, GameObject refObject)
{
string desc = ident;
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.5.0",
"version": "1.5.1",
"unity": "2021.3",
"description": "OkapiKit is a toolkit for creation of simple games without code.",
"keywords": [ "kit" ],
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Use the UPM Git extension to install the OkapiKit:
# Samples

It currently has six sample 'games' (each a Scene under the Samples directory), accessible through a menu (Samples scene, also in the Samples directory).
There are also some code snippets demonstrating some of the features, but devoid of any meaningful context. The Snippets menu can be accessed through the Samples scene.

## Pong
![PongImage](Screenshots/pong.png)
Expand All @@ -71,6 +72,11 @@ It currently has six sample 'games' (each a Scene under the Samples directory),
## Commando
![CommandoImage](Screenshots/commando.png)

## Snippets
### Probe: Shows probe usage
### StoppingDistance: Shows how to use the Stopping Distance property on the Follow movement
### Platformer: Shows the Platformer movement controller

#
# Documentation

Expand Down

0 comments on commit e7ec7f1

Please sign in to comment.