Adventure Creator Wikia
Explore
Main Page
Discuss
All Pages
Community
Interactive Maps
Recent Blog Posts
Popular pages
Most visited articles
Motion Matching in Adventure Creator
Fix Blurry Pixel Art Style Fonts in Unity
General
Scrolling text and Scrolling text audio.
Cancel Interaction Menus
Adding image effects
Custom trigger (triggers one actionlist when entering and another when exiting)
Randomize speech audio (Random Syllables)
Use items on an AC Character
Running Animations when game is paused
Integrations
CNControls Integration (Virtual Joystick)
Rewired integration
Unity analytics Integration (AC Action)
FinalIK Interactions Integration (AC Action)
Rogo Lipsync (No audio) 01 - Play Action
Rogo Lipsync (No audio) 02 - Stop Action
Rogo Lipsync (No audio) 03 - Set Emotion Action
FANDOM
Fan Central
BETA
Games
Anime
Movies
TV
Video
Wikis
Explore Wikis
Community Central
Start a Wiki
Don't have an account?
Register
Sign In
FANDOM
Explore
Current Wiki
Start a Wiki
Don't have an account?
Register
Sign In
Sign In
Register
Adventure Creator Wikia
192
pages
Explore
Main Page
Discuss
All Pages
Community
Interactive Maps
Recent Blog Posts
Popular pages
Most visited articles
Motion Matching in Adventure Creator
Fix Blurry Pixel Art Style Fonts in Unity
General
Scrolling text and Scrolling text audio.
Cancel Interaction Menus
Adding image effects
Custom trigger (triggers one actionlist when entering and another when exiting)
Randomize speech audio (Random Syllables)
Use items on an AC Character
Running Animations when game is paused
Integrations
CNControls Integration (Virtual Joystick)
Rewired integration
Unity analytics Integration (AC Action)
FinalIK Interactions Integration (AC Action)
Rogo Lipsync (No audio) 01 - Play Action
Rogo Lipsync (No audio) 02 - Stop Action
Rogo Lipsync (No audio) 03 - Set Emotion Action
Editing
Custom Action - Variable: MultiBoolCheck
Back to page
Edit
Edit source
View history
Talk (0)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
This is a Custom Action that is used to check a unlimited number of global boolean variables if they meet given conditions. I use it to clean up my ActionLists if there are to many variable state checks in a row. To describe it as simple as possible: It can turn this [[File:MultiBoolCheck.png|thumb|832x832px]] into this: [[File:MultiBoolCheck2.png|thumb|830x830px]] Important to know: - It only works with global boolean variables - It does not support ActionList parameters It is based on the "Variable: Check" Action. Here's the code:<syntaxhighlight lang="csharp"> using UnityEngine; using System.Collections; using System.Collections.Generic; #if UNITY_EDITOR using UnityEditor; #endif namespace AC { [System.Serializable] public class MultiBool { public int variableID; public BoolValue boolValue = BoolValue.True; } public class ActionMultiBoolCheck : ActionCheck { public int NumberOfBools = 1; public int variableNumber; public List<MultiBool> multiBool=new List<MultiBool>(); public override ActionCategory Category { get { return ActionCategory.Variable; } } public override string Title { get { return "MultiBoolCheck"; } } public override string Description { get { return "Queries the value of one or more Global Bool Variables declared in the Variables Manager."; } } public override bool CheckCondition () { int Hits = 0; int Count=0; foreach (MultiBool _multiBool in multiBool) { if (_multiBool.variableID == -1) { ACDebug.LogWarning ("The 'Variable: MultiBoolCheck' Action halted the ActionList because it cannot find a given Global Variable (Index="+Count+")"); return false; } GVar var = GlobalVariables.GetVariable (_multiBool.variableID); if (var != null) { var.Download (); if (var.BooleanValue == true && _multiBool.boolValue == BoolValue.True) { Hits++; } else if (var.BooleanValue == false && _multiBool.boolValue == BoolValue.False) { Hits++; } } else { ACDebug.LogWarning ("The 'Variable: MultiBoolCheck' Action halted the ActionList because it cannot find the Global Variable with an ID of " + _multiBool.variableID); return false; } Count++; } if (Hits == NumberOfBools) { return true; } else { return false; } } #if UNITY_EDITOR override public void ShowGUI (List<ActionParameter> parameters) { int OldNumber = NumberOfBools; NumberOfBools = EditorGUILayout.IntField ("Number of checks:", NumberOfBools); if (NumberOfBools < 1) { NumberOfBools = 1; } // If "Number of checks" is altered then delete or create multiBool indexes accordingly int Dif = OldNumber - NumberOfBools; if (Dif > 0) { multiBool.RemoveRange(NumberOfBools,Dif); } else if (Dif < 0) { for (int Count=0; Count < -Dif; Count++) { multiBool.Add(new MultiBool()); } } EditorGUILayout.LabelField (" ", GUILayout.MaxWidth (60f)); VariablesManager variablesManager = AdvGame.GetReferences ().variablesManager; foreach (MultiBool _multiBool in multiBool) { _multiBool.variableID = ShowVarGUI (variablesManager.vars, _multiBool.variableID, true); _multiBool.boolValue = (BoolValue) EditorGUILayout.EnumPopup ("has to be:",_multiBool.boolValue); EditorGUILayout.LabelField (" ", GUILayout.MaxWidth (60f)); } } private int ShowVarSelectorGUI (List<GVar> vars, int ID) { variableNumber = -1; List<string> labelList = new List<string>(); foreach (GVar _var in vars) { if (_var.type == VariableType.Boolean) { labelList.Add (_var.label); } } variableNumber = GetVarNumber (vars, ID); if (variableNumber == -1) { ACDebug.LogWarning ("Previously chosen variable no longer exists!"); variableNumber = 0; ID = 0; } variableNumber = EditorGUILayout.Popup ("Variable:", variableNumber, labelList.ToArray()); ID = GetVarID(vars, variableNumber); return ID; } private int ShowVarGUI (List<GVar> vars, int ID, bool changeID) { if (vars.Count > 0) { if (changeID) { ID = ShowVarSelectorGUI (vars, ID); } variableNumber = Mathf.Min (variableNumber, vars.Count-1); } else { EditorGUILayout.HelpBox ("No variables exist!", MessageType.Info); ID = -1; variableNumber = -1; } return ID; } override public string SetLabel () { return " ("+NumberOfBools+" checks)"; } #endif private int GetVarNumber (List<GVar> vars, int ID) { int i = 0; foreach (GVar _var in vars) { if (_var.id == ID) { return i; } if (_var.type == VariableType.Boolean) { i++; } } return -1; } private int GetVarID (List<GVar> vars, int Number) { int i = 0; foreach (GVar _var in vars) { if (_var.type == VariableType.Boolean) { if (i == Number) { return _var.id; } i++; } } return -1; } } } </syntaxhighlight>
Summary:
Please note that all contributions to the Adventure Creator Wikia are considered to be released under the CC-BY-SA
Cancel
Editing help
(opens in new window)
Follow on IG
TikTok
Join Fan Lab