How to find a variable int with a string?
So I have my script set up finding a variable in another script using and it works just fine using "Item1" since "Item1" is a variable in Inventory script. Code:
GameObject helper = GameObject.Find ("Helper"); Inventory inventory = helper.GetComponent (); if (inventory.Item1 == 0) { Debug.Log ("TA DA"); }
But is it possible to replace:
if (inventory.Item1 == 0) {
with:
public string SOMESTRINGHERE = Item1; (or whatever I need)
if (inventory.SOMESTRINGHERE == 0) {
So that I can change it from the editor that way I can make a prefab where I can change it to whatever I need?
Answer by Adam-Mechtley · Sep 28, 2016 at 07:05 AM
@PigChop I'm not 100% clear on what you're wanting to do, but it sounds like maybe you want to use SerializedProperty
Your answer
Follow this Question
Related Questions
Editor script: Variable created on gameObject in editor set to missing on runtime 0 Answers
how to find gameobject using a varable 1 Answer
Editorscript: How to reference prefabs in editor not in awake or start 0 Answers
String Variable Not Changing From Starting Value, 0 Answers
int variable seem to have multiple value at the same time 0 Answers