I am converting my Unity3D game from JS to C#, and I face some problem with this function:
void ReorientationNaming(GameObject g)
    {
        ///find the cube and its bounds
        GameObject tobename = g;
        Bounds cubebound = tobename.renderer.bounds;
        string namex;
        string namey;
        string namez;
        GameObject[] allAxisList = GameObject.FindGameObjectsWithTag("AxisPlain");
        foreach(GameObject allAxis in allAxisList) 
        {
            Bounds axisbound = allAxis.renderer.bounds;
            if (cubebound.Intersects(axisbound))
            {
                if (allAxis.name.Contains("x")) 
                {
                    namex = allAxis.name;
                    namex = namex.Substring(1,1);
                    //print("namex" + namex);
                }
                if (allAxis.name.Contains("y")) 
                {
                    namey = allAxis.name;
                    namey = namey.Substring(1,1);
                }
                if (allAxis.name.Contains("z")) 
                {
                    namez = allAxis.name;
                    namez = namez.Substring(1,1);
                }
            }
            tobename.name = namex+namey+namez;//<-- this line is the problem!
        }
    }
The final line give me the error:
Assets/Cumetry/MainGameLogic.cs(136,41): error CS0165: Use of unassigned local variable `namex'
Assets/Cumetry/MainGameLogic.cs(136,41): error CS0165: Use of unassigned local variable `namey'
Assets/Cumetry/MainGameLogic.cs(136,41): error CS0165: Use of unassigned local variable `namez'
I believe is the way I declare the string. Any idea How can I resolve this?
 
     
    