ClientServer/Client/Assets/GPUInstancer/Scripts/Editor/GPUInstancerTerrainProxyEditor.cs
TG9six 03a642d635 first push
first push
2025-09-06 17:17:39 +04:00

78 lines
3.6 KiB
C#

using System;
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace GPUInstancer
{
[CustomEditor(typeof(GPUInstancerTerrainProxy))]
public class GPUInstancerTerrainProxyEditor : Editor
{
private static Type terrainInspectorType;
private GPUInstancerTerrainProxy terrainProxy;
public override void OnInspectorGUI()
{
terrainProxy = (GPUInstancerTerrainProxy)target;
if (terrainProxy.detailManager != null)
{
GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.goToGPUInstancerDetail, GPUInstancerEditorConstants.Colors.green, Color.white, FontStyle.Bold, Rect.zero,
() =>
{
if (terrainProxy.detailManager != null && terrainProxy.detailManager.gameObject != null)
Selection.activeGameObject = terrainProxy.detailManager.gameObject;
});
}
if (terrainProxy.treeManager != null)
{
GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.goToGPUInstancerTree, GPUInstancerEditorConstants.Colors.green, Color.white, FontStyle.Bold, Rect.zero,
() =>
{
if (terrainProxy.treeManager != null && terrainProxy.treeManager.gameObject != null)
Selection.activeGameObject = terrainProxy.treeManager.gameObject;
});
}
EditorGUILayout.HelpBox(GPUInstancerEditorConstants.HELPTEXT_terrainProxyWarning, MessageType.Warning);
// select terrain tool
//if(terrainProxy.terrainSelectedToolIndex > 0)
//{
// try
// {
// if(terrainInspectorType == null)
// terrainInspectorType = Assembly.GetAssembly(typeof(Editor)).GetType("UnityEditor.TerrainInspector");
// PropertyInfo selectedTool = terrainInspectorType.GetProperty("selectedTool", BindingFlags.NonPublic | BindingFlags.Instance);
// UnityEngine.Object[] terrainInspectors = Resources.FindObjectsOfTypeAll(terrainInspectorType);
// foreach (UnityEngine.Object terrainInspector in terrainInspectors)
// {
// //Debug.Log(selectedTool.GetValue(terrainInspector, new object[0]));
// selectedTool.SetValue(terrainInspector, terrainProxy.terrainSelectedToolIndex, new object[0]);
// break;
// }
// }
// catch (Exception) { };
// terrainProxy.terrainSelectedToolIndex = -1;
//}
}
//void OnSceneGUI()
//{
// if (Event.current.type == EventType.MouseUp && Event.current.button == 0)
// {
// if (terrainProxy != null && terrainProxy.detailManager != null && terrainProxy.detailManager.gpuiSimulator != null && terrainProxy.detailManager.gpuiSimulator.simulateAtEditor
// && terrainProxy.detailManager.keepSimulationLive && terrainProxy.detailManager.updateSimulation)
// {
// if (terrainProxy.detailManager.isInitialized)
// {
// //Debug.Log("restarting simulation");
// terrainProxy.detailManager.gpuiSimulator.StopSimulation();
// terrainProxy.detailManager.gpuiSimulator.StartSimulation();
// }
// }
// }
//}
}
}