zoukankan      html  css  js  c++  java
  • Unity Collider Bounds and extents 调试

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class TestPhyCollider : MonoBehaviour
    {
        public Collider tree;
    
        public Vector3 scale = new Vector3(0.3f, 0.3f, 0.3f);
        public bool isExtent;
        public bool isSize;
    
        public void OnCollisionEnter(Collision other)
        {
        }
    
        public void OnDrawGizmos()
        {
            Gizmos.DrawCube(tree.bounds.center, scale);
    
            Gizmos.color = Color.blue;
            Gizmos.DrawCube(tree.bounds.max, scale);
            Gizmos.color = Color.yellow;
            Gizmos.DrawCube(tree.bounds.min, scale);
    
            if (isExtent)
            {
                Gizmos.color = Color.magenta;
                Gizmos.DrawCube(tree.bounds.center, tree.bounds.extents);
            }
    
            if (isSize)
            {
                Gizmos.color = Color.gray;
                Gizmos.DrawCube(tree.bounds.center, tree.bounds.size);
            }
    
            //下面一个点
            var center = tree.bounds.center;
            center.y = tree.bounds.min.y;
            Gizmos.DrawCube(center, scale);
            
            //后面一个点
            var center2 = tree.bounds.center;
            center2.z = tree.bounds.min.z;
            Gizmos.DrawCube(center2, scale);
            
            //前面一个点
            var center3 = tree.bounds.center;
            center3.z = tree.bounds.max.z;
            Gizmos.DrawCube(center3, scale);
            
            //左边一个点
            var center4 = tree.bounds.center;
            center4.x = tree.bounds.min.x;
            Gizmos.DrawCube(center4, scale);
            
            //右边一个点
            var center5 = tree.bounds.center;
            center5.x = tree.bounds.max.x;
            Gizmos.DrawCube(center5, scale);
            
        }
    }
    

      

  • 相关阅读:
    百斯特
    C++
    转载
    转载+整理
    转载
    转载
    转载
    C++
    转载
    CodeForces
  • 原文地址:https://www.cnblogs.com/plateFace/p/14177395.html
Copyright © 2011-2022 走看看