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


C# UnityEngine.BoxCollider類代碼示例

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


BoxCollider類屬於UnityEngine命名空間,在下文中一共展示了BoxCollider類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnStart

        public override void OnStart(StartState state)
        {
            if (HighLogic.LoadedSceneIsFlight)
            {

                if (escapeHatch == null)
                {
                    escapeHatch = new GameObject("EscapeHatch");
                    escapeHatch.tag = "Airlock";
                    escapeHatch.layer = 21;
                    escapeHatch.transform.parent = this.part.transform;
                    escapeHatch.transform.localEulerAngles = new Vector3(0, 0, 0);
                    escapeHatch.transform.localPosition = new Vector3(0, 0, 0);

                    escapeHatch.AddComponent<BoxCollider>();
                    escapeHatchCollider = escapeHatch.GetComponent<BoxCollider>();
                    escapeHatchCollider.size = new Vector3(0.25f, 0.25f, 0.25f);
                    escapeHatchCollider.isTrigger = true;

                    this.part.airlock = escapeHatch.transform;
                    print("[TakeCommand] added escape hatch to " + this.part.name + " (" + this.part.GetInstanceID() + ")");

                    // Disable it for now until we need it
                    escapeHatch.collider.enabled = true;
                }

            }
            base.OnStart(state);
        }
開發者ID:Kerbas-ad-astra,項目名稱:TakeCommand,代碼行數:29,代碼來源:TakeCommand.cs

示例2: OnDrawGizmos

            private void OnDrawGizmos()
            {
                if (_shouldRender == false)
                    return;

                if (this._collider == null)
                {
                    this._collider = this.gameObject.transform.GetComponent<BoxCollider>();
                }

                if (this._collider == null)
                {
                    return;
                }

                if (this._shouldRenderOnlyWhenSelected == true)
                {
                    if (UnityEditor.Selection.activeTransform == null)
                    {
                        return;
                    }

                    if (UnityEditor.Selection.activeTransform.GetComponentsInChildren<Transform>(true).Contains(this.transform) == false)
                    {
                        return;
                    }
                }

                Matrix4x4 gizmoMatrix = Matrix4x4.TRS(this.transform.position, this.transform.rotation, this.transform.lossyScale);
                Gizmos.matrix = gizmoMatrix;
                Gizmos.color = this._volumeColor;

                Gizmos.DrawCube(this._collider.center, this._collider.size);
            }
開發者ID:supertms,項目名稱:WolongYin,代碼行數:34,代碼來源:EditorVisibleVolume.cs

示例3: UnityBoxCollider

 public UnityBoxCollider(GameObject obj)
 {
     box = obj.GetComponent<BoxCollider>();
     if (null == box) {
         box = obj.AddComponent<BoxCollider>();
     }
 }
開發者ID:ZackGill,項目名稱:Uniject,代碼行數:7,代碼來源:UnityBoxCollider.cs

示例4: Awake

 void Awake()
 {
     //punchParticles = GetComponent<ParticleSystem> ();
     punchAudio = GetComponent<AudioSource> ();
     boxCollider = GetComponent<BoxCollider> ();
     //anim = GetComponent<Animation> ();
 }
開發者ID:enro92,項目名稱:Unity,代碼行數:7,代碼來源:PlayerPunch.cs

示例5: Start

 protected override void Start()
 {
     base.Start();
     laserMesh = transform.FindChild("Laser").gameObject.GetComponent<MeshRenderer>();
     laserCollider = transform.FindChild("Laser").gameObject.GetComponent<BoxCollider>();
     mirrorSync = GetComponent<spt_mirrorSync>();
 }
開發者ID:misterplatt,項目名稱:Shackle-170,代碼行數:7,代碼來源:spt_mirror.cs

示例6: Awake

 void Awake()
 {
     cl = (GetComponent<BoxCollider>()) ?? gameObject.AddComponent<BoxCollider>();
     //cl.center = new Vector3(0,(float)depth/2-height,0);
     //cl.size = new Vector3(2048f,(float)depth,2048f);
     cl.isTrigger = true;
 }
開發者ID:evan-erdos,項目名稱:pathways,代碼行數:7,代碼來源:WaterPhysics.cs

示例7: OnTriggerExit

        protected override void OnTriggerExit( Collider other )
        {
            base.OnTriggerExit(other);

            if( !enabled || !ShouldAffect(other) )
                return;

            Rigidbody rigidbody = other.GetComponent<Rigidbody>();

            if( rigidbody == null )
                return;

            if( boxCollider == null )
                boxCollider = GetComponent<BoxCollider>();

            Vector3 position = transform.InverseTransformPoint( other.transform.position );

            if( affectX && Mathf.Abs( position.x * 2 ) >= boxCollider.size.x )
            {
                position.x = -position.x;
            }

            if( affectY && Mathf.Abs( position.y * 2 ) >= boxCollider.size.y )
            {
                position.y = -position.y;
            }

            if( affectZ && Mathf.Abs( position.z * 2 ) >= boxCollider.size.z )
            {
                position.z = -position.z;
            }

            rigidbody.MovePosition( transform.TransformPoint(position) );
        }
開發者ID:willstall,項目名稱:FPS_0,代碼行數:34,代碼來源:WrapForceField.cs

