void OnGUI() { EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(GUILayout.Height(Screen.width - 40)); EditorGUILayout.LabelField(""); EditorGUILayout.EndVertical(); Rect rectangle = GUILayoutUtility.GetLastRect(); EditorGUILayout.EndHorizontal(); { rectangle.y = (rectangle.height - rectangle.width) / 2; rectangle.height = rectangle.width; GUI.DrawTexture(rectangle, Resources.Load("Icon/pixyz_banner", typeof(Texture2D)) as Texture2D); //PiXYZUtils.drawGroupBox(rectangle, "test"); } showLicenseInfos(false); GUILayout.FlexibleSpace(); EditorGUILayout.BeginVertical(); { GUIStyle centeredBold = new GUIStyle(EditorStyles.boldLabel); centeredBold.alignment = TextAnchor.UpperCenter; EditorGUILayout.LabelField("Plugin version: " + PiXYZ4UnityWrapper.getVersion(), centeredBold); } { GUIStyle boldRich = new GUIStyle(EditorStyles.boldLabel); boldRich.alignment = TextAnchor.MiddleCenter; boldRich.normal.textColor = Color.blue; //GUI.Label(new Rect(0, Screen.height * 3 / 4 - 10, Screen.width, Screen.height / 4), "Click to see Terms & Conditions", boldRich); string str = "Click to see Terms & Conditions"; TextGenerationSettings settings = new TextGenerationSettings(); settings.fontSize = boldRich.fontSize; settings.fontStyle = boldRich.fontStyle; settings.font = boldRich.font; settings.color = boldRich.normal.textColor; settings.pivot = Vector2.zero; if (GUILayout.Button(str, boldRich)) { Application.OpenURL("https://www.pixyz-software.com/general-and-products-terms-and-conditions/"); } TextGenerator a = new TextGenerator(); Rect buttonRect = GUILayoutUtility.GetLastRect(); EditorGUIUtility.AddCursorRect(buttonRect, MouseCursor.Link); Rect underlineRect = new Rect(buttonRect); underlineRect.width = a.GetPreferredWidth(str, settings); underlineRect.x = Screen.width / 2 - underlineRect.width / 2; underlineRect.y += underlineRect.height - 2; underlineRect.height = 1; PiXYZUtils.GUIDrawRect(underlineRect, Color.blue); } { GUIStyle italic = new GUIStyle(); italic.fontStyle = FontStyle.Italic; italic.alignment = TextAnchor.MiddleCenter; italic.fontSize = 10; italic.wordWrap = true; EditorGUILayout.LabelField("PiXYZ Software solutions are edited by Metaverse Technologies France", italic); } EditorGUILayout.EndVertical(); }
public void show(SerializedObject serializedObject, GameObject gameObject = null) { GUIStyle sliderStyle = new GUIStyle(GUI.skin.horizontalSlider); GUIStyle thumbStyle = new GUIStyle(GUI.skin.horizontalSliderThumb); Texture2D tex = new Texture2D(2, 300); var fillColorArray = tex.GetPixels(); for (var i = 0; i < fillColorArray.Length; ++i) { fillColorArray[i] = Color.black; } tex.SetPixels(fillColorArray); tex.Apply(); sliderStyle.normal.background = null; thumbStyle.fixedWidth = 1f; thumbStyle.fixedHeight = 1f; thumbStyle.normal.background = null; int maxLod = serializedObject.FindProperty("settings").FindPropertyRelative("lodSettingCount").intValue; Rect sliderRect = EditorGUILayout.GetControlRect(); sliderRect.height = 30; Rect labelRect = new Rect(sliderRect); float lodValue = 1f; float nextLodValue = PiXYZLoDSettingsEditor.getIndexProperty(0, serializedObject, "startLod", "settings.lodSettings").floatValue; float start = 0; for (int i = 0; i < maxLod; i++) { labelRect.width = sliderRect.width * (lodValue - nextLodValue); labelRect.position = new Vector2(sliderRect.position.x + start, sliderRect.position.y); if (Event.current.type == EventType.MouseUp && nextLodValue < currentValue && currentValue < lodValue) { selectedLOD = i; } if (i < maxLod) { PiXYZUtils.GUIDrawRect(labelRect, selectedLOD == i ? highlightColors[i] : normalColors[i], highlightColors[highlightColors.Length - 1], selectedLOD == i ? 2 : 0, " LOD " + i + "\n " + (Math.Round(lodValue * 100)) + "%", TextAnchor.MiddleLeft); } Rect movePos = new Rect(labelRect.x + labelRect.width - 5, labelRect.y, 10, labelRect.height); EditorGUIUtility.AddCursorRect(movePos, MouseCursor.ResizeHorizontal); if (movePos.Contains(Event.current.mousePosition) && (Event.current.type == EventType.MouseDown && Event.current.button == 0)) { grabbing = i; } else if (grabbing != -1 && Event.current.type == EventType.MouseUp && Event.current.button == 0) { if (gameObject != null) { foreach (LODGroup lodGroup in gameObject.GetComponentsInChildren <LODGroup>()) { LOD[] lods = lodGroup.GetLODs(); lods[grabbing].screenRelativeTransitionHeight = PiXYZLoDSettingsEditor.getIndexProperty(grabbing, serializedObject, "startLod", "settings.lodSettings").floatValue; lodGroup.SetLODs(lods); } } grabbing = -1; } lodValue = nextLodValue; nextLodValue = i < maxLod - 1 ? PiXYZLoDSettingsEditor.getIndexProperty(i + 1, serializedObject, "startLod", "settings.lodSettings").floatValue : -1; start += labelRect.width; } labelRect.width = sliderRect.width - start; labelRect.position = new Vector2(sliderRect.position.x + start, sliderRect.position.y); PiXYZUtils.GUIDrawRect(labelRect, normalColors[normalColors.Length - 1], highlightColors[highlightColors.Length - 1], 0, " Culled\n " + (Math.Round(lodValue * 100)) + "%", TextAnchor.MiddleLeft); currentValue = GUI.Slider(sliderRect, currentValue, 0, 1, 0, sliderStyle, thumbStyle, true, 0); if (grabbing != -1) { if (grabbing == 2 && currentValue < 0.01f) { return; } else if (grabbing == 0 && currentValue > 0.99f) { return; } else if (grabbing > 0 && currentValue > PiXYZLoDSettingsEditor.getIndexProperty(grabbing - 1, serializedObject, "startLod", "settings.lodSettings").floatValue - 0.01f) { return; } else if (grabbing < maxLod - 1 && currentValue < PiXYZLoDSettingsEditor.getIndexProperty(grabbing + 1, serializedObject, "startLod", "settings.lodSettings").floatValue + 0.01f) { return; } PiXYZLoDSettingsEditor.getIndexProperty(grabbing, serializedObject, "startLod", "settings.lodSettings").floatValue = currentValue <= 0f?1f: currentValue; } }