Beispiel #1
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            if (converter.terrain)
            {
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("生成分层网格"))
                {
                    converter.trees = new LodNodeTree[converter.maxLodLevel + 1];
                    for (int i = 0; i <= converter.maxLodLevel; i++)
                    {
                        converter.trees[i] = new LodNodeTree();
                        float       error    = converter.minError * Mathf.Pow(Mathf.Pow(converter.maxError / converter.minError, 1.0f / (converter.maxLodLevel)), i);
                        Node        tempNode = CreateNode(error, converter.gridSize);
                        List <byte> bytes    = new List <byte>();
                        tempNode.ToBytes(bytes);
                        converter.trees[i].tree        = bytes;
                        converter.trees[i].alphaLayers = tempNode.GetAlphaBytes();
                    }

                    converter.LoadNodes();

                    converter.ClearChildren();

                    converter.CreateGridObjects();
                }
                GUILayout.EndHorizontal();
            }
        }
Beispiel #2
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            if (converter.terrain)
            {
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("测试"))
                {
                    converter.bakedControlTexture = TerrainToMeshTool.BakeTextureIndex(converter.terrain.terrainData);
                }
                if (GUILayout.Button("生成分层网格"))
                {
                    converter.trees = new LodNodeTree[converter.maxLodLevel + 1];
                    for (int i = 0; i <= converter.maxLodLevel; i++)
                    {
                        converter.trees[i] = new LodNodeTree();
                        float       error    = converter.minError * Mathf.Pow(Mathf.Pow(converter.maxError / converter.minError, 1.0f / (converter.maxLodLevel)), i);
                        Node        tempNode = CreateNode(error, converter.gridSize);
                        List <byte> bytes    = new List <byte>();
                        tempNode.ToBytes(bytes);
                        converter.trees[i].tree        = bytes.ToArray();
                        converter.trees[i].alphaLayers = tempNode.GetAlphaBytes();
                    }

                    converter.LoadNodes();

                    converter.ClearChildren();
                    converter.CollectInfos();
                    if (converter.staticLodMesh)
                    {
                        converter.CreateStaticMeshes();
                        converter.ClearCollectedInfo();
                    }
                    else
                    {
                        converter.Update();
                    }
                }
                GUILayout.EndHorizontal();
            }
            EditorGUILayout.LabelField("内存", converter.GetMemorySize().ToString());
        }