示例8: Awake

        private void Awake()
        {
            // Create frictionless physmaterial for walls
            var material = new PhysicMaterial("Frictionless");
            material.staticFriction = 0f;
            material.dynamicFriction = 0f;
            material.frictionCombine = PhysicMaterialCombine.Minimum;
            material.bounceCombine = PhysicMaterialCombine.Minimum;
            material.bounciness = 0f;

            var surfaces = new BoxCollider[6];
            for (var i = 0; i < 6; i++)
            {
                var obj = new GameObject();
                obj.transform.SetParent(transform, false);
                var collider = obj.AddComponent<BoxCollider>();
                collider.sharedMaterial = material;
                surfaces[i] = collider;
            }
            var size = thickness / transform.localScale.magnitude;
            var offset = 0.5f + size / 2f;
            // Floor
            surfaces[0].size = new Vector3(1f, size, 1f);
            surfaces[0].transform.localPosition = new Vector3(0f, -offset, 0f);
            surfaces[0].name = "Floor";

            // Ceiling
            surfaces[1].size = new Vector3(1f, size, 1f);
            surfaces[1].transform.localPosition = new Vector3(0f, offset, 0f);
            surfaces[1].name = "Ceiling";

            // Wall Z-
            surfaces[2].size = new Vector3(1f, 1f, size);
            surfaces[2].transform.localPosition = new Vector3(0f, 0f, -offset);
            surfaces[2].name = "Wall Z-";

            // Wall Z+
            surfaces[3].size = new Vector3(1f, 1f, size);
            surfaces[3].transform.localPosition = new Vector3(0f, 0f, offset);
            surfaces[3].name = "Wall Z+";

            // Wall X-
            surfaces[4].size = new Vector3(size, 1f, 1f);
            surfaces[4].transform.localPosition = new Vector3(-offset, 0f, 0f);
            surfaces[4].name = "Wall X-";

            // Wall X+
            surfaces[5].size = new Vector3(size, 1f, 1f);
            surfaces[5].transform.localPosition = new Vector3(offset, 0f, 0f);
            surfaces[5].name = "Wall X+";

            if (useLayer)
            {
                for (int i = 0; i < surfaces.Length; i++)
                {
                    surfaces[i].gameObject.layer = gameObject.layer;
                }
            }
        }
開發者ID:thebeardphantom,項目名稱:UnityCommonLibrary,代碼行數:59,代碼來源:MakeWorldBounds.cs

示例9: OnStart

 public override void OnStart()
 {
     var currentGameObject = GetDefaultGameObject(targetGameObject.Value);
     if (currentGameObject != prevGameObject) {
         boxCollider = currentGameObject.GetComponent<BoxCollider>();
         prevGameObject = currentGameObject;
     }
 }
開發者ID:dev-celvin,項目名稱:DK,代碼行數:8,代碼來源:GetCenter.cs

示例10: Awake

        void Awake()
        {
            kickParticle = GetComponentInChildren<ParticleSystem> ();

            kickAudio = GetComponent<AudioSource> ();
            boxCollider = GetComponent<BoxCollider> ();
            //anim = GetComponent<Animation> ();
        }
開發者ID:enro92,項目名稱:Unity,代碼行數:8,代碼來源:PlayerKick.cs

示例11: Start

        void Start()
        {
            _sprite = GetComponent<UISprite>();
            _button = GetComponent<UIButton>();
            _collider = GetComponent<BoxCollider>();

            Reset();
        }
開發者ID:PhilipMantrov,項目名稱:JekaMinigames,代碼行數:8,代碼來源:BlankError.cs

示例12: From3DBoxCollider

        public static void From3DBoxCollider(VLSObstructor _obstructor, BoxCollider _collider)
        {
            pntBuffer[3] = (_collider.size * 0.5f);
            pntBuffer[2] = new Vector2(pntBuffer[3].x, -pntBuffer[3].y);
            pntBuffer[1] = new Vector2(-pntBuffer[3].x, -pntBuffer[3].y);
            pntBuffer[0] = new Vector2(-pntBuffer[3].x, pntBuffer[3].y);

            for (int i = 0; i < 4; i++)
                _obstructor.LocalVertex(10000, pntBuffer[i] + (Vector2)_collider.center);
        }
開發者ID:losetear,項目名稱:VLS2D,代碼行數:10,代碼來源:VLSConverter.cs

示例13: Awake

        public void Awake()
        {
            Manager = GameManagerLocator.Manager;

            gameObject.AddComponent<BoxCollider>();

            TriggerCollider = GetComponent<BoxCollider>();

            TriggerCollider.isTrigger = true;
        }
開發者ID:IsaacOfModels,項目名稱:Installation01,代碼行數:10,代碼來源:TriggerVolume.cs

示例14: baseAwake

        protected void baseAwake()
        {
            box = GetComponent<BoxCollider>();
            MeshRenderer mr = GetComponentInChildren<MeshRenderer>();
            meshObj = mr.transform;
            mat = mr.material;

            enabledPos = meshObj.transform.position;
            disabledPos = enabledPos;
            disabledPos.y -= .015f;
        }
開發者ID:Beanalby,項目名稱:1GameAMonth14,代碼行數:11,代碼來源:RailSection.cs

示例15: Start

        protected virtual void Start()
        {
            // Make sure the Tagalong object has a BoxCollider.
            tagalongCollider = GetComponent<BoxCollider>();

            // Get the Interpolator component and set some default parameters for
            // it. These parameters can be adjusted in Unity's Inspector as well.
            interpolator = gameObject.GetComponent<Interpolator>();
            interpolator.SmoothLerpToTarget = SmoothMotion;
            interpolator.SmoothPositionLerpRatio = SmoothingFactor;
        }
開發者ID:CameronVetter,項目名稱:HoloToolkit-Unity,代碼行數:11,代碼來源:SimpleTagalong.cs


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