Ejemplo n.º 1
0
        /// <summary>
        /// Called if the terrain hasn't been setup yet or
        /// if the terrain GameObject is missing any components
        /// </summary>
        private void SetupTerrainEditor(TerrainSegment terrain)
        {
            if (terrain.gameObject.name == "GameObject")
            {
                terrain.gameObject.name = "Terrain";
            }

            if (terrain.GetComponent <EdgeCollider2D>() == null)
            {
                terrain.gameObject.AddComponent <EdgeCollider2D>();
            }
            if (terrain.GetComponent <MeshFilter>() == null)
            {
                terrain.gameObject.AddComponent <MeshFilter>();
            }
            if (terrain.GetComponent <MeshRenderer>() == null)
            {
                MeshRenderer newRenderer = terrain.gameObject.AddComponent <MeshRenderer>();
                newRenderer.receiveShadows = false;
                //newRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
            }

            terrain.Setup(terrain.numberOfPoints, terrain.createEdge, 0);
        }
Ejemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            TerrainSegment terrain = (TerrainSegment)target;

            DrawDefaultInspector();

            if (terrain.GetMesh() == null || terrain.GetComponent <EdgeCollider2D>() == null || terrain.GetComponent <MeshFilter>() == null || terrain.GetComponent <MeshRenderer>() == null)
            {
                SetupTerrainEditor(terrain);
            }
            else
            {
                RunTerrainEditor(terrain);
            }
        }