• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# UnityEngine.BoxCollider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中UnityEngine.BoxCollider的典型用法代码示例。如果您正苦于以下问题:C# BoxCollider类的具体用法?C# BoxCollider怎么用?C# BoxCollider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BoxCollider类属于UnityEngine命名空间,在下文中一共展示了BoxCollider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: Init

        private void Init()
        {
            if (_isInit)
                return;

            _collider = GetComponent<BoxCollider>();
            _sprite = GetComponent<UISprite>();
            _positionStart = transform.localPosition;

            _isInit = true;
        }
开发者ID:PhilipMantrov,项目名称:JekaMinigames,代码行数:11,代码来源:Person.cs


示例17: Init

        private void Init()
        {
            if (_isInit)
                return;

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

            _isInit = true;
        }
开发者ID:PhilipMantrov,项目名称:JekaMinigames,代码行数:11,代码来源:BuildObject.cs


示例18: FromCollider

 public static AABBox FromCollider(BoxCollider c, bool local = false)
 {
     if(local)
     {
         return new AABBox(c.center, c.size);
     }
     else
     {
         return new AABBox(c.bounds);
     }
 }
开发者ID:XianWorld,项目名称:spacepuppy-unity-framework,代码行数:11,代码来源:AABBox.cs


示例19: Init

        public void Init(Func<bool> shouldPauseCb, ITimeProvider time, WeaponConfig weaponConfig, BaseShip owner, Rect levelBounds )
        {
            base.Init( shouldPauseCb, time);
            WeaponConfig = weaponConfig;
            Owner = owner;
            LevelBounds = levelBounds;

            ProjectileCollider = gameObject.As< BoxCollider >();

            if ( ProjectileCollider == null )
                throw new MissingComponentException("Box collider is not present on Projectile");
        }
开发者ID:forwolk,项目名称:HamburgTest,代码行数:12,代码来源:BaseProjectile.cs


示例20: Init

        private void Init()
        {
            if (_isInit)
                return;

            _collider = GetComponent<BoxCollider>();
            _sprite = GetComponent<UISprite>();
            _startPosition = transform.position;
            _currentCell = null;

            _isInit = true;
        }
开发者ID:PhilipMantrov,项目名称:JekaMinigames,代码行数:12,代码来源:Plate.cs



注:本文中的UnityEngine.BoxCollider类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UnityEngine.BoxCollider2D类代码示例发布时间:2022-05-26
下一篇:
C# UnityEngine.Bounds类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap