private void ShowSettings() { if (settings == null) { settings = PathFinderSettings.LoadSettings(); } settings.helperName = EditorGUILayout.TextField(new GUIContent("Helper name", "pathfinder need object in scene in order to use unity API. you can specify it's name here"), settings.helperName); settings.useMultithread = EditorGUILayout.Toggle(new GUIContent("Multithread", "you can on/off multithreading for debug purpose. cause debuging threads is pain"), settings.useMultithread); if (settings.useMultithread) { settings.maxThreads = EditorGUILayout.IntField(new GUIContent("Max threads", "limit how much threads are used"), settings.maxThreads); } settings.terrainCollectionType = (TerrainCollectorType)EditorGUILayout.EnumPopup(new GUIContent("Terrain collection", "UnityWay - Collect data from terrain using Terrain.SampleHeight and TerrainData.GetSteepness. It's fast but it's all in main thread.\nCPU - Collect data by some fancy math using CPU. Not that fast but fully threaded.\nComputeShader - Superfast but in big chunks can be slow cause moving data from GPU is not that fast."), settings.terrainCollectionType); settings.colliderCollectionType = (ColliderCollectorType)EditorGUILayout.EnumPopup(new GUIContent("Collider collection", "CPU - Collect data using CPU rasterization. It's threaded so no FPS drops here. \nComputeShader - Collect data by ComputeShader. Superfast but in big chunks can be slow cause moving data from GPU is not that fast."), settings.colliderCollectionType); settings.gridSize = EditorGUILayout.FloatField(new GUIContent("World grid size", "Chunk size in world space. Good values are 10, 15, 20 etc."), settings.gridSize); settings.gridHighest = EditorGUILayout.IntField(new GUIContent("Chunk max height", "For autocreating chunks. World space value is grid size * this value."), settings.gridHighest); if (settings.gridHighest < settings.gridLowest) { settings.gridHighest = settings.gridLowest; } settings.gridLowest = EditorGUILayout.IntField(new GUIContent("Chunk min height", "For autocreating chunks. World space value is grid size * this value."), settings.gridLowest); if (settings.gridLowest > settings.gridHighest) { settings.gridLowest = settings.gridHighest; } settings.DrawAreaEditor(); }
private void ShowSettings() { if (settings == null) { settings = PathFinderSettings.LoadSettings(); } EditorGUILayout.PropertyField(helperName, helperNameContent); if (useMultithread.boolValue) { GUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(useMultithread, useMultithreadContent); EditorGUIUtility.labelWidth = 80; EditorGUILayout.PropertyField(maxThreads, maxThreadsContent); EditorGUIUtility.labelWidth = LABEL_WIDTH; GUILayout.EndHorizontal(); } else { EditorGUILayout.PropertyField(useMultithread, useMultithreadContent); } EditorGUILayout.PropertyField(terrainCollectionType, terrainCollectionTypeContent); EditorGUILayout.PropertyField(colliderCollectionType, colliderCollectionTypeContent); float someFloat; EditorGUI.BeginChangeCheck(); someFloat = EditorGUILayout.FloatField(gridSizeContent, gridSize.floatValue); if (EditorGUI.EndChangeCheck()) { settings.gridSize = someFloat; PathFinder.gridSize = someFloat; } GUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(gridLowest, gridLowestContent); EditorGUIUtility.labelWidth = 30; EditorGUILayout.PropertyField(gridHighest, gridHighestContent); EditorGUIUtility.labelWidth = LABEL_WIDTH; GUILayout.EndHorizontal(); if (gridHighest.intValue < gridLowest.intValue) { gridHighest.intValue = gridLowest.intValue; } if (gridLowest.intValue > gridHighest.intValue) { gridLowest.intValue = gridHighest.intValue; } UITools.Line(); settingsDrawer.DrawAreaEditor(); }
void OnEnable() { Debuger_K.Init(); settings = PathFinderSettings.LoadSettings(); SceneView.onSceneGUIDelegate -= this.OnSceneGUI; SceneView.onSceneGUIDelegate += this.OnSceneGUI; Repaint(); this.autoRepaintOnSceneChange = true; }
//return if scene object was loaded public static bool Init() { if (!_areInit) { _areInit = true; //asume init was in main thread _mainThreadID = Thread.CurrentThread.ManagedThreadId; } if (Thread.CurrentThread.ManagedThreadId != _mainThreadID) { return(false); } if (_settings == null) { _settings = PathFinderSettings.LoadSettings(); foreach (var item in _settings.areaLibrary) { _hashData.AddAreaHash(item); } #if UNITY_EDITOR if (Debuger_K.doDebug) { Debug.LogFormat("settings init"); } #endif } if (_sceneInstance == null || _sceneInstance.gameObject == null) { try { GameObject go = GameObject.Find(_settings.helperName); if (go == null) { go = new GameObject(_settings.helperName); } _sceneInstance = go.GetComponent <PathFinderScene>(); if (_sceneInstance == null) { _sceneInstance = go.AddComponent <PathFinderScene>(); } _sceneInstance.AddCoroutine((int)NavMeshTaskType.navMesh, TemplatePopulationLoop()); _sceneInstance.AddCoroutine((int)NavMeshTaskType.graphFinish, ChunkConnection()); _sceneInstance.AddCoroutine((int)NavMeshTaskType.disconnect, ChunkDisconnection()); _sceneInstance.InitComputeShaderRasterization3D(_settings.ComputeShaderRasterization3D); _sceneInstance.InitComputeShaderRasterization2D(_settings.ComputeShaderRasterization2D); _sceneInstance.Init(); } catch (Exception e) { Debug.LogError(e); throw; } return(true); } else { return(false); } }