Skip to content

Commit 26d0b1d

Browse files
authored
Upload in UPM Package Format
1 parent 90efb8e commit 26d0b1d

47 files changed

Lines changed: 4596 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
4+
5+
## [2.0.0] - 2022-09-07
6+
7+
- Initial Release.

CHANGELOG.md.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/AIAgentEditor.cs

Lines changed: 753 additions & 0 deletions
Large diffs are not rendered by default.

Editor/AIAgentEditor.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/MAI_EditorUtility.cs

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
using UnityEngine;
2+
using UnityEditor;
3+
using UnityEditorInternal;
4+
using System;
5+
6+
namespace Kitbashery.AI
7+
{
8+
/// <summary>
9+
/// Utility class for drawing commonly used editor GUI elements for modular AI's custom inspectors.
10+
/// </summary>
11+
public static class MAI_EditorUtility
12+
{
13+
public static GUIStyle centeredBoldHelpBox = new GUIStyle(EditorStyles.helpBox) { fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleCenter };
14+
public static GUIStyle wrappedMiniLabel = new GUIStyle(GUI.skin.label) { wordWrap = true, fontSize = 10 };
15+
public static GUIStyle miniLabel = new GUIStyle(GUI.skin.label) { clipping = TextClipping.Overflow, fontSize = 10 };
16+
public static GUIStyle centeredMiniLabel = new GUIStyle(GUI.skin.label) { clipping = TextClipping.Overflow, fontSize = 10, alignment = TextAnchor.MiddleCenter };
17+
public static GUIStyle upperLeftMiniLabel = new GUIStyle(GUI.skin.label) { clipping = TextClipping.Overflow, fontSize = 10, alignment = TextAnchor.UpperLeft };
18+
public static GUIStyle centeredLabel = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter };
19+
public static GUIStyle centeredBoldLabel = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleCenter, fontStyle = FontStyle.Bold };
20+
public static GUIStyle middleLeftBoldLabel = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleLeft, fontStyle = FontStyle.Bold };
21+
public static GUIStyle lowerLeftBoldLabel = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.LowerLeft, fontStyle = FontStyle.Bold };
22+
public static GUIStyle clippingBoldLabel = new GUIStyle(GUI.skin.label) { clipping = TextClipping.Overflow, fontStyle = FontStyle.Bold };
23+
public static GUIStyle rightAlignedLabel = new GUIStyle(GUI.skin.label) { alignment = TextAnchor.MiddleRight };
24+
public static GUIStyle richText = new GUIStyle(GUI.skin.label) { richText = true };
25+
public static GUILayoutOption[] horizontalLine = new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(1) };
26+
public static GUILayoutOption[] thickHorizontalLine = new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(3) };
27+
28+
/// <summary>
29+
/// Draws a bold title with a help button that toggles a help box.
30+
/// Useage example: myBool = DrawHelpTitleToggle(myBool, "title", "message");
31+
/// </summary>
32+
/// <param name="toggle">Boolean to pass in and return.</param>
33+
/// <param name="title">Text for the bold title.</param>
34+
/// <param name="text">Text for the help box to display.</param>
35+
/// <returns>toggle</returns>
36+
public static bool DrawHelpTitleToggle(bool toggle, string title, string text)
37+
{
38+
EditorGUILayout.BeginHorizontal();
39+
EditorGUILayout.LabelField(title, EditorStyles.boldLabel);
40+
if (GUILayout.Button(EditorGUIUtility.IconContent("_Help"), GUIStyle.none, GUILayout.Width(20))) { toggle = !toggle; }
41+
EditorGUILayout.EndHorizontal();
42+
if (toggle == true)
43+
{
44+
EditorGUILayout.HelpBox(text, MessageType.Info);
45+
}
46+
GUILayout.Box("", thickHorizontalLine);
47+
48+
return toggle;
49+
}
50+
51+
public static bool DrawFoldout(bool value, string label)
52+
{
53+
bool _value;
54+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
55+
56+
_value = EditorGUILayout.Toggle(value, EditorStyles.foldout);
57+
58+
EditorGUILayout.EndVertical();
59+
60+
var rect = GUILayoutUtility.GetLastRect();
61+
rect.x += 20;
62+
rect.width -= 20;
63+
64+
EditorGUI.LabelField(rect, label, EditorStyles.boldLabel);
65+
return _value;
66+
}
67+
68+
public static int DrawCompactPopup(string label, int value, string[] options)
69+
{
70+
EditorGUILayout.BeginHorizontal();
71+
EditorGUILayout.LabelField(label, GUILayout.Width(75));
72+
value = EditorGUILayout.Popup(value, options);
73+
EditorGUILayout.EndHorizontal();
74+
return value;
75+
}
76+
77+
78+
public static void DrawComponentOptions(Component component)
79+
{
80+
if (GUILayout.Button(EditorGUIUtility.IconContent("_Menu"), EditorStyles.helpBox, GUILayout.Width(24), GUILayout.Height(24)))
81+
{
82+
GenericMenu menu = new GenericMenu();
83+
menu.AddItem(new GUIContent("Move Component Up"), false, MoveComponentUp, component);
84+
menu.AddSeparator("");
85+
menu.AddItem(new GUIContent("Move Component Down"), false, MoveComponentDown, component);
86+
menu.AddSeparator("");
87+
menu.AddItem(new GUIContent("Copy Component"), false, CopyComponentValues, component);
88+
menu.AddSeparator("");
89+
menu.AddItem(new GUIContent("Paste Component Values"), false, PasteComponentValues, component);
90+
menu.AddSeparator("");
91+
menu.AddItem(new GUIContent("Reset"), false, ResetComponentValues, component);
92+
menu.ShowAsContext();
93+
}
94+
}
95+
96+
static void MoveComponentUp(object component)
97+
{
98+
ComponentUtility.MoveComponentUp((Component)component);
99+
}
100+
101+
static void MoveComponentDown(object component)
102+
{
103+
ComponentUtility.MoveComponentDown((Component)component);
104+
}
105+
106+
static void CopyComponentValues(object component)
107+
{
108+
ComponentUtility.CopyComponent((Component)component);
109+
}
110+
111+
static void PasteComponentValues(object component)
112+
{
113+
ComponentUtility.PasteComponentValues((Component)component);
114+
}
115+
116+
static void ResetComponentValues(object component)
117+
{
118+
Component c = (Component)component;
119+
Type t = c.GetType();
120+
GameObject go = c.gameObject;
121+
GameObject.DestroyImmediate(c);
122+
go.AddComponent(t);
123+
}
124+
}
125+
}

Editor/MAI_EditorUtility.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "kitbashery.modular-ai.Editor",
3+
"rootNamespace": "",
4+
"references": [
5+
"GUID:ccf8ba3375b6aeb46bcf987ccab5d75a"
6+
],
7+
"includePlatforms": [],
8+
"excludePlatforms": [],
9+
"allowUnsafeCode": false,
10+
"overrideReferences": false,
11+
"precompiledReferences": [],
12+
"autoReferenced": true,
13+
"defineConstraints": [],
14+
"versionDefines": [],
15+
"noEngineReferences": false
16+
}

Editor/kitbashery.modular-ai.Editor.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gizmos.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)