|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using UnityEngine; |
|
|
|
|
using UnityEngine.Serialization; |
|
|
|
|
using System.Collections; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
|
@ -8,19 +9,23 @@ namespace Fungus
|
|
|
|
|
"Set Active", |
|
|
|
|
"Sets a game object in the scene to be active / inactive.")] |
|
|
|
|
[AddComponentMenu("")] |
|
|
|
|
public class SetActive : Command |
|
|
|
|
{ |
|
|
|
|
public class SetActive : Command, ISerializationCallbackReceiver |
|
|
|
|
{ |
|
|
|
|
#region Obsolete Properties |
|
|
|
|
[HideInInspector] [FormerlySerializedAs("targetGameObject")] public GameObject targetGameObjectOLD; |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
[Tooltip("Reference to game object to enable / disable")] |
|
|
|
|
public GameObject targetGameObject; |
|
|
|
|
public GameObjectData _targetGameObject; |
|
|
|
|
|
|
|
|
|
[Tooltip("Set to true to enable the game object")] |
|
|
|
|
public BooleanData activeState; |
|
|
|
|
|
|
|
|
|
public override void OnEnter() |
|
|
|
|
{ |
|
|
|
|
if (targetGameObject != null) |
|
|
|
|
if (_targetGameObject.Value != null) |
|
|
|
|
{ |
|
|
|
|
targetGameObject.SetActive(activeState.Value); |
|
|
|
|
_targetGameObject.Value.SetActive(activeState.Value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Continue(); |
|
|
|
@ -28,18 +33,34 @@ namespace Fungus
|
|
|
|
|
|
|
|
|
|
public override string GetSummary() |
|
|
|
|
{ |
|
|
|
|
if (targetGameObject == null) |
|
|
|
|
if (_targetGameObject.Value == null) |
|
|
|
|
{ |
|
|
|
|
return "Error: No game object selected"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return targetGameObject.name + " = " + activeState.GetDescription(); |
|
|
|
|
return _targetGameObject.Value.name + " = " + activeState.GetDescription(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override Color GetButtonColor() |
|
|
|
|
{ |
|
|
|
|
return new Color32(235, 191, 217, 255); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// |
|
|
|
|
// ISerializationCallbackReceiver implementation |
|
|
|
|
// |
|
|
|
|
|
|
|
|
|
public virtual void OnBeforeSerialize() |
|
|
|
|
{} |
|
|
|
|
|
|
|
|
|
public virtual void OnAfterDeserialize() |
|
|
|
|
{ |
|
|
|
|
if (targetGameObjectOLD != null) |
|
|
|
|
{ |
|
|
|
|
_targetGameObject.Value = targetGameObjectOLD; |
|
|
|
|
targetGameObjectOLD = null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |