private static void CreateAllConditionsAsset() { // If there's already an AllConditions asset, do nothing. if (AllConditions.Instance) { return; } // Create an instance of the AllConditions object and make an asset for it. AllConditions instance = CreateInstance <AllConditions> (); AssetDatabase.CreateAsset(instance, CREATION_PATH); // Set this as the singleton instance. AllConditions.Instance = instance; // Create a new empty array of Conditions. instance.Conditions = new Condition[0]; }
public ReactionCollection ReactionCollection; // Reference to the ReactionCollection that will React should all the Conditions be met. // This is called by the Interactable one at a time for each of its ConditionCollections until one returns true. public bool CheckAndReact() { // Go through all Conditions... for (int i = 0; i < RequiredConditions.Length; i++) { // ... and check them against the AllConditions version of the Condition. // If they don't have the same satisfied flag, return false. if (!AllConditions.CheckCondition(RequiredConditions[i])) { return(false); } } // If there is an ReactionCollection assigned, call its React function. if (ReactionCollection) { ReactionCollection.React(); } // A Reaction happened so return true. return(true); }
private const float BUTTON_WIDTH = 30f; // Width in pixels of the button to create Conditions. private void OnEnable() { // Cache the reference to the target. _allConditions = (AllConditions)target; // If there aren't any Conditions on the target, create an empty array of Conditions. if (_allConditions.Conditions == null) { _allConditions.Conditions = new Condition[0]; } // If there aren't any editors, create them. if (_conditionEditors == null) { CreateEditors(); } _conditionsProperty = serializedObject.FindProperty("Conditions"); _reordableList = new ReorderableList(serializedObject, _conditionsProperty, true, false, false, false); _reordableList.drawElementCallback = DrawListItems; _reordableList.drawHeaderCallback = DrawHeader; }