コード例 #1
0
    // OnInspector GUI
    public override void OnInspectorGUI()
    {
        if (GUILayout.Button("Generate"))
        {
            TerrainSettings settings = GameObject.FindGameObjectWithTag("GameManager").GetComponentInChildren <TerrainSettings>();

            PlaneSurface mySurface = settings.gameObject.GetComponent <PlaneSurface>();
            if (mySurface == null)
            {
                mySurface = settings.gameObject.AddComponent <PlaneSurface>();
            }

            mySurface.maxHeight   = (int)planeSize / 2;
            mySurface.width       = baseWidth;
            mySurface.length      = baseLength;
            mySurface.planeLength = planeSize;

            mySurface.tmpNodeObjects = new List <GameObject>();

            mySurface.populateNodes();
            mySurface.createPlanes();

            Debug.Log("Terrain generated.");
        }
    }