using UnityEngine; using System.Collections; using System.Collections.Generic; namespace Fungus { [CommandInfo("Sprite", "Set Collider", "Sets all collider (2d or 3d) components on the target objects to be active / inactive")] [AddComponentMenu("")] public class SetCollider : Command { [Tooltip("A list of gameobjects containing collider components to be set active / inactive")] public List targetObjects = new List(); [Tooltip("Set to true to enable the collider components")] public BooleanData activeState; public override void OnEnter() { foreach (GameObject go in targetObjects) { if (go != null) { // 3D objects foreach (Collider c in go.GetComponentsInChildren()) { c.enabled = activeState.Value; } // 2D objects foreach (Collider2D c in go.GetComponentsInChildren()) { c.enabled = activeState.Value; } } } Continue(); } public override string GetSummary() { if (activeState.Value) { return "Enable " + targetObjects.Count + " collider objects."; } else { return "Disable " + targetObjects.Count + " collider objects."; } } public override Color GetButtonColor() { return new Color32(235, 191, 217, 255); } } }