public static int GetCurrentLOD(this LODGroup lodGroup, Camera camera = null) { LOD[] lods = lodGroup.GetLODs(); float relativeHeight = lodGroup.GetRelativeHeight(camera ?? Camera.current); int lodIndex = GetCurrentLOD(lods, lodGroup.GetMaxLOD(), relativeHeight, camera); return(lodIndex); }
void OnGUI_CurrentObj() { var obj = Selection.activeGameObject; if (obj == null) { return; } LODGroup group = obj.GetComponent <LODGroup> (); if (group == null) { return; } if (cam == null) { return; } ShowTitle("当前物体"); var sceneDis = Vector3.Distance(group.transform.TransformPoint(group.localReferencePoint), sceneCam.transform.position); var sceneReHeight = group.GetRelativeHeight(sceneCam); GUILayout.BeginHorizontal(); GUILayout.Label("Scene", GUILayout.Width(columnWidth)); GUILayout.Label(string.Format("占屏比:{0}", sceneReHeight.ToString("f2")), GUILayout.Width(columnWidth)); GUILayout.Label(string.Format("距离:{0}", sceneDis.ToString("f2")), GUILayout.Width(columnWidth)); GUILayout.EndHorizontal(); var lods = group.GetLODs(); for (int i = 0; i < lods.Length; i++) { var lod = lods [i]; var dis = LODGroupExtensions.RelativeHeightToDistance(cam, lod.screenRelativeTransitionHeight, group); dis *= Bias; GUILayout.BeginHorizontal(); GUILayout.Label(string.Format("LOD {0}", i), GUILayout.Width(columnWidth)); GUILayout.Label(string.Format("占屏比:{0}", lod.screenRelativeTransitionHeight.ToString("f2")), GUILayout.Width(columnWidth)); GUILayout.Label(string.Format("距离:{0}", dis.ToString("f2")), GUILayout.Width(columnWidth)); GUILayout.EndHorizontal(); } }