Changing value of a property without knowing the component its in
So I have a string called BoolName, for the purpose of this BoolName = DoAction: OpenDoor[true]
What i want to do with the string is: - remove the DoAction: part (done this) - figure out if the [true] part says true or false then remove it (done this) - take the remaing bit that says "OpenDoor" and use it to find the bool property in an unknown script called OpenDoor
Heres the code I have so far: public void PerformAction() { BoolName = System.Convert.ToString(DialogueValue.Remove(0, 11)); // This bit is just removing the "DoAction:" part that will always be at the start if (BoolName.Contains("[true]")) { Debug.Log("String contains true"); BoolName.Replace("[true]", string.Empty); // Removing the true/false part to just leave the name of the bool being targeted SetBoolToTrue(BoolName); } else if (BoolName.Contains("[false]")) { Debug.Log("String contains false"); BoolName.Replace("[false]", string.Empty); // Removing the true/false part to just leave the name of the bool being targeted } }