public FloatingIsland(Vector3 center, float minRadius, int seed, float islandScale, float jaggedDensity, float jaggedScale, int meshDensity, float topHeight, float botHeight)
        {
            islandGenerator         = FindObjectOfType <FloatingIslandGenerator>();
            this.baseCenterPosition = center;
            this.minorRadius        = minRadius;
            this.islandScale        = islandScale;
            this.jaggedDensity      = jaggedDensity;
            this.jaggedScale        = jaggedScale;
            this.seed        = seed;
            this.meshDensity = meshDensity;

            meshObject   = new GameObject("Floating Island");
            meshRenderer = meshObject.AddComponent <MeshRenderer>();
            meshFilter   = meshObject.AddComponent <MeshFilter>();
            Material diffuse = islandGenerator.GetComponent <MeshRenderer>().sharedMaterial;

            meshRenderer.material = diffuse;

            meshObject.transform.position   = center;
            meshObject.transform.parent     = islandGenerator.transform;
            meshObject.transform.localScale = Vector3.one * islandScale;
            SetVisible(false);


            Noise.NoiseParams edgeNoiseParams = new Noise.NoiseParams(islandGenerator.noiseScale,
                                                                      islandGenerator.octaves,
                                                                      islandGenerator.persistance,
                                                                      islandGenerator.lacunarity,
                                                                      islandGenerator.offset,
                                                                      islandGenerator.normalizeMode);

            Noise.NoiseParams contourNoiseParams = new Noise.NoiseParams(islandGenerator.noiseScale_top,
                                                                         islandGenerator.octaves_top,
                                                                         islandGenerator.persistance_top,
                                                                         islandGenerator.lacunarity_top,
                                                                         islandGenerator.offset_top,
                                                                         islandGenerator.normalizeMode);

            this.islandData = MeshGenerator.GenerateFloatingIslandMesh(
                this.baseCenterPosition,
                topHeight,
                botHeight,
                islandGenerator.jaggedScale,
                islandScale,
                this.minorRadius,
                islandGenerator.jaggedDensity,
                this.meshDensity,
                this.seed,
                edgeNoiseParams,
                contourNoiseParams,
                islandGenerator.topRegions,
                islandGenerator.botRegions);
        }
Exemple #2
0
    public override void OnInspectorGUI()
    {
        mapGen = (FloatingIslandGenerator)target;

        if (DrawDefaultInspector())
        {
            if (mapGen.autoUpdate)
            {
                mapGen.DrawMapInEditor();
            }
        }

        if (GUILayout.Button("Generate"))
        {
            mapGen.DrawMapInEditor();
        }
    }