Ejemplo n.º 1
0
    public void Initialize()
    {
        colourGenerator.UpdateSettings(coloursSettings);
        elevationMinMax = new MinMax();

        if (faces.Length != 6)
        {
            faces = new PlanetFace[6];
        }
        for (int i = 0; i < 6; i++)
        {
            if (faces[i] == null)
            {
                GameObject go = new GameObject("face");
                go.transform.parent     = transform;
                go.transform.localScale = Vector3.one;
                Debug.Log("init face " + i);
                faces[i] = go.AddComponent <PlanetFace>();
            }
            ;
            PlanetFace face = faces[i];
            face.gameObject.layer = terrainLayer;
            face.GetComponent <MeshRenderer>().sharedMaterial = coloursSettings.planetMaterial;
        }
    }
Ejemplo n.º 2
0
    void SetupMesh()
    {
        for (int i = 0; i < 6; i++)
        {
            PlanetFace face     = faces[i];
            bool       renderIt = toRender.HasFlag((Faces)(1 << i));
            face.meshFilter.sharedMesh   = renderIt ? GenerateFaceMesh(directions[i], nbSegments) : null;
            face.meshCollider.sharedMesh = renderIt && !designMode?GenerateFaceMesh(directions[i], Mathf.CeilToInt(colliderPrecision *nbSegments)) : null;

            face.GetComponent <MeshRenderer>().sharedMaterial = coloursSettings.planetMaterial;
            colourGenerator.UpdateElevation(elevationMinMax);
        }
    }