jamirokwai
Tue, 15 Jan 2019 20:08:26 GMT
I coded a command "GetActive", which will save TRUE, if the GameObject is currently active. Afterwards, you check IF Variable == TRUE. That's ok for one interaction, but for 10 objects, the block will get cluttered very fast.
My solution would be to extend the IF-Command, but I can't get it to work. Any ideas on how to convert GetActive.cs to a VariableCondition like the IF-command? I'd like to have this working like IF ELSE END IF. See the image at the end of the post.
Here is my current approach of GetActive.cs
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Serialization;
namespace Fungus
{
[CommandInfo("GameObject",
"Get Active",
"Get the state of the GameObject (active == true or false).")]
[AddComponentMenu("")]
public class GetActive : Command
{
[Tooltip("GameObject to get activeness from.")]
[SerializeField] protected GameObject targetGameObject;
[Tooltip("Boolean variable to store the information in")]
[VariableProperty(typeof(BooleanVariable))]
[SerializeField] protected BooleanVariable boolVariable;
#region Public members
public override void OnEnter()
{
if (targetGameObject == null)
{
Continue();
return;
}
if (targetGameObject != null) {
boolVariable.Value = targetGameObject.activeInHierarchy;
}
Continue();
}
public override string GetSummary()
{
if (targetGameObject == null) { return "Error: No GameObject selected"; }
if (boolVariable == null) { return "Error: No variable selected"; }
return targetGameObject.name + " : " + boolVariable.name;
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
#endregion
}
} [Menumove](//muut.com/u/fungus/s3/:fungus:1vQW:menumove.png.jpg)