public static void DrawGPUInstancerPrototypeInfo(GPUInstancerPrototype selectedPrototype, UnityAction <string> DrawHelpText, Object component, UnityAction OnEditorDataChanged,
                                                         GPUInstancerShaderBindings shaderBindings, GPUInstancerEditorSimulator simulator, GPUInstancerTerrainSettings terrainSettings)
        {
            GPUInstancerTreePrototype treePrototype = (GPUInstancerTreePrototype)selectedPrototype;

            EditorGUILayout.BeginVertical(GPUInstancerEditorConstants.Styles.box);
            GPUInstancerEditorConstants.DrawCustomLabel(GPUInstancerEditorConstants.TEXT_treeSettings, GPUInstancerEditorConstants.Styles.boldLabel);

            treePrototype.isApplyRotation = EditorGUILayout.Toggle(GPUInstancerEditorConstants.TEXT_useRandomTreeTotation, treePrototype.isApplyRotation);
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_useRandomTreeTotation);

            EditorGUILayout.EndVertical();
        }
示例#2
0
        private void MapMagicTerrainAddTreeManager(Terrain terrain)
        {
            if (terrain.GetComponent <GPUInstancerTreeManager>() == null && treePrototypes != null && treePrototypes.Count > 0)
            {
                GPUInstancerTreeManager newTreeManager = terrain.gameObject.AddComponent <GPUInstancerTreeManager>();
                newTreeManager.isFrustumCulling   = isFrustumCulling;
                newTreeManager.isOcclusionCulling = isOcclusionCulling;
                newTreeManager.minCullingDistance = minCullingDistance;
                newTreeManager.autoSelectCamera   = autoSelectCamera;
                newTreeManager.cameraData.SetCamera(cameraData.mainCamera);
                newTreeManager.cameraData.renderOnlySelectedCamera = cameraData.renderOnlySelectedCamera;
                newTreeManager.cameraData.hiZOcclusionGenerator    = null;
                newTreeManager.InitializeCameraData();
                // for mapmagic tree optimization
                if (terrain.terrainData.treePrototypes.Length != treePrototypes.Count)
                {
                    int terrainTreeIndex = 0;
                    List <GPUInstancerPrototype> newPrototypeList = new List <GPUInstancerPrototype>();
                    for (int i = 0; i < treePrototypes.Count; i++)
                    {
                        if (terrainTreeIndex >= terrain.terrainData.treePrototypes.Length)
                        {
                            break;
                        }

                        GPUInstancerTreePrototype tp = (GPUInstancerTreePrototype)treePrototypes[i];
                        if (!terrain.terrainData.treePrototypes[terrainTreeIndex].prefab == tp.prefabObject)
                        {
                            newPrototypeList.Add(tp);
                            terrainTreeIndex++;
                        }
                    }
                    newTreeManager.prototypeList = newPrototypeList;
                }
                else
                {
                    newTreeManager.prototypeList = treePrototypes;
                }
                newTreeManager.SetupManagerWithTerrain(terrain);

                newTreeManager.terrainSettings.maxTreeDistance = terrainSettings.maxTreeDistance;

                if (terrain.gameObject.activeSelf)
                {
                    newTreeManager.InitializeRuntimeDataAndBuffers();
                }
            }
        }
        public static bool DrawGPUInstancerPrototypeInfo(List <GPUInstancerPrototype> selectedPrototypeList, UnityAction <string> DrawHelpText, Object component, UnityAction OnEditorDataChanged,
                                                         GPUInstancerEditorSimulator simulator, GPUInstancerTerrainSettings terrainSettings)
        {
            GPUInstancerTreePrototype prototype0 = (GPUInstancerTreePrototype)selectedPrototypeList[0];

            #region Determine Multiple Values
            bool hasChanged                = false;
            bool isApplyRotationMixed      = false;
            bool isApplyRotation           = prototype0.isApplyRotation;
            bool isApplyPrefabScaleMixed   = false;
            bool isApplyPrefabScale        = prototype0.isApplyPrefabScale;
            bool isApplyTerrainHeightMixed = false;
            bool isApplyTerrainHeight      = prototype0.isApplyTerrainHeight;
            for (int i = 1; i < selectedPrototypeList.Count; i++)
            {
                GPUInstancerTreePrototype prototypeI = (GPUInstancerTreePrototype)selectedPrototypeList[i];
                if (!isApplyRotationMixed && isApplyRotation != prototypeI.isApplyRotation)
                {
                    isApplyRotationMixed = true;
                }
                if (!isApplyPrefabScaleMixed && isApplyPrefabScale != prototypeI.isApplyPrefabScale)
                {
                    isApplyPrefabScaleMixed = true;
                }
                if (!isApplyTerrainHeightMixed && isApplyTerrainHeight != prototypeI.isApplyTerrainHeight)
                {
                    isApplyTerrainHeightMixed = true;
                }
            }
            #endregion Determine Multiple Values

            EditorGUILayout.BeginVertical(GPUInstancerEditorConstants.Styles.box);
            GPUInstancerEditorConstants.DrawCustomLabel(GPUInstancerEditorConstants.TEXT_treeSettings, GPUInstancerEditorConstants.Styles.boldLabel);

            hasChanged |= MultiToggle(selectedPrototypeList, GPUInstancerEditorConstants.TEXT_useRandomTreeRotation, isApplyRotation, isApplyRotationMixed, (p, v) => ((GPUInstancerTreePrototype)p).isApplyRotation = v);
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_useRandomTreeRotation);

            hasChanged |= MultiToggle(selectedPrototypeList, GPUInstancerEditorConstants.TEXT_useTerrainHeight, isApplyTerrainHeight, isApplyTerrainHeightMixed, (p, v) => ((GPUInstancerTreePrototype)p).isApplyTerrainHeight = v);
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_useTerrainHeight);

            hasChanged |= MultiToggle(selectedPrototypeList, GPUInstancerEditorConstants.TEXT_usePrefabScale, isApplyPrefabScale, isApplyPrefabScaleMixed, (p, v) => ((GPUInstancerTreePrototype)p).isApplyPrefabScale = v);
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_usePrefabScale);

            EditorGUILayout.EndVertical();

            return(hasChanged);
        }