Search Unity

Get all the variable names?

Discussion in 'Scripting' started by Bongmo, Jun 11, 2017.

  1. Bongmo

    Bongmo

    Joined:
    Jan 18, 2014
    Posts:
    155
    Hi.

    I read a *.txt file line by line very simple with ReadLines in unity..

    The text file looks like this:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class Testing : MonoBehaviour {
    6.  
    7.     public float fOne;
    8.  
    9.     public GameObject gObjOne;
    10.  
    11.     public GameObject[] gObjTwo;
    12.  
    13.     // Use this for initialization
    14.     void Start () {
    15.    
    16.         int testVar;
    17.    
    18.         testVar = 32;
    19.    
    20.     }
    21.  
    22.     // Update is called once per frame
    23.     void Update () {
    24.    
    25.     }
    26. }
    Now, what I want is to put all these variable names (E.g. fOne, gObjOne, gObjTwo, testVar) in a list:
    Code (CSharp):
    1. private List<string> varNames = new List<String> ();
    Is this possible?