public override void OnInspectorGUI()
    {
        GraphNoiseGenerator graphNoiseGenerator = (GraphNoiseGenerator)target;

        if (DrawDefaultInspector() && graphNoiseGenerator.autoUpdate)
        {
            graphNoiseGenerator.GenerateGraphNoise();
        }

        if (GUILayout.Button("Generate"))
        {
            graphNoiseGenerator.GenerateGraphNoise();
        }
    }
Esempio n. 2
0
    public void GenerateGraph()
    {
        while (transform.childCount != 0)
        {
            DestroyImmediate(transform.GetChild(0).gameObject);
        }

        Random.InitState(seed);

        PolyGraph polyGraph = new PolyGraph(width, height, faceSize, faceSize, smoothingSteps, new CentriodCorner());

        graph = new Graph(polyGraph);


        for (int index = 0; index < graph.faces.Length; index++)
        {
            Face face = graph.faces[index];
            Tile tile = (Tile)Object.Instantiate(
                tilePrefab, face.position, Quaternion.identity);
            tile.transform.SetParent(transform);
            tile.Initialize(face, new GroundTile());
            face.tile = tile;
        }

        GraphNoiseGenerator graphNoiseGenerator = GetComponent <GraphNoiseGenerator>();

        if (graphNoiseGenerator != null)
        {
            graphNoiseGenerator.GenerateGraphNoise();
        }
    }