-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
942 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@Reality.Stop() Here goes for the type of events: | ||
|
||
- Global Event: Is triggered to the event bus (EventBus.Trigger) on all handlers. | ||
- Game Object Event: Is triggered through the event bus (EventBus.Trigger), but only on handlers where the EventHook's target matches. (Basically: "local" events) | ||
- Manual Event: Will have to get triggered through TriggerEventHandler. Usually used for special cases & edit mode stuff like gizmos. | ||
- Event (abstract): None of this is very well defined, so you can derive it to implement really customized events. | ||
|
||
It's important to note that the event bus does not exist during edit mode, so if you need to run graph code then, you'll probably need Manual Event. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Ludiq; | ||
|
||
namespace Bolt.Community.Addons.Fundamentals.Editor.Controls | ||
{ | ||
[Inspectable] | ||
public class UnitButton | ||
{ | ||
public System.Action action; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace Bolt.Community.Addons.Fundamentals.Editor.Controls | ||
{ | ||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = true)] | ||
public class UnitButtonAttribute : Attribute | ||
{ | ||
public string action; | ||
|
||
public UnitButtonAttribute(string action) | ||
{ | ||
this.action = action; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using Ludiq; | ||
using System.Reflection; | ||
using System; | ||
|
||
namespace Bolt.Community.Addons.Fundamentals.Editor.Controls | ||
{ | ||
[Inspector(typeof(UnitButton) )] | ||
public class UnitButtonInspector : Inspector | ||
{ | ||
public UnitButtonInspector(Metadata metadata) : base(metadata) { } | ||
|
||
protected override float GetHeight(float width, GUIContent label) | ||
{ | ||
return 16; | ||
} | ||
|
||
protected override void OnGUI(Rect position, GUIContent label) | ||
{ | ||
BeginBlock(metadata, position, GUIContent.none); | ||
|
||
var buttonPosition = new Rect( | ||
position.x, | ||
position.y, | ||
position.width + 8, | ||
16 | ||
); | ||
|
||
if (GUI.Button(buttonPosition, "Trigger", new GUIStyle(UnityEditor.EditorStyles.miniButton))) | ||
{ | ||
var attribute = metadata.GetAttribute<UnitButtonAttribute>(true); | ||
|
||
if (attribute != null) | ||
{ | ||
var method = attribute.action; | ||
|
||
object typeObject = metadata.parent.value; | ||
typeObject.GetType().GetMethod(method).Invoke(typeObject, new object[0] { }); | ||
|
||
} | ||
} | ||
|
||
if (EndBlock(metadata)) | ||
{ | ||
metadata.RecordUndo(); | ||
} | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/Fundamentals/Editor/Controls/UnitButtonPropertyDrawer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEditor; | ||
|
||
namespace Bolt.Community.Addons.Fundamentals.Editor.Controls | ||
{ | ||
[CustomPropertyDrawer(typeof(UnitButton))] | ||
public class UnitButtonPropertyDrawer : PropertyDrawer | ||
{ | ||
|
||
} | ||
} |
Oops, something went wrong.