private void ClassicMaterial() { TerrainLayer ly = editData.layers[_selectProcedural]; if (ly.texture != null) { GUILayout.Label("Modify", PGUIStyle.nodeLabelBold); GUILayout.BeginHorizontal("Box"); GUILayout.Label(PResourceManager.LoadTexture("Terrain/TDiff.jpg")); ly.texture = EditorGUILayout.ObjectField(ly.texture, typeof(Texture2D), true, GUILayout.Width(75), GUILayout.Height(75)) as Texture; TerrainObject tobj = currentSelect.GetComponent <TerrainObject>(); tobj.material.SetTexture("_Splat" + _selectProcedural, ly.texture); if (tobj.material.HasProperty("_BumpSplat" + _selectProcedural)) { GUILayout.Label(PResourceManager.LoadTexture("Terrain/TBump.jpg")); ly.bumpTexture = EditorGUILayout.ObjectField(ly.bumpTexture, typeof(Texture2D), true, GUILayout.Width(75), GUILayout.Height(75)) as Texture; tobj.material.SetTexture("_BumpSplat" + _selectProcedural, ly.bumpTexture); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } }
private static void BuildIcons() { menuIcon[0] = new GUIContent(PResourceManager.LoadTexture("Terrain/conv.png"), "Conveter"); menuIcon[1] = new GUIContent(PResourceManager.LoadTexture("Terrain/optimize.png"), "Optimize"); menuIcon[2] = new GUIContent(PResourceManager.LoadTexture("Terrain/myt4m.png"), "Setting"); menuIcon[3] = new GUIContent(PResourceManager.LoadTexture("Terrain/paint.png"), "Paint"); menuIcon[4] = new GUIContent(PResourceManager.LoadTexture("Terrain/plant.png"), "Plant"); menuIcon[5] = new GUIContent(PResourceManager.LoadTexture("Terrain/lod.png"), "LOD"); menuIcon[6] = new GUIContent(PResourceManager.LoadTexture("Terrain/bill.png"), "Billboard"); }
private static void DrawShaderCompability(string label, bool compatible) { GUILayout.BeginHorizontal(); GUILayout.Label(label, GUILayout.Width(300)); GUILayout.FlexibleSpace(); GUILayout.Label(compatible ? PResourceManager.LoadTexture("Terrain/ok.png") : PResourceManager.LoadTexture("Terrain/ko.png")); GUILayout.EndHorizontal(); }
internal void OnEnable() { PResourceManager.SetDefaultResourcePath("Assets/Res/Scripts/Editor/res/"); Texture icon = PResourceManager.LoadTexture(EditorGUIUtility.isProSkin ? "Textures/Icon_Dark.png" : "Textures/Icon_Light.png"); titleContent = new GUIContent("Tree Property", icon); TreePropertyCenter.Start(); PPaintCenter.ClientRepaints -= Repaint; PPaintCenter.ClientRepaints += Repaint; }
internal void OnEnable() { PResourceManager.SetDefaultResourcePath("Assets/Res/Scripts/Editor/res/"); Texture icon = PResourceManager.LoadTexture(EditorGUIUtility.isProSkin ? "Textures/Icon_Dark.png" : "Textures/Icon_Light.png"); titleContent = new GUIContent("Machine", icon); minSize = new Vector2(150, 100); MachineHierachyCenter.Start(); PPaintCenter.ClientRepaints -= Repaint; PPaintCenter.ClientRepaints += Repaint; }
internal void OnEnable() { PResourceManager.SetDefaultResourcePath("Assets/Res/Scripts/Editor/res/"); Texture icon = PResourceManager.LoadTexture(EditorGUIUtility.isProSkin ? "Textures/Icon_Dark.png" : "Textures/Icon_Light.png"); titleContent = new GUIContent("Diagram", icon); minSize = new Vector2(250, 100); // wantsMouseMove = true; DiagramCenter.notifier -= ShowNotification; DiagramCenter.notifier += ShowNotification; DiagramCenter.Start(); PPaintCenter.ClientRepaints -= Repaint; PPaintCenter.ClientRepaints += Repaint; }
internal void OnEnable() { PResourceManager.SetDefaultResourcePath("Assets/Res/Scripts/Editor/res/"); Texture icon = PResourceManager.LoadTexture(EditorGUIUtility.isProSkin ? "Textures/Icon_Dark.png" : "Textures/Icon_Light.png"); titleContent = new GUIContent("Search", icon); minSize = new Vector2(300, 100); wantsMouseMove = true; TreeSearchCenter.Start(); PPaintCenter.ClientRepaints -= Repaint; PPaintCenter.ClientRepaints += Repaint; TreeSearchCenter.windowCloseHandler -= ShouldClose; TreeSearchCenter.windowCloseHandler += ShouldClose; }
private void DrawConvertGUI() { Renderer _currRenderer = currentSelect.GetComponent <Renderer>(); Terrain _unityTerrainComp = currentSelect.GetComponent <Terrain>(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if ((_currRenderer || editData.childRenderers != null) && !_unityTerrainComp) { if (_terrainDat) { _terrainDat = null; } GUILayout.Label("Convert Object To Pure TerrainObject", PGUIStyle.nodeLabelBold); } else { if (!_terrainDat && _unityTerrainComp) { GetHeightMap(); } GUILayout.Label("Convert Unity Terrain To Pure TerrainObject", PGUIStyle.nodeLabelBold); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); EditorGUILayout.Space(); GUILayout.BeginHorizontal("box"); GUILayout.Label("name", PGUIStyle.nodeLabelBold); _terrainName = GUILayout.TextField(_terrainName, 25, GUILayout.Width(155)); GUILayout.Label("empty = object name"); GUILayout.EndHorizontal(); if ((_currRenderer || editData.childRenderers != null) && !_unityTerrainComp) { GUILayout.BeginHorizontal(); GUILayout.Label("Create New Prefab", PGUIStyle.nodeLabelBold, GUILayout.Width(150)); _createNewPrefab = EditorGUILayout.Toggle(_createNewPrefab, GUILayout.Width(53)); GUILayout.EndHorizontal(); } else { GUILayout.BeginHorizontal(); GUILayout.Label("Keep the textures", PGUIStyle.nodeLabelBold, GUILayout.Width(150)); _keepTexture = EditorGUILayout.Toggle(_keepTexture, GUILayout.Width(53)); GUILayout.EndHorizontal(); GUILayout.Label("Can Keep the first 4 splats and first blend", GUILayout.Width(300)); } if (_unityTerrainComp) { EditorGUILayout.Space(); EditorGUILayout.Space(); GUILayout.Label("Quality", PGUIStyle.nodeLabelBold); EditorGUILayout.Space(); EditorGUILayout.Space(); GUILayout.BeginHorizontal(); GUILayout.Label("<"); GUILayout.FlexibleSpace(); _resolution = EditorGUILayout.IntField(_resolution, GUILayout.Width(30)); GUILayout.Label("x" + _resolution + " : " + _resX * _resY + "Verts"); GUILayout.FlexibleSpace(); GUILayout.Label(">"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); _resolution = (int)GUILayout.HorizontalScrollbar(_resolution, 0, 4, 350, GUILayout.Width(350)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.Space(); _tRes = _heightmapWidth / _resolution; _resX = (int)((_heightmapWidth - 1) / _tRes + 1); _resY = (int)((_heightmapHeight - 1) / _tRes + 1); EditorGUILayout.Space(); EditorGUILayout.Space(); GUILayout.Label("Vertex Performances (Approximate Indications)", PGUIStyle.nodeLabelBold); EditorGUILayout.Space(); EditorGUILayout.Space(); float _t = _resX * _resY; GUILayout.BeginHorizontal(); GUILayout.Space(50); GUILayout.BeginVertical(); for (int i = 0, len = _platforms.Length; i < len; i++) { GUILayout.BeginHorizontal(); GUILayout.Label(_platforms[i].name); GUILayout.FlexibleSpace(); if (_t <= _platforms[i].min) { GUILayout.Label(PResourceManager.LoadTexture("Terrain/ok.png")); } else if (_t > _platforms[i].min && _t <= _platforms[i].max) { GUILayout.Label( PResourceManager.LoadTexture("Terrain/avoid.png")); } else { GUILayout.Label(PResourceManager.LoadTexture("Terrain/ko.png")); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.Space(50); GUILayout.EndHorizontal(); } GUILayout.Box(PGUIStyle.BorderColor0, GUILayout.ExpandWidth(true), GUILayout.Height(1.0f)); GUILayout.Space(20); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("Might Take Some Time", PGUIStyle.nodeLabelBold); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (!_unityTerrainComp && (_currRenderer || editData.childRenderers != null)) { if (GUILayout.Button("Convert Object To Pure", GUILayout.Width(200), GUILayout.Height(30))) { Object2Terrain(); } } else { if (GUILayout.Button("Convert Unity Terrain To Pure", GUILayout.Width(200), GUILayout.Height(30))) { Unity2Terrain(); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); }
internal static void Draw() { PGUIStyle.StartNodeGUI(); TerrainEditData data = TerrainCenter.editData; data.currentSelect = Selection.activeTransform; BuildIcons(); if ((data.currentSelect != null && Selection.activeInstanceID != data.terrainSelectId) || (data.unityTerrain != null && TerrainCenter.menuToolBar != 0) || (TerrainCenter.menuToolBar != 3 && data.previewer != null)) { data.InitSelection(); } GUILayout.BeginHorizontal("box"); TerrainCenter.menuToolBar = GUILayout.Toolbar(TerrainCenter.menuToolBar, menuIcon, GUILayout.Width(240), GUILayout.Height(18)); GUILayout.FlexibleSpace(); GUILayout.Label("Controls", GUILayout.Width(52)); if (GUILayout.Button(TerrainCenter.Activated ? "Activated" : "Deactivated")) { TerrainCenter.Activated = !TerrainCenter.Activated; } GUILayout.EndHorizontal(); if (data.currentSelect != null && TerrainCenter.Activated) { TerrainObject to = data.currentSelect.GetComponent <TerrainObject>(); if (data.currentSelect.GetComponent <TerrainPart>()) { Selection.activeTransform = data.currentSelect.parent; } Renderer[] rendererPart = data.currentSelect.GetComponentsInChildren <Renderer>(); if (to != null && (!to.material || !to.mesh)) { if (rendererPart.Length == 0) { to.material = data.currentSelect.GetComponent <Renderer>().sharedMaterial; to.mesh = data.currentSelect.GetComponent <MeshFilter>(); } else { to.material = rendererPart[0].sharedMaterial; to.mesh = rendererPart[0].gameObject.GetComponent <MeshFilter>(); } } else if (to != null && to.material) { if (data.nbrTerrainObject == 1 && to.master != 1) { data.isMaster = false; } else if (data.nbrTerrainObject == 1 && to.master == 1 && data.isMaster == false && data.initMaster == false) { data.isMaster = true; data.initMaster = true; } Material mat = rendererPart.Length > 0 ? rendererPart[0].sharedMaterial : data.currentSelect.GetComponent <Renderer>().sharedMaterial; if (to.material != mat) { to.material = mat; EditorUtility.SetSelectedRenderState(to.GetComponent <Renderer>(), EditorSelectedRenderState.Highlight); } } if (data.currentSelect.GetComponent <TerrainObject>()) { int countChild = data.currentSelect.transform.childCount; if (countChild > 0) { data.childRenderers = data.currentSelect.GetComponentsInChildren <Renderer>(); } } if (subEditors[TerrainCenter.menuToolBar] != null) { subEditors[TerrainCenter.menuToolBar].OnGUI(); } } else { if (data.currentSelect != null && data.currentSelect.GetComponent <TerrainObject>() != null && data.currentSelect.GetComponent <TerrainObject>().material != null) { Renderer[] renderPart = data.currentSelect.GetComponentsInChildren <Renderer>(); if (renderPart.Length == 0) { EditorUtility.SetSelectedRenderState(data.currentSelect.GetComponent <Renderer>(), EditorSelectedRenderState.Highlight | EditorSelectedRenderState.Wireframe); } else { foreach (var r in renderPart) { EditorUtility.SetSelectedRenderState(r, EditorSelectedRenderState.Highlight | EditorSelectedRenderState.Wireframe); } } } GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(PResourceManager.LoadTexture("Terrain/Waiting.png")); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } PGUIStyle.EndNodeGUI(); }
private void PickMaterials() { TerrainObject to = currentSelect.GetComponent <TerrainObject>(); if (to.material != null && to.material.HasProperty("_Control") && to.material.HasProperty("_Splat0") && to.material.HasProperty("_Splat1")) { EditorGUILayout.Space(); InitPencil(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal("box", GUILayout.Width(340)); GUILayout.FlexibleSpace(); _selectProcedural = GUILayout.SelectionGrid(_selectProcedural, _textures, 6, "gridlist", GUILayout.Width(340), GUILayout.Height(60)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Box(PGUIStyle.BorderColor0, GUILayout.ExpandWidth(true), GUILayout.Height(1)); GUILayout.Label("Add / Replace / Substrances Update", PGUIStyle.nodeLabelBold); EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(GUILayout.Width(340), GUILayout.Height(20)); for (int i = 0; i < 4; i++) { if (to.material.HasProperty("_Splat" + i)) { if (GUILayout.Button(PResourceManager.LoadTexture("Terrain/up.png"), GUILayout.Width(53))) { if (_procedualAdd == null && _materialAdd == null && _procedual != null) { _procedualAdd = _procedual; } if (_procedualAdd != null) { to.material.SetTexture("_Splat" + i, _procedualAdd.GetTexture("_MainTex")); if (to.material.HasProperty("_BumpSpat" + i)) { to.material.SetTexture("_BumpSplat" + i, _procedualAdd.GetTexture("_BumpMap")); } } else if (_materialAdd != null) { to.material.SetTexture("_Splat" + i, _materialAdd); } _selectProcedural = i; _procedualAdd = null; _materialAdd = null; editData.InitSelection(); } } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.Box(PGUIStyle.BorderColor0, GUILayout.ExpandWidth(true), GUILayout.Height(1)); GUILayout.Space(5); string _assetName = AssetDatabase.GetAssetPath(to.material.GetTexture("_Splat" + _selectProcedural)); SubstanceImporter importer = AssetImporter.GetAtPath(_assetName) as SubstanceImporter; if (importer != null) { ProceduralMaterial[] _promats = importer.GetMaterials(); foreach (ProceduralMaterial t in _promats) { if (t.name + "Diffuse" == to.material.GetTexture("_Splat" + _selectProcedural).name) { _procedual = t; } } GUILayout.Space(5); GUILayout.Box(PGUIStyle.BorderColor0, GUILayout.ExpandWidth(true), GUILayout.Height(1)); } else { _procedual = null; } EditorGUILayout.Space(); EditorGUILayout.Space(); GUILayout.Space(5); GUILayout.BeginHorizontal(); GUILayout.Label("Material Type", GUILayout.Width(100)); _materialType = (TerrianMaterialType) EditorGUILayout.EnumPopup("", _materialType, GUILayout.Width(240)); GUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (_materialType != TerrianMaterialType.Classic) { GUILayout.Label("Substances to add:"); _materialAdd = null; _procedualAdd = EditorGUILayout.ObjectField(_procedualAdd, typeof(ProceduralMaterial), true, GUILayout.Width(220)) as ProceduralMaterial; } else { GUILayout.Label("Texture to add:"); _procedualAdd = null; _materialAdd = EditorGUILayout.ObjectField(_materialAdd, typeof(Texture2D), true, GUILayout.Width(220)) as Texture; } GUILayout.FlexibleSpace(); EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); if (_procedual != null) { GUILayout.Label("Modify", PGUIStyle.nodeLabelBold); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos, GUILayout.Width(350), GUILayout.Height(296)); Substance(); EditorGUILayout.EndScrollView(); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } else { ClassicMaterial(); } } else { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("Please, select the Pure Terrain Object", PGUIStyle.nodeLabelBold); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } }