Browse Source

Added SendEvent command (commented out due to Unity bug)

master
chrisgregan 10 years ago
parent
commit
597aec7d94
  1. 63
      Assets/Fungus/FungusScript/Commands/SendEvent.cs
  2. 8
      Assets/Fungus/FungusScript/Commands/SendEvent.cs.meta
  3. 38
      Assets/Fungus/FungusScript/Editor/SendEventEditor.cs
  4. 8
      Assets/Fungus/FungusScript/Editor/SendEventEditor.cs.meta

63
Assets/Fungus/FungusScript/Commands/SendEvent.cs

@ -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);
}
}
*/
}

8
Assets/Fungus/FungusScript/Commands/SendEvent.cs.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 753b649228ad54a909f27b04023be7aa
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

38
Assets/Fungus/FungusScript/Editor/SendEventEditor.cs

@ -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();
}
}
*/
}

8
Assets/Fungus/FungusScript/Editor/SendEventEditor.cs.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bac7aca93b77a4b78a6357a2c13ad26d
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
Loading…
Cancel
Save