[Test] Cleanup assemblies for Android build test. Working game flow, working build, passing unit tests

This commit is contained in:
Michal Pikulski
2025-09-15 09:30:27 +02:00
parent 15414f9414
commit 793da5e568
23 changed files with 25 additions and 45 deletions

View File

@@ -0,0 +1,106 @@
/// <summary>
/// SURGE FRAMEWORK
/// Author: Bob Berkebile
/// Email: bobb@pixelplacement.com
///
/// Custom inspector Chooser.
///
/// </summary>
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace Pixelplacement
{
[CustomEditor(typeof(Chooser), true)]
[CanEditMultipleObjects]
public class ChooserEditor : UnityEditor.Editor
{
//Private Variables:
Chooser _target;
//Flow:
void OnEnable()
{
_target = target as Chooser;
}
//Inspector GUI:
public override void OnInspectorGUI()
{
serializedObject.Update();
DrawPropertiesExcluding(serializedObject, new string[] {
"OnSelected",
"OnDeselected",
"OnPressed",
"OnReleased",
"_cursorPropertiesFolded",
"_unityEventsFolded",
"source",
"raycastDistance",
"layermask",
"pressedInput",
"cursor",
"surfaceOffset",
"idleDistance",
"stabilityDelta",
"snapDelta",
"stableSpeed",
"unstableSpeed",
"flipForward",
"matchSurfaceNormal",
"autoHide",
"cursorHidden",
"flipCastDirection",
"lineRenderer",
"_debugView",
"_method"
});
EditorGUILayout.PropertyField(serializedObject.FindProperty("source"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("raycastDistance"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("flipCastDirection"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("layermask"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("_method"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("_debugView"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("pressedInput"), true);
_target._cursorPropertiesFolded = EditorGUILayout.Foldout(_target._cursorPropertiesFolded, "Cursor Properties", true);
if (_target._cursorPropertiesFolded)
{
EditorGUI.indentLevel = 1;
EditorGUILayout.PropertyField(serializedObject.FindProperty("cursor"));
GUI.enabled = _target.cursor != null;
EditorGUILayout.PropertyField(serializedObject.FindProperty("cursorHidden"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("lineRenderer"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("surfaceOffset"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("idleDistance"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("stabilityDelta"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("snapDelta"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("stableSpeed"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("unstableSpeed"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("flipForward"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("matchSurfaceNormal"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("autoHide"));
EditorGUI.indentLevel = 0;
GUI.enabled = true;
EditorGUILayout.Space();
}
_target._unityEventsFolded = EditorGUILayout.Foldout(_target._unityEventsFolded, "Unity Events", true);
if (_target._unityEventsFolded)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("OnSelected"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("OnPressed"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("OnReleased"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("OnDeselected"));
EditorGUILayout.Space();
}
serializedObject.ApplyModifiedProperties();
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: ad17b9c71d7903743aa42f462c8826fb
timeCreated: 1522266293
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 107312
packageName: Surge
packageVersion: 1.0.48
assetPath: Assets/Pixelplacement/Surge/Chooser/Editor/ChooserEditor.cs
uploadId: 467433

View File

@@ -0,0 +1,127 @@
/// <summary>
/// SURGE FRAMEWORK
/// Author: Bob Berkebile
/// Email: bobb@pixelplacement.com
///
/// Custom inspector ColliderButton.
///
/// </summary>
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace Pixelplacement
{
[CustomEditor(typeof(ColliderButton), true)]
[CanEditMultipleObjects]
public class ColliderButtonEditor : UnityEditor.Editor
{
//Private Variables:
ColliderButton _target;
//Init:
void OnEnable()
{
_target = target as ColliderButton;
}
//Inspector GUI:
public override void OnInspectorGUI()
{
serializedObject.Update();
DrawPropertiesExcluding(serializedObject, new string[] {
"interactable",
"keyInput",
"collisionLayerMask",
"resizeGUIBoxCollider",
"centerGUIBoxCollider",
"guiBoxColliderPadding",
"Color Responses",
"applyColor",
"colorRendererTarget",
"colorImageTarget",
"colorImageTarget",
"selectedColor",
"pressedColor",
"disabledColor",
"colorDuration",
"Scale Responses",
"applyScale",
"scaleTarget",
"normalScale",
"selectedScale",
"pressedScale",
"scaleDuration",
"scaleEaseType",
"Unity Events",
"OnSelected",
"OnDeselected",
"OnClick",
"OnPressed",
"OnReleased",
"_unityEventsFolded",
"_scaleResponseFolded",
"_colorResponseFolded"
});
EditorGUILayout.PropertyField(serializedObject.FindProperty("interactable"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("keyInput"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("collisionLayerMask"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("resizeGUIBoxCollider"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("centerGUIBoxCollider"));
GUI.enabled = _target.resizeGUIBoxCollider;
EditorGUILayout.PropertyField(serializedObject.FindProperty("guiBoxColliderPadding"));
GUI.enabled = true;
_target._colorResponseFolded = EditorGUILayout.Foldout(_target._colorResponseFolded, "Color Responses", true);
if (_target._colorResponseFolded)
{
EditorGUI.indentLevel = 1;
EditorGUILayout.PropertyField(serializedObject.FindProperty("applyColor"));
GUI.enabled = _target.applyColor;
EditorGUILayout.PropertyField(serializedObject.FindProperty("colorRendererTarget"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("colorImageTarget"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("selectedColor"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("pressedColor"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("disabledColor"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("colorDuration"));
EditorGUI.indentLevel = 0;
GUI.enabled = true;
EditorGUILayout.Space();
}
_target._scaleResponseFolded = EditorGUILayout.Foldout(_target._scaleResponseFolded, "Scale Responses", true);
if (_target._scaleResponseFolded)
{
EditorGUI.indentLevel = 1;
EditorGUILayout.PropertyField(serializedObject.FindProperty("applyScale"));
GUI.enabled = _target.applyScale;
EditorGUILayout.PropertyField(serializedObject.FindProperty("scaleTarget"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("normalScale"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("selectedScale"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("pressedScale"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("scaleDuration"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("scaleEaseType"));
EditorGUI.indentLevel = 0;
GUI.enabled = true;
EditorGUILayout.Space();
}
//fold events:
_target._unityEventsFolded = EditorGUILayout.Foldout(_target._unityEventsFolded, "Unity Events", true);
if (_target._unityEventsFolded)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("OnSelected"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("OnDeselected"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("OnClick"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("OnPressed"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("OnReleased"));
}
serializedObject.ApplyModifiedProperties();
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 3f63601133a78564180c3d96d8448bda
timeCreated: 1521850300
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 107312
packageName: Surge
packageVersion: 1.0.48
assetPath: Assets/Pixelplacement/Surge/ColliderButton/Editor/ColliderButtonEditor.cs
uploadId: 467433

View File

@@ -0,0 +1,82 @@
/// <summary>
/// SURGE FRAMEWORK
/// Author: Bob Berkebile
/// Email: bobb@pixelplacement.com
///
/// Custom inspector for the DisplayObject class.
///
/// </summary>
using UnityEngine;
using System.Collections;
using UnityEditor;
namespace Pixelplacement
{
[CustomEditor (typeof (DisplayObject), true)]
public class DisplayObjectEditor : UnityEditor.Editor
{
//Private Variables:
DisplayObject _target;
//Init:
void OnEnable()
{
_target = target as DisplayObject;
}
//Inspector GUI:
public override void OnInspectorGUI()
{
DrawDefaultInspector ();
GUILayout.BeginHorizontal ();
DrawSoloButton ();
DrawShowButton ();
DrawHideButton ();
DrawHideAllButton ();
GUILayout.EndHorizontal ();
}
//GUI Draw Methods:
void DrawShowButton ()
{
GUI.color = Color.yellow;
if (GUILayout.Button ("Show"))
{
Undo.RegisterCompleteObjectUndo (_target, "Show DisplayObject");
_target.SetActive (true);
}
}
void DrawSoloButton ()
{
GUI.color = Color.green;
if (GUILayout.Button ("Solo"))
{
Undo.RegisterCompleteObjectUndo (_target, "Solo DisplayObject");
_target.Solo ();
}
}
void DrawHideButton ()
{
GUI.color = new Color (1, 0.5f, 0, 1);
if (GUILayout.Button ("Hide"))
{
Undo.RegisterCompleteObjectUndo (_target, "Hide DisplayObject");
_target.SetActive (false);
}
}
void DrawHideAllButton ()
{
GUI.color = Color.red;
if (GUILayout.Button ("Hide All"))
{
Undo.RegisterCompleteObjectUndo (_target, "Hide all DisplayObjects");
_target.HideAll ();
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 1494a48c2c33dfc499b2bfdd0ce24f5b
timeCreated: 1479232771
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 107312
packageName: Surge
packageVersion: 1.0.48
assetPath: Assets/Pixelplacement/Surge/DisplayObject/Editor/DisplayObjectEditor.cs
uploadId: 467433

View File

@@ -0,0 +1,18 @@
{
"name": "PixelplacementEditor",
"rootNamespace": "",
"references": [
"GUID:db4a9769b2b9c5a4788bcd189eea1f0b"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0547315a6b16c1a48bf1db2b83869a5a
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,38 @@
/// <summary>
/// SURGE FRAMEWORK
/// Author: Bob Berkebile
/// Email: bobb@pixelplacement.com
///
/// Forces pivot mode to center so an anchor's pivot is always correct while adjusting a spline.
///
/// </summary>
using UnityEditor;
using UnityEngine;
namespace Pixelplacement
{
[CustomEditor(typeof(SplineAnchor))]
public class SplineAnchorEditor : UnityEditor.Editor
{
//Scene GUI:
void OnSceneGUI ()
{
//ensure pivot is used so anchor selection has a proper transform origin:
if (Tools.pivotMode == PivotMode.Center)
{
Tools.pivotMode = PivotMode.Pivot;
}
}
//Gizmos:
[DrawGizmo(GizmoType.Selected)]
static void RenderCustomGizmo(Transform objectTransform, GizmoType gizmoType)
{
if (objectTransform.parent != null)
{
SplineEditor.RenderCustomGizmo(objectTransform.parent, gizmoType);
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 15d4e254e3652404797dcee644ec6a84
timeCreated: 1483388323
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 107312
packageName: Surge
packageVersion: 1.0.48
assetPath: Assets/Pixelplacement/Surge/Spline/Editor/SplineAnchorEditor.cs
uploadId: 467433

View File

@@ -0,0 +1,136 @@
/// <summary>
/// SURGE FRAMEWORK
/// Author: Bob Berkebile
/// Email: bobb@pixelplacement.com
///
/// Draws all controls for a spline.
///
/// </summary>
using UnityEditor;
using UnityEngine;
namespace Pixelplacement
{
[CustomEditor(typeof(Spline))]
public class SplineEditor : UnityEditor.Editor
{
//Private Variables
Spline _target;
//Init:
void OnEnable ()
{
_target = target as Spline;
}
//Inspector:
public override void OnInspectorGUI ()
{
//draw:
DrawDefaultInspector ();
DrawAddButton ();
}
//Gizmo Overload:
[DrawGizmo(GizmoType.Selected)]
public static void RenderCustomGizmo (Transform objectTransform, GizmoType gizmoType)
{
DrawTools (objectTransform);
}
//Scene GUI:
void OnSceneGUI ()
{
DrawTools ((target as Spline).transform);
}
//Draw Methods:
void DrawAddButton ()
{
if (GUILayout.Button ("Extend"))
{
Undo.RegisterCreatedObjectUndo (_target.AddAnchors (1) [0], "Extend Spline");
}
}
static void DrawTools (Transform target)
{
Spline spline = target.GetComponent<Spline> ();
if (spline == null) return;
if (target.transform.childCount == 0) return;
//set primary draw color:
Handles.color = spline.SecondaryColor;
for (int i = 0; i < spline.Anchors.Length; i++)
{
//refs:
Quaternion lookRotation = Quaternion.identity;
SplineAnchor currentAnchor = spline.Anchors[i];
//scale geometry:
currentAnchor.InTangent.localScale = Vector3.one * (spline.toolScale * 1.3f);
currentAnchor.OutTangent.localScale = Vector3.one * (spline.toolScale * 1.3f);
currentAnchor.Anchor.localScale = Vector3.one * (spline.toolScale * 2.1f);
if (spline.toolScale > 0)
{
//draw persistent identifiers that face the scene view camera and only draw if the corrosponding tangent is active:
if (currentAnchor.OutTangent.gameObject.activeSelf)
{
//connection:
Handles.DrawDottedLine (currentAnchor.Anchor.position, currentAnchor.OutTangent.position, 3);
//indicators:
if (SceneView.currentDrawingSceneView != null)
{
lookRotation = Quaternion.LookRotation ((SceneView.currentDrawingSceneView.camera.transform.position - currentAnchor.OutTangent.position).normalized);
Handles.CircleHandleCap (0, currentAnchor.OutTangent.position, lookRotation, spline.toolScale * .65f, EventType.Repaint);
Handles.CircleHandleCap (0, currentAnchor.OutTangent.position, lookRotation, spline.toolScale * .25f, EventType.Repaint);
}
}
if (currentAnchor.InTangent.gameObject.activeSelf)
{
//connection:
Handles.DrawDottedLine (currentAnchor.Anchor.position, currentAnchor.InTangent.position, 3);
//indicators:
if (SceneView.currentDrawingSceneView != null)
{
lookRotation = Quaternion.LookRotation ((SceneView.currentDrawingSceneView.camera.transform.position - currentAnchor.InTangent.position).normalized);
Handles.CircleHandleCap (0, currentAnchor.InTangent.position, lookRotation, spline.toolScale * .65f, EventType.Repaint);
Handles.CircleHandleCap (0, currentAnchor.InTangent.position, lookRotation, spline.toolScale * .25f, EventType.Repaint);
}
}
//anchor tools:
if (SceneView.currentDrawingSceneView != null)
{
lookRotation = Quaternion.LookRotation ((SceneView.currentDrawingSceneView.camera.transform.position - currentAnchor.Anchor.position).normalized);
Handles.CircleHandleCap (0, currentAnchor.Anchor.position, lookRotation, spline.toolScale, EventType.Repaint);
}
//identify path origin:
if (spline.direction == SplineDirection.Forward && i == 0 || spline.direction == SplineDirection.Backwards && i == spline.Anchors.Length - 1)
{
Handles.CircleHandleCap (0, currentAnchor.Anchor.position, lookRotation, spline.toolScale * .8f, EventType.Repaint);
Handles.CircleHandleCap (0, currentAnchor.Anchor.position, lookRotation, spline.toolScale * .75f, EventType.Repaint);
Handles.CircleHandleCap (0, currentAnchor.Anchor.position, lookRotation, spline.toolScale * .5f, EventType.Repaint);
Handles.CircleHandleCap (0, currentAnchor.Anchor.position, lookRotation, spline.toolScale * .45f, EventType.Repaint);
Handles.CircleHandleCap (0, currentAnchor.Anchor.position, lookRotation, spline.toolScale * .25f, EventType.Repaint);
}
}
}
//draw spline:
for (int i = 0; i < spline.Anchors.Length - 1; i++)
{
SplineAnchor startAnchor = spline.Anchors[i];
SplineAnchor endAnchor = spline.Anchors[i+1];
Handles.DrawBezier (startAnchor.Anchor.position, endAnchor.Anchor.position, startAnchor.OutTangent.position, endAnchor.InTangent.position, spline.color, null, 2);
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: bf584abde32dd4d28abdf7112e4cd744
timeCreated: 1483123495
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 107312
packageName: Surge
packageVersion: 1.0.48
assetPath: Assets/Pixelplacement/Surge/Spline/Editor/SplineEditor.cs
uploadId: 467433

View File

@@ -0,0 +1,38 @@
/// <summary>
/// SURGE FRAMEWORK
/// Author: Bob Berkebile
/// Email: bobb@pixelplacement.com
///
/// Forces pivot mode to center so an anchor's pivot is always correct while adjusting a spline.
///
/// </summary>
using UnityEditor;
using UnityEngine;
namespace Pixelplacement
{
[CustomEditor(typeof(SplineTangent))]
public class SplineTangentEditor : UnityEditor.Editor
{
//Scene GUI:
void OnSceneGUI ()
{
//ensure pivot is used so anchor selection has a proper transform origin:
if (Tools.pivotMode == PivotMode.Center)
{
Tools.pivotMode = PivotMode.Pivot;
}
}
//Gizmos:
[DrawGizmo(GizmoType.Selected)]
static void RenderCustomGizmo(Transform objectTransform, GizmoType gizmoType)
{
if (objectTransform.parent != null && objectTransform.parent.parent != null)
{
SplineEditor.RenderCustomGizmo(objectTransform.parent.parent, gizmoType);
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: def6dcf256e22a049928f540963d59f0
timeCreated: 1532464219
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 107312
packageName: Surge
packageVersion: 1.0.48
assetPath: Assets/Pixelplacement/Surge/Spline/Editor/SplineTangentEditor.cs
uploadId: 467433

View File

@@ -0,0 +1,82 @@
/// <summary>
/// SURGE FRAMEWORK
/// Author: Bob Berkebile
/// Email: bobb@pixelplacement.com
///
/// Custom inspector for the State class.
///
/// </summary>
using UnityEngine;
using System.Collections;
using UnityEditor;
namespace Pixelplacement
{
[CustomEditor (typeof (State), true)]
public class StateEditor : UnityEditor.Editor
{
//Private Variables:
State _target;
//Init:
void OnEnable()
{
_target = target as State;
}
//Inspector GUI:
public override void OnInspectorGUI()
{
DrawDefaultInspector ();
if (!Application.isPlaying)
{
GUILayout.BeginHorizontal();
DrawSoloButton();
DrawHideAllButton();
GUILayout.EndHorizontal();
}
else
{
DrawChangeStateButton();
}
}
//GUI Draw Methods:
void DrawChangeStateButton ()
{
GUI.color = Color.green;
if (GUILayout.Button("Change State"))
{
_target.ChangeState(_target.gameObject);
}
}
void DrawHideAllButton ()
{
GUI.color = Color.red;
if (GUILayout.Button ("Hide All"))
{
Undo.RegisterCompleteObjectUndo (_target.transform.parent.transform, "Hide All");
foreach (Transform item in _target.transform.parent.transform)
{
item.gameObject.SetActive (false);
}
}
}
void DrawSoloButton ()
{
GUI.color = Color.green;
if (GUILayout.Button ("Solo"))
{
foreach (Transform item in _target.transform.parent.transform)
{
if (item != _target.transform) item.gameObject.SetActive (false);
Undo.RegisterCompleteObjectUndo (_target, "Solo");
_target.gameObject.SetActive (true);
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 2c7a5df70e8f545d3b4898af06994a20
timeCreated: 1444835269
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 107312
packageName: Surge
packageVersion: 1.0.48
assetPath: Assets/Pixelplacement/Surge/StateMachine/Editor/StateEditor.cs
uploadId: 467433

View File

@@ -0,0 +1,136 @@
/// <summary>
/// SURGE FRAMEWORK
/// Author: Bob Berkebile
/// Email: bobb@pixelplacement.com
///
/// Custom inspector for the StateMachine class.
///
/// </summary>
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
namespace Pixelplacement
{
[CustomEditor (typeof (StateMachine), true)]
public class StateMachineEditor : UnityEditor.Editor
{
//Private Variables:
StateMachine _target;
//Init:
void OnEnable()
{
_target = target as StateMachine;
}
//Inspector GUI:
public override void OnInspectorGUI()
{
//if no states are found:
if (_target.transform.childCount == 0)
{
DrawNotification("Add child Gameobjects for this State Machine to control.", Color.yellow);
return;
}
//change buttons:
if (EditorApplication.isPlaying)
{
DrawStateChangeButtons();
}
serializedObject.Update();
DrawPropertiesExcluding(serializedObject, new string[] {
"currentState",
"_unityEventsFolded",
"defaultState",
"verbose",
"allowReentry",
"returnToDefaultOnDisable",
"Unity Events",
"OnStateExited",
"OnStateEntered",
"OnFirstStateEntered",
"OnFirstStateExited",
"OnLastStateEntered",
"OnLastStateExited"
});
EditorGUILayout.PropertyField(serializedObject.FindProperty("defaultState"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("verbose"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("allowReentry"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("returnToDefaultOnDisable"));
//fold events:
_target._unityEventsFolded = EditorGUILayout.Foldout(_target._unityEventsFolded, "Unity Events", true);
if (_target._unityEventsFolded)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("OnStateExited"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("OnStateEntered"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("OnFirstStateEntered"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("OnFirstStateExited"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("OnLastStateEntered"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("OnLastStateExited"));
}
serializedObject.ApplyModifiedProperties();
if (!EditorApplication.isPlaying)
{
DrawHideAllButton();
}
}
//GUI Draw Methods:
void DrawStateChangeButtons()
{
if (_target.transform.childCount == 0) return;
Color currentColor = GUI.color;
for (int i = 0; i < _target.transform.childCount; i++)
{
GameObject current = _target.transform.GetChild(i).gameObject;
if (_target.currentState != null && current == _target.currentState)
{
GUI.color = Color.green;
}
else
{
GUI.color = Color.white;
}
if (GUILayout.Button(current.name)) _target.ChangeState(current);
}
GUI.color = currentColor;
if (GUILayout.Button("Exit")) _target.Exit();
}
void DrawHideAllButton()
{
GUI.color = Color.red;
GUILayout.BeginHorizontal();
if (GUILayout.Button("Hide All"))
{
Undo.RegisterCompleteObjectUndo(_target.transform, "Hide All");
foreach (Transform item in _target.transform)
{
item.gameObject.SetActive(false);
}
}
GUILayout.EndHorizontal();
GUI.color = Color.white;
}
void DrawNotification(string message, Color color)
{
Color currentColor = GUI.color;
GUI.color = color;
EditorGUILayout.HelpBox(message, MessageType.Warning);
GUI.color = currentColor;
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 422f5854a358c4431b43cb2db1db4a50
timeCreated: 1444835081
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 107312
packageName: Surge
packageVersion: 1.0.48
assetPath: Assets/Pixelplacement/Surge/StateMachine/Editor/StateMachineEditor.cs
uploadId: 467433