コード例 #1
0
    private void OnEnable()
    {
        TerrainManager instance = (TerrainManager)target;

        paintType    = instance.PaintMode;
        topologyType = instance.SelectedTopology;
    }
コード例 #2
0
    public override void OnInspectorGUI()
    {
        TerrainManager instance = (TerrainManager)target;

        if (!TerrainManager.HasValidTerrain())
        {
            GUILayout.Label("Create or load a map to continue...");
            return;
        }

        GUILayout.Label("Paint Controls", EditorStyles.boldLabel);

        GUILayout.Space(5f);

        paintType = (PaintType)EditorGUILayout.EnumPopup("Paint Mode", paintType);
        if (paintType != instance.PaintMode)
        {
            instance.ChangePaintType(paintType);
            return;
        }

        if (paintType == PaintType.Topology)
        {
            topologyType = (TerrainTopology.Enum)EditorGUILayout.EnumPopup("Topology Layer", topologyType);
            if (topologyType != instance.SelectedTopology)
            {
                instance.ChangeTopologyLayer(topologyType);
            }
        }
    }
コード例 #3
0
    /// <summary>Rotates the selected topologies.</summary>
    /// <param name="topologyLayers">The Topology layers to rotate.</param>
    /// <param name="CW">True = 90°, False = 270°</param>
    public static void RotateTopologyLayers(TerrainTopology.Enum topologyLayers, bool CW)
    {
        List <int> topologyElements = GetEnumSelection(topologyLayers);

        int progressId = Progress.Start("Rotating Topologies", null, Progress.Options.Sticky);

        for (int i = 0; i < topologyElements.Count; i++)
        {
            Progress.Report(progressId, (float)i / topologyElements.Count, "Rotating: " + ((TerrainTopology.Enum)TerrainTopology.IndexToType(i)).ToString());
            RotateLayer(LandLayers.Topology, CW, i);
        }
        Progress.Finish(progressId);
    }
コード例 #4
0
    /// <summary>Inverts the selected Topology layers.</summary>
    /// <param name="topologyLayers">The Topology layers to invert.</param>
    public static void InvertTopologyLayers(TerrainTopology.Enum topologyLayers)
    {
        List <int> topologyElements = GetEnumSelection(topologyLayers);

        int progressId = Progress.Start("Invert Topologies");

        for (int i = 0; i < topologyElements.Count; i++)
        {
            Progress.Report(progressId, (float)i / topologyElements.Count, "Inverting: " + ((TerrainTopology.Enum)TerrainTopology.IndexToType(i)).ToString());
            InvertLayer(LandLayers.Topology, i);
        }
        Progress.Finish(progressId);
    }
コード例 #5
0
    public void Cleanup()
    {
        if (Terrain != null)
        {
            UnityEngine.Object.DestroyImmediate(Terrain.gameObject);
        }

        if (WaterPlane != null)
        {
            UnityEngine.Object.DestroyImmediate(WaterPlane);
        }

        PaintMode        = PaintType.Splat;
        SelectedTopology = TerrainTopology.Enum.Field;
    }
コード例 #6
0
    public void ChangeTopologyLayer(TerrainTopology.Enum topology)
    {
        if (topology == SelectedTopology)
        {
            return;
        }

        if (!HasValidTerrain())
        {
            return;
        }

        StoreCurrentAlphaMaps();

        SelectedTopology = topology;

        SetSplatMaps(PaintType.Topology);
    }
コード例 #7
0
    public void SetArray(TerrainTopology.Enum layer, float[,,] splatMap)
    {
        for (int z = 0; z < res; z++)
        {
            for (int x = 0; x < res; x++)
            {
                bool set = (splatMap[z, x, 0] == 1f);

                if (set)
                {
                    this[z, x] |= (int)layer;
                }
                else
                {
                    this[z, x] &= ~(int)layer;
                }
            }
        }
    }
コード例 #8
0
    public float[,,] GetArray(TerrainTopology.Enum layer)
    {
        float[,,] splats = new float[res, res, 2];

        for (int z = 0; z < res; z++)
        {
            for (int x = 0; x < res; x++)
            {
                if ((this[z, x] & (int)layer) != 0)
                {
                    splats[z, x, 0] = 1f;
                    splats[z, x, 1] = 0f;
                }
                else
                {
                    splats[z, x, 0] = 0f;
                    splats[z, x, 1] = 1f;
                }
            }
        }

        return(splats);
    }
コード例 #9
0
ファイル: Variables.cs プロジェクト: drewdunne/Editor
 public TopologyConditions(TerrainTopology.Enum layer)
 {
     Layer      = layer;
     Texture    = new TopologyTextures[TerrainTopology.COUNT];
     CheckLayer = new bool[TerrainTopology.COUNT];
 }
コード例 #10
0
 public void UpdateFromTerrain(TerrainTopology.Enum layer, Terrain terrain)
 {
     SetArray(layer, terrain.terrainData.GetAlphamaps(0, 0, res, res));
 }