Example #1
0
 private void CheckVariables()
 {
     for (int i = 0; i < boolVariables.Count; i++)
     {
         BoolVariable variable = boolVariables[i];
         bool         flag     = false;
         foreach (DataVariable dataVariable in dataVariables)
         {
             if (dataVariable.variable == variable)
             {
                 flag = true;
                 break;
             }
         }
         if (!flag)
         {
             boolVariables.RemoveAt(i);
             i--;
             DestroyImmediate(variable.gameObject);
         }
     }
 }
Example #2
0
        private BoolVariable CreateBoolVariable(string name, bool value)
        {
            GameObject goBoolVariables;

            if (transform.Find("BoolVariables") == null)
            {
                goBoolVariables = new GameObject("BoolVariables");
                goBoolVariables.transform.parent = transform;
            }
            else
            {
                goBoolVariables = transform.Find("BoolVariables").gameObject;
            }
            GameObject   goBoolVariable = new GameObject("BoolVariable");
            BoolVariable boolVariable   = goBoolVariable.AddComponent <BoolVariable>();

            boolVariable.variableName       = name;
            boolVariable.value              = value;
            goBoolVariable.transform.parent = goBoolVariables.transform;
            boolVariables.Add(boolVariable);
            return(boolVariable);
        }
Example #3
0
        public void CheckBoolVariable(DataVariable dataVariable, string name, bool value)
        {
            BoolVariable boolVariable = null;

            if (name != "")
            {
                foreach (BoolVariable variable in boolVariables)
                {
                    if (variable.variableName == name)
                    {
                        boolVariable       = variable;
                        boolVariable.value = value;
                    }
                }
                if (boolVariable == null)
                {
                    boolVariable = CreateBoolVariable(name, value);
                }
            }
            dataVariable.variable = boolVariable;
            CheckVariables();
        }