public override void ShowGUIEdit(EditorWindow window)
        {
            region = (LevelRegion)EditorGUILayout.ObjectField(Style.LABLE_REGION_FIELD, region, typeof(LevelRegion), false);
            if (region != null)
            {
                prefab = region.terrainGameObject;
                //prefab.GetComponent<RegionTerrain>().enabled = false;

                preview  = preview = AssetPreview.GetAssetPreview(prefab);
                cellSize = region.mapSize;

                pivot = new Vector3((region.mapSize.x * region.mapScale.x) / 2, 0, (region.mapSize.y * region.mapScale.y) / 2);
            }
        }
Example #2
0
        //En un principio Grid terrain tenia toda la lógica del grid. Dado que es un Monobehaviour, no se puede serializar y por lo tanto tiene que estar en Level.
        public Mesh Init(float xS, float yS, Vector2Int size, LevelRegion o)
        {
            xSize  = size.x;
            ySize  = size.y;
            xScale = xS;
            yScale = yS;
            Mesh m = new Mesh();

            m.name = "Procedular";
            m.SetVertices(CreateVertex().ToList());
            m.SetTriangles(CreateTris(m), 0, true);
            m.RecalculateNormals();
            gameObject.layer = LayerMask.NameToLayer("Grid");
            mesh             = GetComponent <MeshFilter>();
            meshRenderer     = GetComponent <MeshRenderer>();
            mesh.mesh        = m;
            SetMaterial();
            collider            = gameObject.AddComponent <MeshCollider>();
            collider.sharedMesh = m;
            owner = o;
            return(m);
        }