當前位置: 首頁>>代碼示例>>C#>>正文


C# Bounds.ToString方法代碼示例

本文整理匯總了C#中UnityEngine.Bounds.ToString方法的典型用法代碼示例。如果您正苦於以下問題:C# Bounds.ToString方法的具體用法?C# Bounds.ToString怎麽用?C# Bounds.ToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UnityEngine.Bounds的用法示例。


在下文中一共展示了Bounds.ToString方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RenderBoundsGizmo

    static void RenderBoundsGizmo(DrawBoundsGizmo boundsGizmo, GizmoType gizmoType) {
        Gizmos.color = boundsGizmo.color;

        // get renderer bonding box
        var bounds = new Bounds();
        var initBound = false;
        if (UnityUtility.GetBoundWithChildren(boundsGizmo.transform, ref bounds, ref initBound)) {
            if (boundsGizmo.drawCube) {
                Gizmos.DrawWireCube(bounds.center, bounds.size);
            }
            if (boundsGizmo.drawSphere) {
                Gizmos.DrawWireSphere(bounds.center, Mathf.Max(Mathf.Max(bounds.extents.x, bounds.extents.y), bounds.extents.z));
            }
        }

        if (boundsGizmo.showCenter) {
            Gizmos.DrawLine(new Vector3(bounds.min.x, bounds.center.y, bounds.center.z), new Vector3(bounds.max.x, bounds.center.y, bounds.center.z));
            Gizmos.DrawLine(new Vector3(bounds.center.x, bounds.min.y, bounds.center.z), new Vector3(bounds.center.x, bounds.max.y, bounds.center.z));
            Gizmos.DrawLine(new Vector3(bounds.center.x, bounds.center.y, bounds.min.z), new Vector3(bounds.center.x, bounds.center.y, bounds.max.z));
        }

        // UnityEditor code draws a label with the dimensions of the bounding box
        Handles.BeginGUI();
        var view = SceneView.currentDrawingSceneView;
        var pos = view.camera.WorldToScreenPoint(bounds.center);
        var size = GUI.skin.label.CalcSize(new GUIContent(bounds.ToString()));
        GUI.Label(new Rect(pos.x - (size.x / 2), -pos.y + view.position.height + 4, size.x, size.y), bounds.ToString());
        Handles.EndGUI();
    }
開發者ID:Maxii,項目名稱:CodeEnv.Master,代碼行數:29,代碼來源:DrawBoundsGizmoEditor.cs


注:本文中的UnityEngine.Bounds.ToString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。