Quantcast
Channel: Unity Forum
Viewing all articles
Browse latest Browse all 1466670

Change string into a runnable code (kind of)

$
0
0
I basically need to use a string passed in through a function as a part of the code.

This is an example of how I'd call the function:
Code (CSharp):
  1. findPathVar("GetComponent<exampleScript>()", "ItemID");
Code (CSharp):
  1. public int findPathVar(string path, string varName) {
  2.      
  3.        int variableNeeded = gameObject.(path).(varName);
  4.      
  5.        return variableNeeded;
  6. }
So this way I could find the value of 'ItemID' in 'exampleScript'.
Is this, or something similar, possible?...

Change string into a runnable code (kind of)

Viewing all articles
Browse latest Browse all 1466670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>