chrisgregan
10 years ago
4 changed files with 117 additions and 0 deletions
@ -0,0 +1,63 @@
|
||||
using UnityEngine; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine.Events; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/* |
||||
[CommandInfo("Scripting", |
||||
"Send Event", |
||||
"Send an event to a gameobject in the scene. Use this to call any public method or set public properties on any game object.")] |
||||
public class SendEvent : Command |
||||
{ |
||||
public UnityEvent targetEvent; |
||||
|
||||
public bool stopCurrentScript = false; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
if (targetEvent != null) |
||||
{ |
||||
if (stopCurrentScript) |
||||
{ |
||||
Stop(); |
||||
} |
||||
|
||||
targetEvent.Invoke(); |
||||
|
||||
if (!stopCurrentScript) |
||||
{ |
||||
Continue(); |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
Continue(); |
||||
} |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
if (targetEvent == null || |
||||
targetEvent.GetPersistentEventCount() == 0) |
||||
{ |
||||
return "<Continue>"; |
||||
} |
||||
|
||||
UnityEngine.Object obj = targetEvent.GetPersistentTarget(0); |
||||
if (obj == null) |
||||
{ |
||||
return "Error: No target object selected"; |
||||
} |
||||
|
||||
return obj.name; |
||||
} |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(235, 191, 217, 255); |
||||
} |
||||
} |
||||
*/ |
||||
} |
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 753b649228ad54a909f27b04023be7aa |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
@ -0,0 +1,38 @@
|
||||
using UnityEditor; |
||||
using UnityEngine; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/* |
||||
[CustomEditor (typeof(SendEvent))] |
||||
public class SendEventEditor : CommandEditor |
||||
{ |
||||
protected SerializedProperty targetEventProp; |
||||
protected SerializedProperty stopCurrentScriptProp; |
||||
|
||||
protected virtual void OnEnable() |
||||
{ |
||||
targetEventProp = serializedObject.FindProperty("targetEvent"); |
||||
stopCurrentScriptProp = serializedObject.FindProperty("stopCurrentScript"); |
||||
} |
||||
|
||||
public override void DrawCommandGUI() |
||||
{ |
||||
// For some reason the serializedObject has already been disposed by the time this method is called |
||||
// The workaround is to acquire a new serializedObject and find the targetEvent property every time. |
||||
// This could be a bug in the Unity 4.6 beta so try to aquire the property in OnEnable() again some time. |
||||
|
||||
serializedObject.Update(); |
||||
|
||||
serializedObject.Update(); |
||||
|
||||
EditorGUILayout.PropertyField(targetEventProp); |
||||
EditorGUILayout.PropertyField(stopCurrentScriptProp); |
||||
|
||||
serializedObject.ApplyModifiedProperties(); |
||||
} |
||||
} |
||||
*/ |
||||
} |
Loading…
Reference in new issue