Added display of WIP CallbackEvents on the inspector
This commit is contained in:
parent
c6d29a1038
commit
f6cbb18143
|
@ -57,6 +57,10 @@ namespace SHADE
|
||||||
|
|
||||||
#region Constructors ------------------------------------------------------------
|
#region Constructors ------------------------------------------------------------
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Constructs an empty Callback action.
|
||||||
|
/// </summary>
|
||||||
|
public CallbackAction() {}
|
||||||
|
/// <summary>
|
||||||
/// Constructs a CallbackAction that represents a call to the specified method on the
|
/// Constructs a CallbackAction that represents a call to the specified method on the
|
||||||
/// specified target.
|
/// specified target.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -130,6 +134,10 @@ namespace SHADE
|
||||||
|
|
||||||
#region Constructors ------------------------------------------------------------
|
#region Constructors ------------------------------------------------------------
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Constructs an empty Callback action.
|
||||||
|
/// </summary>
|
||||||
|
public CallbackAction() {}
|
||||||
|
/// <summary>
|
||||||
/// Constructs a CallbackAction that represents a call to the specified method on the
|
/// Constructs a CallbackAction that represents a call to the specified method on the
|
||||||
/// specified target.
|
/// specified target.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -204,6 +212,10 @@ namespace SHADE
|
||||||
|
|
||||||
#region Constructors ------------------------------------------------------------
|
#region Constructors ------------------------------------------------------------
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Constructs an empty Callback action.
|
||||||
|
/// </summary>
|
||||||
|
public CallbackAction() {}
|
||||||
|
/// <summary>
|
||||||
/// Constructs a CallbackAction that represents a call to the specified method on the
|
/// Constructs a CallbackAction that represents a call to the specified method on the
|
||||||
/// specified target.
|
/// specified target.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -279,6 +291,10 @@ namespace SHADE
|
||||||
|
|
||||||
#region Constructors ------------------------------------------------------------
|
#region Constructors ------------------------------------------------------------
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Constructs an empty Callback action.
|
||||||
|
/// </summary>
|
||||||
|
public CallbackAction() {}
|
||||||
|
/// <summary>
|
||||||
/// Constructs a CallbackAction that represents a call to the specified method on the
|
/// Constructs a CallbackAction that represents a call to the specified method on the
|
||||||
/// specified target.
|
/// specified target.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -355,6 +371,10 @@ namespace SHADE
|
||||||
|
|
||||||
#region Constructors ------------------------------------------------------------
|
#region Constructors ------------------------------------------------------------
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Constructs an empty Callback action.
|
||||||
|
/// </summary>
|
||||||
|
public CallbackAction() {}
|
||||||
|
/// <summary>
|
||||||
/// Constructs a CallbackAction that represents a call to the specified method on the
|
/// Constructs a CallbackAction that represents a call to the specified method on the
|
||||||
/// specified target.
|
/// specified target.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -432,6 +452,10 @@ namespace SHADE
|
||||||
|
|
||||||
#region Constructors ------------------------------------------------------------
|
#region Constructors ------------------------------------------------------------
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Constructs an empty Callback action.
|
||||||
|
/// </summary>
|
||||||
|
public CallbackAction() {}
|
||||||
|
/// <summary>
|
||||||
/// Constructs a CallbackAction that represents a call to the specified method on the
|
/// Constructs a CallbackAction that represents a call to the specified method on the
|
||||||
/// specified target.
|
/// specified target.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -510,6 +534,10 @@ namespace SHADE
|
||||||
|
|
||||||
#region Constructors ------------------------------------------------------------
|
#region Constructors ------------------------------------------------------------
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Constructs an empty Callback action.
|
||||||
|
/// </summary>
|
||||||
|
public CallbackAction() {}
|
||||||
|
/// <summary>
|
||||||
/// Constructs a CallbackAction that represents a call to the specified method on the
|
/// Constructs a CallbackAction that represents a call to the specified method on the
|
||||||
/// specified target.
|
/// specified target.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -589,6 +617,10 @@ namespace SHADE
|
||||||
|
|
||||||
#region Constructors ------------------------------------------------------------
|
#region Constructors ------------------------------------------------------------
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Constructs an empty Callback action.
|
||||||
|
/// </summary>
|
||||||
|
public CallbackAction() {}
|
||||||
|
/// <summary>
|
||||||
/// Constructs a CallbackAction that represents a call to the specified method on the
|
/// Constructs a CallbackAction that represents a call to the specified method on the
|
||||||
/// specified target.
|
/// specified target.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -669,6 +701,10 @@ namespace SHADE
|
||||||
|
|
||||||
#region Constructors ------------------------------------------------------------
|
#region Constructors ------------------------------------------------------------
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Constructs an empty Callback action.
|
||||||
|
/// </summary>
|
||||||
|
public CallbackAction() {}
|
||||||
|
/// <summary>
|
||||||
/// Constructs a CallbackAction that represents a call to the specified method on the
|
/// Constructs a CallbackAction that represents a call to the specified method on the
|
||||||
/// specified target.
|
/// specified target.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -750,6 +786,10 @@ namespace SHADE
|
||||||
|
|
||||||
#region Constructors ------------------------------------------------------------
|
#region Constructors ------------------------------------------------------------
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Constructs an empty Callback action.
|
||||||
|
/// </summary>
|
||||||
|
public CallbackAction() {}
|
||||||
|
/// <summary>
|
||||||
/// Constructs a CallbackAction that represents a call to the specified method on the
|
/// Constructs a CallbackAction that represents a call to the specified method on the
|
||||||
/// specified target.
|
/// specified target.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -74,6 +74,10 @@ namespace SHADE
|
||||||
|
|
||||||
#region Constructors ------------------------------------------------------------
|
#region Constructors ------------------------------------------------------------
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Constructs an empty Callback action.
|
||||||
|
/// </summary>
|
||||||
|
public CallbackAction() {}
|
||||||
|
/// <summary>
|
||||||
/// Constructs a CallbackAction that represents a call to the specified method on the
|
/// Constructs a CallbackAction that represents a call to the specified method on the
|
||||||
/// specified target.
|
/// specified target.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -22,6 +22,10 @@ namespace SHADE
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ICallbackEvent
|
public interface ICallbackEvent
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Registers an empty ICallbackAction.
|
||||||
|
/// </summary>
|
||||||
|
void RegisterAction();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers an ICallbackAction with the event such that it will be called in
|
/// Registers an ICallbackAction with the event such that it will be called in
|
||||||
/// future
|
/// future
|
||||||
|
@ -59,6 +63,11 @@ namespace SHADE
|
||||||
|
|
||||||
#region Usage Functions ---------------------------------------------------------
|
#region Usage Functions ---------------------------------------------------------
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
public void RegisterAction()
|
||||||
|
{
|
||||||
|
actions.Add(new CallbackAction<T1>());
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
public void RegisterAction(ICallbackAction action)
|
public void RegisterAction(ICallbackAction action)
|
||||||
{
|
{
|
||||||
// Check if valid action
|
// Check if valid action
|
||||||
|
@ -140,6 +149,11 @@ namespace SHADE
|
||||||
|
|
||||||
#region Usage Functions ---------------------------------------------------------
|
#region Usage Functions ---------------------------------------------------------
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
public void RegisterAction()
|
||||||
|
{
|
||||||
|
actions.Add(new CallbackAction<T1, T2>());
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
public void RegisterAction(ICallbackAction action)
|
public void RegisterAction(ICallbackAction action)
|
||||||
{
|
{
|
||||||
// Check if valid action
|
// Check if valid action
|
||||||
|
@ -221,6 +235,11 @@ namespace SHADE
|
||||||
|
|
||||||
#region Usage Functions ---------------------------------------------------------
|
#region Usage Functions ---------------------------------------------------------
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
public void RegisterAction()
|
||||||
|
{
|
||||||
|
actions.Add(new CallbackAction<T1, T2, T3>());
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
public void RegisterAction(ICallbackAction action)
|
public void RegisterAction(ICallbackAction action)
|
||||||
{
|
{
|
||||||
// Check if valid action
|
// Check if valid action
|
||||||
|
@ -302,6 +321,11 @@ namespace SHADE
|
||||||
|
|
||||||
#region Usage Functions ---------------------------------------------------------
|
#region Usage Functions ---------------------------------------------------------
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
public void RegisterAction()
|
||||||
|
{
|
||||||
|
actions.Add(new CallbackAction<T1, T2, T3, T4>());
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
public void RegisterAction(ICallbackAction action)
|
public void RegisterAction(ICallbackAction action)
|
||||||
{
|
{
|
||||||
// Check if valid action
|
// Check if valid action
|
||||||
|
@ -383,6 +407,11 @@ namespace SHADE
|
||||||
|
|
||||||
#region Usage Functions ---------------------------------------------------------
|
#region Usage Functions ---------------------------------------------------------
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
public void RegisterAction()
|
||||||
|
{
|
||||||
|
actions.Add(new CallbackAction<T1, T2, T3, T4, T5>());
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
public void RegisterAction(ICallbackAction action)
|
public void RegisterAction(ICallbackAction action)
|
||||||
{
|
{
|
||||||
// Check if valid action
|
// Check if valid action
|
||||||
|
@ -464,6 +493,11 @@ namespace SHADE
|
||||||
|
|
||||||
#region Usage Functions ---------------------------------------------------------
|
#region Usage Functions ---------------------------------------------------------
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
public void RegisterAction()
|
||||||
|
{
|
||||||
|
actions.Add(new CallbackAction<T1, T2, T3, T4, T5, T6>());
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
public void RegisterAction(ICallbackAction action)
|
public void RegisterAction(ICallbackAction action)
|
||||||
{
|
{
|
||||||
// Check if valid action
|
// Check if valid action
|
||||||
|
@ -545,6 +579,11 @@ namespace SHADE
|
||||||
|
|
||||||
#region Usage Functions ---------------------------------------------------------
|
#region Usage Functions ---------------------------------------------------------
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
public void RegisterAction()
|
||||||
|
{
|
||||||
|
actions.Add(new CallbackAction<T1, T2, T3, T4, T5, T6, T7>());
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
public void RegisterAction(ICallbackAction action)
|
public void RegisterAction(ICallbackAction action)
|
||||||
{
|
{
|
||||||
// Check if valid action
|
// Check if valid action
|
||||||
|
@ -626,6 +665,11 @@ namespace SHADE
|
||||||
|
|
||||||
#region Usage Functions ---------------------------------------------------------
|
#region Usage Functions ---------------------------------------------------------
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
public void RegisterAction()
|
||||||
|
{
|
||||||
|
actions.Add(new CallbackAction<T1, T2, T3, T4, T5, T6, T7, T8>());
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
public void RegisterAction(ICallbackAction action)
|
public void RegisterAction(ICallbackAction action)
|
||||||
{
|
{
|
||||||
// Check if valid action
|
// Check if valid action
|
||||||
|
@ -707,6 +751,11 @@ namespace SHADE
|
||||||
|
|
||||||
#region Usage Functions ---------------------------------------------------------
|
#region Usage Functions ---------------------------------------------------------
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
public void RegisterAction()
|
||||||
|
{
|
||||||
|
actions.Add(new CallbackAction<T1, T2, T3, T4, T5, T6, T7, T8, T9>());
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
public void RegisterAction(ICallbackAction action)
|
public void RegisterAction(ICallbackAction action)
|
||||||
{
|
{
|
||||||
// Check if valid action
|
// Check if valid action
|
||||||
|
@ -788,6 +837,11 @@ namespace SHADE
|
||||||
|
|
||||||
#region Usage Functions ---------------------------------------------------------
|
#region Usage Functions ---------------------------------------------------------
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
public void RegisterAction()
|
||||||
|
{
|
||||||
|
actions.Add(new CallbackAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>());
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
public void RegisterAction(ICallbackAction action)
|
public void RegisterAction(ICallbackAction action)
|
||||||
{
|
{
|
||||||
// Check if valid action
|
// Check if valid action
|
||||||
|
|
|
@ -38,6 +38,10 @@ namespace SHADE
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ICallbackEvent
|
public interface ICallbackEvent
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Registers an empty ICallbackAction.
|
||||||
|
/// </summary>
|
||||||
|
void RegisterAction();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers an ICallbackAction with the event such that it will be called in
|
/// Registers an ICallbackAction with the event such that it will be called in
|
||||||
/// future
|
/// future
|
||||||
|
@ -76,6 +80,11 @@ namespace SHADE
|
||||||
|
|
||||||
#region Usage Functions ---------------------------------------------------------
|
#region Usage Functions ---------------------------------------------------------
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
public void RegisterAction()
|
||||||
|
{
|
||||||
|
actions.Add(new CallbackAction<<# for (int t = 1; t < i + 1; ++t) { #>T<#=t#><# if (t != i) { #>, <# } #><# } #>>());
|
||||||
|
}
|
||||||
|
/// <inheritdoc/>
|
||||||
public void RegisterAction(ICallbackAction action)
|
public void RegisterAction(ICallbackAction action)
|
||||||
{
|
{
|
||||||
// Check if valid action
|
// Check if valid action
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace SHADE
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
bool SHEditorUI::CollapsingHeader(const std::string& title)
|
bool SHEditorUI::CollapsingHeader(const std::string& title)
|
||||||
{
|
{
|
||||||
return ImGui::CollapsingHeader(title.c_str());
|
return ImGui::CollapsingHeader(title.c_str(), ImGuiTreeNodeFlags_DefaultOpen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHEditorUI::SameLine()
|
void SHEditorUI::SameLine()
|
||||||
|
|
|
@ -255,6 +255,10 @@ namespace SHADE
|
||||||
<HintPath Condition=\"Exists('..\\bin\\Debug\\SHADE_Managed.dll')\">..\\bin\\Debug\\SHADE_Managed.dll</HintPath>\n\
|
<HintPath Condition=\"Exists('..\\bin\\Debug\\SHADE_Managed.dll')\">..\\bin\\Debug\\SHADE_Managed.dll</HintPath>\n\
|
||||||
<HintPath Condition=\"Exists('..\\bin\\Release\\SHADE_Managed.dll')\">..\\bin\\Release\\SHADE_Managed.dll</HintPath>\n\
|
<HintPath Condition=\"Exists('..\\bin\\Release\\SHADE_Managed.dll')\">..\\bin\\Release\\SHADE_Managed.dll</HintPath>\n\
|
||||||
</Reference>\n\
|
</Reference>\n\
|
||||||
|
<Reference Include=\"SHADE_CSharp\">\n\
|
||||||
|
<HintPath Condition=\"Exists('..\\bin\\Debug\\SHADE_Managed.dll')\">..\\bin\\Debug\\SHADE_CSharp.dll</HintPath>\n\
|
||||||
|
<HintPath Condition=\"Exists('..\\bin\\Release\\SHADE_Managed.dll')\">..\\bin\\Release\\SHADE_CSharp.dll</HintPath>\n\
|
||||||
|
</Reference>\n\
|
||||||
</ItemGroup>\n\
|
</ItemGroup>\n\
|
||||||
</Project>";
|
</Project>";
|
||||||
|
|
||||||
|
|
|
@ -286,8 +286,49 @@ namespace SHADE
|
||||||
registerUndoAction(object, field, Convert::ToCLI(val), Convert::ToCLI(oldVal));
|
registerUndoAction(object, field, Convert::ToCLI(val), Convert::ToCLI(oldVal));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (field->FieldType->BaseType == ICallbackEvent::typeid)
|
else
|
||||||
{
|
{
|
||||||
|
array<System::Type^>^ interfaces = field->FieldType->GetInterfaces();
|
||||||
|
if (interfaces->Length > 0 && interfaces[0] == ICallbackEvent::typeid)
|
||||||
|
{
|
||||||
|
array<System::Type^>^ typeArgs = field->FieldType->GenericTypeArguments;
|
||||||
|
System::String^ title = field->Name + " : CallbackEvent<";
|
||||||
|
for (int i = 0; i < typeArgs->Length; ++i)
|
||||||
|
{
|
||||||
|
title += typeArgs[i]->Name;
|
||||||
|
if (i < typeArgs->Length - 1)
|
||||||
|
title += ", ";
|
||||||
|
}
|
||||||
|
title += ">";
|
||||||
|
if (SHEditorUI::CollapsingHeader(Convert::ToNative(title)))
|
||||||
|
{
|
||||||
|
ICallbackEvent^ callbackEvent = safe_cast<ICallbackEvent^>(field->GetValue(object));
|
||||||
|
if (callbackEvent == nullptr)
|
||||||
|
{
|
||||||
|
// Construct one since it was not constructed before
|
||||||
|
callbackEvent = safe_cast<ICallbackEvent^>(System::Activator::CreateInstance(field->FieldType));
|
||||||
|
}
|
||||||
|
for each (ICallbackAction ^ action in callbackEvent->Actions)
|
||||||
|
{
|
||||||
|
if (action->IsRuntimeAction)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (action->TargetObject == nullptr)
|
||||||
|
SHEditorUI::Text("Target Object");
|
||||||
|
else
|
||||||
|
SHEditorUI::Text(Convert::ToNative(action->TargetObject->GetType()->Name));
|
||||||
|
SHEditorUI::SameLine();
|
||||||
|
|
||||||
|
if (action->TargetMethodName == nullptr)
|
||||||
|
SHEditorUI::Text("Target Method Name");
|
||||||
|
else
|
||||||
|
SHEditorUI::Text(Convert::ToNative(action->TargetMethodName));
|
||||||
|
}
|
||||||
|
if (SHEditorUI::Button("Add Action"))
|
||||||
|
{
|
||||||
|
callbackEvent->RegisterAction();
|
||||||
|
}
|
||||||
|
}
|
||||||
// Needs to present
|
// Needs to present
|
||||||
// - name and param list
|
// - name and param list
|
||||||
// Needs to present for each callbackaction
|
// Needs to present for each callbackaction
|
||||||
|
@ -298,6 +339,7 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the field has a specific attribute
|
// Check if the field has a specific attribute
|
||||||
TooltipAttribute^ toolTip = hasAttribute<TooltipAttribute^>(field);
|
TooltipAttribute^ toolTip = hasAttribute<TooltipAttribute^>(field);
|
||||||
|
|
|
@ -7,6 +7,10 @@ public class RaccoonSpin : Script
|
||||||
[Tooltip("Speed of the rotation in radians per second.")]
|
[Tooltip("Speed of the rotation in radians per second.")]
|
||||||
private double RotateSpeed = 1.0;
|
private double RotateSpeed = 1.0;
|
||||||
private double rotation = 0.0;
|
private double rotation = 0.0;
|
||||||
|
[SerializeField]
|
||||||
|
private CallbackEvent<int> testEvent;
|
||||||
|
[SerializeField]
|
||||||
|
private CallbackEvent<int, double, Vector3> testEvent3 = new CallbackEvent<int, double, Vector3>();
|
||||||
private Transform Transform;
|
private Transform Transform;
|
||||||
public RaccoonSpin(GameObject gameObj) : base(gameObj) { }
|
public RaccoonSpin(GameObject gameObj) : base(gameObj) { }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue