当前位置: 首页>>代码示例>>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;未经允许,请勿转载。