Esempio n. 1
0
        private void initContactBones()
        {
            _contactBones = new ContactBone[NUM_FINGERS * BONES_PER_FINGER + 1];
            _handContactBoneMapFunctions = new BoneMapFunc[NUM_FINGERS * BONES_PER_FINGER + 1];

            // Finger bones
            for (int fingerIndex = 0; fingerIndex < NUM_FINGERS; fingerIndex++)
            {
                for (int jointIndex = 0; jointIndex < BONES_PER_FINGER; jointIndex++)
                {
                    GameObject contactBoneObj = new GameObject("Contact Fingerbone", typeof(CapsuleCollider), typeof(Rigidbody), typeof(ContactBone));
                    contactBoneObj.layer = manager.contactBoneLayer;

                    Bone bone = _unwarpedHandData.Fingers[fingerIndex]
                                .Bone((Bone.BoneType)(jointIndex) + 1);        // +1 to skip first bone.
                    int boneArrayIndex = fingerIndex * BONES_PER_FINGER + jointIndex;
                    contactBoneObj.transform.position = bone.Center.ToVector3();
                    contactBoneObj.transform.rotation = bone.Rotation.ToQuaternion();

                    // Remember the method we used to calculate this bone position from
                    // a Leap Hand for later.
                    int fingerIndexCopy = fingerIndex;
                    int jointIndexCopy  = jointIndex;
                    _handContactBoneMapFunctions[boneArrayIndex] = (Leap.Hand hand,
                                                                    out Vector3 targetPosition,
                                                                    out Quaternion targetRotation) => {
                        Bone theBone = hand.Fingers[fingerIndexCopy].Bone((Bone.BoneType)(jointIndexCopy + 1));
                        targetPosition = theBone.Center.ToVector3();
                        targetRotation = theBone.Rotation.ToQuaternion();
                    };

                    CapsuleCollider capsule = contactBoneObj.GetComponent <CapsuleCollider>();
                    capsule.direction = 2;
                    capsule.radius    = bone.Width * 0.5f;
                    capsule.height    = bone.Length + bone.Width;
                    capsule.material  = defaultContactBoneMaterial;

                    ContactBone contactBone = initContactBone(bone, contactBoneObj, boneArrayIndex, capsule);

                    contactBone.lastTargetPosition = bone.Center.ToVector3();
                }
            }

            // Palm bone
            {
                // Palm is attached to the third metacarpal and derived from it.
                GameObject contactBoneObj = new GameObject("Contact Palm Bone", typeof(BoxCollider), typeof(Rigidbody), typeof(ContactBone));

                Bone bone           = _unwarpedHandData.Fingers[(int)Finger.FingerType.TYPE_MIDDLE].Bone(Bone.BoneType.TYPE_METACARPAL);
                int  boneArrayIndex = NUM_FINGERS * BONES_PER_FINGER;
                contactBoneObj.transform.position = _unwarpedHandData.PalmPosition.ToVector3();
                contactBoneObj.transform.rotation = _unwarpedHandData.Rotation.ToQuaternion();

                // Remember the method we used to calculate the palm from a Leap Hand for later.
                _handContactBoneMapFunctions[boneArrayIndex] = (Leap.Hand hand,
                                                                out Vector3 targetPosition,
                                                                out Quaternion targetRotation) => {
                    targetPosition = hand.PalmPosition.ToVector3();
                    targetRotation = hand.Rotation.ToQuaternion();
                };

                BoxCollider box = contactBoneObj.GetComponent <BoxCollider>();
                box.center   = new Vector3(_unwarpedHandData.IsLeft ? -0.005f : 0.005f, bone.Width * -0.3f, -0.01f);
                box.size     = new Vector3(bone.Length, bone.Width, bone.Length);
                box.material = defaultContactBoneMaterial;

                initContactBone(null, contactBoneObj, boneArrayIndex, box);
            }

            // Constrain the bones to each other to prevent separation.
            addContactBoneJoints();
        }
Esempio n. 2
0
        //
        public void SetAgentMode(string mode)
        {
            string whichMode;

            whichMode = mode.ToLower();

            FirstPersonCharacterCull fpcc = m_Camera.GetComponent <FirstPersonCharacterCull>();

            //determine if we are in Tall or Bot mode (or other modes as we go on)
            if (whichMode == "tall")
            {
                //toggle FirstPersonCharacterCull
                fpcc.SwitchRenderersToHide(whichMode);

                VisibilityCapsule            = TallVisCap;
                m_CharacterController.center = new Vector3(0, 0, 0);
                m_CharacterController.radius = 0.2f;
                m_CharacterController.height = 1.8f;

                CapsuleCollider cc = this.GetComponent <CapsuleCollider>();
                cc.center = m_CharacterController.center;
                cc.radius = m_CharacterController.radius;
                cc.height = m_CharacterController.height;

                m_Camera.GetComponent <PostProcessVolume>().enabled = false;
                m_Camera.GetComponent <PostProcessLayer>().enabled  = false;

                //camera position
                m_Camera.transform.localPosition = new Vector3(0, 0.675f, 0);

                //camera FOV
                m_Camera.fieldOfView = 90f;

                //set camera stand/crouch local positions for Tall mode
                standingLocalCameraPosition  = m_Camera.transform.localPosition;
                crouchingLocalCameraPosition = m_Camera.transform.localPosition + new Vector3(0, -0.675f, 0);// bigger y offset if tall
            }

            else if (whichMode == "bot")
            {
                //toggle FirstPersonCharacterCull
                fpcc.SwitchRenderersToHide(whichMode);

                VisibilityCapsule            = BotVisCap;
                m_CharacterController.center = new Vector3(0, -0.45f, 0);
                m_CharacterController.radius = 0.175f;
                m_CharacterController.height = 0.9f;

                CapsuleCollider cc = this.GetComponent <CapsuleCollider>();
                cc.center = m_CharacterController.center;
                cc.radius = m_CharacterController.radius;
                cc.height = m_CharacterController.height;

                m_Camera.GetComponent <PostProcessVolume>().enabled = true;
                m_Camera.GetComponent <PostProcessLayer>().enabled  = true;

                //camera position
                m_Camera.transform.localPosition = new Vector3(0, -0.0312f, 0);

                //camera FOV
                m_Camera.fieldOfView = 60f;

                //set camera stand/crouch local positions for Tall mode
                standingLocalCameraPosition  = m_Camera.transform.localPosition;
                crouchingLocalCameraPosition = m_Camera.transform.localPosition + new Vector3(0, -0.2206f, 0);//smaller y offset if Bot

                // limit camera from looking too far down
                this.horizonAngles = new float[] { 30.0f, 0.0f, 330.0f };
            }
        }
Esempio n. 3
0
 private void Start()
 {
     m_RigidBody = GetComponent <Rigidbody>();
     m_Capsule   = GetComponent <CapsuleCollider>();
     mouseLook.Init(transform, cam.transform);
 }
 void Awake()
 {
     //anim = GetComponent <Animator> ();
     capsuleCollider = GetComponent <CapsuleCollider> ();
     currentHealth   = startingHealth;
 }
Esempio n. 5
0
 void Stop()
 {
     Destroy(m_dummyObject);
     m_dummyObject  = null;
     m_dummyCapsule = null;
 }
        public void Init()
        {
            // this method is called on the ThirdPersonController or TopDownController - Start

            animator     = GetComponent <Animator>();
            tpCamera     = v3rdPersonCamera.instance;
            hud          = vHUDController.instance;
            meleeManager = GetComponent <vMeleeManager>();
            // create a offset pivot to the character, to align camera position when transition to ragdoll
            var hips = animator.GetBoneTransform(HumanBodyBones.Hips);

            offSetPivot = Vector3.Distance(transform.position, hips.position);

            if (tpCamera != null)
            {
                tpCamera.offSetPlayerPivot = offSetPivot;
                tpCamera.target            = transform;
            }

            if (hud == null)
            {
                Debug.LogWarning("Invector : Missing HUDController, please assign on ThirdPersonController");
            }

            // prevents the collider from slipping on ramps
            frictionPhysics                 = new PhysicMaterial();
            frictionPhysics.name            = "frictionPhysics";
            frictionPhysics.staticFriction  = 1f;
            frictionPhysics.dynamicFriction = 1f;

            // default physics
            slippyPhysics                 = new PhysicMaterial();
            slippyPhysics.name            = "slippyPhysics";
            slippyPhysics.staticFriction  = 0f;
            slippyPhysics.dynamicFriction = 0f;

            // rigidbody info
            _rigidbody = GetComponent <Rigidbody>();

            // capsule collider
            _capsuleCollider = GetComponent <CapsuleCollider>();

            // save your collider preferences
            colliderCenter = GetComponent <CapsuleCollider>().center;
            colliderRadius = GetComponent <CapsuleCollider>().radius;
            colliderHeight = GetComponent <CapsuleCollider>().height;

            // health info
            currentHealth = maxHealth;
            currentHealthRecoveryDelay = healthRecoveryDelay;
            currentStamina             = maxStamina;

            // stopmove info
            canMoveForward = true;
            canMoveRight   = true;
            canMoveLeft    = true;
            canMoveBack    = true;

            if (hud == null)
            {
                return;
            }

            hud.damageImage.color = new Color(0f, 0f, 0f, 0f);

            cameraTransform.SendMessage("Init", SendMessageOptions.DontRequireReceiver);
            UpdateHUD();
        }
Esempio n. 7
0
        //private FaceManager face;
        //private SpringManager spring;
        //private RandomWind wind;
        //private IKLookAt lookat;

        void GetComponents()
        {
            animator        = GetComponent <Animator>();
            capsuleCollider = GetComponent <CapsuleCollider>();
            collector       = GetComponentInChildren <ItemCollector>();
        }
Esempio n. 8
0
 public override void OnEnable()
 {
     _target = Target as CapsuleCollider;
 }
Esempio n. 9
0
        public void DrawCollider(Collider collider, bool useWireframe = true,
                                 bool skipMatrixSetup = false)
        {
            if (!skipMatrixSetup)
            {
                PushMatrix();
                RelativeTo(collider.transform);
            }

            if (collider is BoxCollider)
            {
                BoxCollider box = collider as BoxCollider;
                if (useWireframe)
                {
                    DrawWireCube(box.center, box.size);
                }
                else
                {
                    DrawCube(box.center, box.size);
                }
            }
            else if (collider is SphereCollider)
            {
                SphereCollider sphere = collider as SphereCollider;
                if (useWireframe)
                {
                    DrawWireSphere(sphere.center, sphere.radius);
                }
                else
                {
                    DrawSphere(sphere.center, sphere.radius);
                }
            }
            else if (collider is CapsuleCollider)
            {
                CapsuleCollider capsule = collider as CapsuleCollider;
                if (useWireframe)
                {
                    Vector3 capsuleDir;
                    switch (capsule.direction)
                    {
                    case 0: capsuleDir = Vector3.right; break;

                    case 1: capsuleDir = Vector3.up; break;

                    case 2:
                    default: capsuleDir = Vector3.forward; break;
                    }
                    DrawWireCapsule(capsule.center + capsuleDir * (capsule.height / 2F - capsule.radius),
                                    capsule.center - capsuleDir * (capsule.height / 2F - capsule.radius), capsule.radius);
                }
                else
                {
                    Vector3 size = Vector3.zero;
                    size += Vector3.one * capsule.radius * 2;
                    size += new Vector3(capsule.direction == 0 ? 1 : 0,
                                        capsule.direction == 1 ? 1 : 0,
                                        capsule.direction == 2 ? 1 : 0) * (capsule.height - capsule.radius * 2);
                    DrawCube(capsule.center, size);
                }
            }
            else if (collider is MeshCollider)
            {
                MeshCollider mesh = collider as MeshCollider;
                if (mesh.sharedMesh != null)
                {
                    if (useWireframe)
                    {
                        DrawWireMesh(mesh.sharedMesh, Matrix4x4.identity);
                    }
                    else
                    {
                        DrawMesh(mesh.sharedMesh, Matrix4x4.identity);
                    }
                }
            }

            if (!skipMatrixSetup)
            {
                PopMatrix();
            }
        }
 // Use this for initialization
 void Awake()
 {
     rb = GetComponent <Rigidbody>();
     cc = GetComponent <CapsuleCollider>();
 }
Esempio n. 11
0
 private void Awake()
 {
     capCollider = this.transform.GetChild(0).gameObject.GetComponent <CapsuleCollider>();
 }
Esempio n. 12
0
    void Start()
    {
        if (!useCustomAttachNormals)
        {
            attachNormal1 = offset1;
            attachNormal2 = offset2;
        }
        if (attachNormal1.Equals(Vector3.zero))
        {
            attachNormal1 = Vector3.up;
        }
        if (attachNormal2.Equals(Vector3.zero))
        {
            attachNormal2 = Vector3.up;
        }
        attachNormal1 = attachNormal1.normalized;
        attachNormal2 = attachNormal2.normalized;

        GameObject rope = new GameObject("ROPE");

        rope.transform.parent = null;

        joints = 1;
        for (int i = 0; i < jointsPowerTwo; i++)
        {
            joints *= 2;
        }
        parts    = joints - 1;
        segments = new GameObject[parts];

        float ifparts    = 1.0f / ((float)parts);
        float lengthStep = length * ifparts;

        Vector3 pos1 = gameObject.transform.TransformPoint(offset1);
        Vector3 pos2 = other.transform.TransformPoint(offset2);

        for (int i = 0; i < parts; i++)
        {
            segments[i] = new GameObject("ROPE");
            segments[i].transform.parent = rope.transform;

            float lerp = ((float)i) / ((float)(parts));

            segments[i].transform.position = pos1 * (1.0f - lerp) + pos2 * lerp;
            segments[i].transform.LookAt(pos2);

            CapsuleCollider sphere = segments[i].AddComponent <CapsuleCollider>();
            sphere.radius    = radius;
            sphere.direction = 2;
            sphere.height    = 2 * radius + lengthStep;
            sphere.center    = new Vector3(0, 0, lengthStep * 0.5f);
            Rigidbody spherebody = segments[i].AddComponent <Rigidbody>();
            spherebody.drag        = drag;
            spherebody.angularDrag = angularDrag;

            spherebody.mass = ropeMass * ifparts;

            if (noCollide)
            {
                spherebody.detectCollisions = false;
            }
        }

        for (int stride = 1; stride <= joints; stride *= 2)
        {
            for (int i = 0; i < joints; i += stride)
            {
                int        i2     = i + stride;
                GameObject first  = (i == 0) ? gameObject : segments[i - 1];
                GameObject second = (i2 < joints) ? segments[i2 - 1] : other;

                ConfigurableJoint joint = first.AddComponent <ConfigurableJoint>();
                joint.autoConfigureConnectedAnchor = false;

                joint.connectedBody = second.GetComponent <Rigidbody>();

                joint.anchor          = (i == 0) ? offset1 : new Vector3(0, 0, lengthStep);
                joint.connectedAnchor = (i2 == joints) ? offset2 : Vector3.zero;

                // attached to world
                if (joint.connectedBody == null)
                {
                    joint.connectedAnchor = second.transform.TransformPoint(offset2);
                }

                float thisPlay = play;
                if (stride > 1)
                {
                    thisPlay += length;
                    joint.enableCollision = true;
                }

                if (thisPlay > 0f)
                {
                    SoftJointLimit slimit = joint.linearLimit;
                    slimit.limit      = stride * thisPlay / ((float)(joints));
                    slimit.bounciness = bounce;
                    joint.linearLimit = slimit;

                    joint.xMotion = ConfigurableJointMotion.Limited;
                    joint.yMotion = ConfigurableJointMotion.Limited;
                    joint.zMotion = ConfigurableJointMotion.Limited;
                }
                else
                {
                    joint.xMotion = ConfigurableJointMotion.Locked;
                    joint.yMotion = ConfigurableJointMotion.Locked;
                    joint.zMotion = ConfigurableJointMotion.Locked;
                }
            }
        }

        Mesh mesh = new Mesh();

        Vector3[]    vertices  = new Vector3[(meshQuality * parts + 1) * meshRoundness];
        Vector2[]    uvs       = new Vector2[vertices.Length];
        BoneWeight[] weights   = new BoneWeight[vertices.Length];
        int[]        triangles = new int[meshQuality * parts * meshRoundness * 6];

        float circum = 2f * Mathf.PI * radius;

        for (int j = 0; j <= parts; j++)
        {
            for (int q = 0; q < (j == parts ? 1 : meshQuality); q++)
            {
                for (int r = 0; r < meshRoundness; r++)
                {
                    float ang = 2f * Mathf.PI * (float)r / (float)meshRoundness;

                    int vertidx = j * meshQuality * meshRoundness + q * meshRoundness + r;

                    vertices[vertidx].x = Mathf.Sin(ang) * radius;
                    vertices[vertidx].y = Mathf.Cos(ang) * radius;
                    vertices[vertidx].z = length * (float)(j * meshQuality + q) / (float)(parts * meshQuality);

                    uvs[vertidx].x = vertices[vertidx].z / circum;
                    uvs[vertidx].y = (float)r / (float)meshRoundness;

                    float boneIndexer = (float)j + ((float)(q) / (float)meshQuality) + 0.5f;

                    if (boneIndexer < 1)
                    {
                        //vertices[vertidx].z += boneIndexer * 2f * extensionIntoSurface;
                        boneIndexer = 1f - (1f - boneIndexer) * 2f;
                    }
                    if (boneIndexer > parts)
                    {
                        //vertices[vertidx].z += (boneIndexer - (float)(parts-1)) * 2f * extensionIntoSurface;
                        boneIndexer = (boneIndexer - parts) * 2f + parts;
                    }

                    weights[vertidx].boneIndex0 = Mathf.FloorToInt(boneIndexer);

                    weights[vertidx].boneIndex1 = weights[vertidx].boneIndex0 + 1;
                    weights[vertidx].weight1    = boneIndexer % 1f;
                    weights[vertidx].weight0    = 1f - weights[vertidx].weight1;

                    if (weights[vertidx].boneIndex1 >= parts + 1)
                    {
                        weights[vertidx].boneIndex1 = 0;
                        weights[vertidx].weight0    = 1f;
                        weights[vertidx].weight1    = 0f;
                    }

                    if (j < parts)
                    {
                        int circnext = vertidx + 1 - ((r == meshRoundness - 1) ? meshRoundness : 0);
                        int triidx   = vertidx * 6;
                        triangles[triidx]     = vertidx;
                        triangles[triidx + 2] = circnext;
                        triangles[triidx + 1] = vertidx + meshRoundness;
                        triangles[triidx + 3] = circnext;
                        triangles[triidx + 4] = vertidx + meshRoundness;
                        triangles[triidx + 5] = circnext + meshRoundness;
                    }
                }
            }
        }

        Matrix4x4[] bindPoses = new Matrix4x4[parts + 2];

        for (int i = 0; i < parts + 2; i++)
        {
            float pi = Mathf.Max(i - 1, 0f);
            bindPoses[i] = Matrix4x4.TRS(new Vector3(0, 0, -pi * lengthStep), Quaternion.identity, Vector3.one);
        }

        mesh.vertices    = vertices;
        mesh.uv          = uvs;
        mesh.triangles   = triangles;
        mesh.boneWeights = weights;
        mesh.bindposes   = bindPoses;
        mesh.RecalculateNormals();

        bones = new Transform[parts + 2];

        for (int i = 0; i < parts + 2; i++)
        {
            GameObject boneobj = new GameObject("ROPERENDERBONE");
            boneobj.transform.parent = rope.transform;
            bones[i] = boneobj.transform;
        }
        bones[0].transform.parent = gameObject.transform;
        bones[0].localPosition    = offset1;
        bones[0].localRotation    = Quaternion.LookRotation(attachNormal1, Vector3.up);

        GameObject renderobj = new GameObject("ROPERENDER");

        renderobj.transform.parent = rope.transform;

        ropeRenderer                     = renderobj.AddComponent <SkinnedMeshRenderer>();
        ropeRenderer.quality             = UnityEngine.SkinQuality.Bone2;
        ropeRenderer.material            = mat;
        ropeRenderer.sharedMesh          = mesh;
        ropeRenderer.bones               = bones;
        ropeRenderer.updateWhenOffscreen = true;

        /* catmullrom linerenderer
         * ropeRenderer = renderobj.AddComponent<LineRenderer>();
         * ropeRenderer.useWorldSpace = true;
         * ropeRenderer.startWidth = radius * 2f;
         * ropeRenderer.endWidth = radius * 2f;
         * Material[] mats = new Material[1];
         * mats[0] = mat;
         * ropeRenderer.materials = mats;
         *
         * curvpoints = new Vector3[parts + 1];
         * points = new Vector3[parts * lineQuality + 1];
         *
         * ropeRenderer.positionCount = points.Length;
         */
        LateUpdate();
    }
Esempio n. 13
0
 // Use this for initialization
 void Start()
 {
     heroCollider = GetComponent <CapsuleCollider>();
 }
Esempio n. 14
0
 // Start is called before the first frame update
 void Start()
 {
     rigidBody      = GetComponent <Rigidbody>();
     playerCollider = GetComponent <CapsuleCollider>();
 }
Esempio n. 15
0
 private void Awake()
 {
     col = GetComponent <CapsuleCollider>();
     cam = FindObjectOfType <Camera>();
 }
Esempio n. 16
0
    protected override void Start()
    {
        m_AIData = new MobInfo();
        GameData.Instance.MobInfoTable[3300].CopyTo(m_AIData);

        m_MaxHp = m_AIData.m_fHp;
        base.Start();

        m_MobAnimator                  = this.GetComponent <MobAnimationsController>();
        m_BodyCollider                 = this.GetComponent <BoxCollider>();
        m_DamageCollider               = GetComponentInChildren <CapsuleCollider>();
        m_FSM                          = new FSMSystem(m_AIData);
        m_AIData.m_Go                  = this.gameObject;
        m_AIData.m_FSMSystem           = m_FSM;
        m_AIData.m_AnimationController = this.GetComponent <MobAnimationsController>();
        m_AIData.navMeshAgent          = this.GetComponent <NavMeshAgent>();
        m_AIData.navMeshAgent.speed    = Random.Range(11.5f, 12.0f);
        m_AIData.navMeshAgent.enabled  = false;
        m_AIData.m_SoundManager        = m_SoundManager;

        #region FSMMap
        FSMRespawnState    m_RespawnState    = new FSMRespawnState();
        FSMChaseState      m_Chasestate      = new FSMChaseState();
        FSMAttackState     m_Attackstate     = new FSMAttackState();
        FSMIdleState       m_IdleState       = new FSMIdleState();
        FSMWanderIdleState m_WanderIdleState = new FSMWanderIdleState();
        FSMWanderState     m_WanderState     = new FSMWanderState();

        m_RespawnState.AddTransition(eFSMTransition.Go_WanderIdle, m_WanderIdleState);

        m_Chasestate.AddTransition(eFSMTransition.Go_Attack, m_Attackstate);

        m_Attackstate.AddTransition(eFSMTransition.Go_Idle, m_IdleState);
        m_Attackstate.AddTransition(eFSMTransition.Go_Chase, m_Chasestate);

        m_IdleState.AddTransition(eFSMTransition.Go_Chase, m_Chasestate);
        m_IdleState.AddTransition(eFSMTransition.Go_Attack, m_Attackstate);

        m_WanderIdleState.AddTransition(eFSMTransition.Go_Wander, m_WanderState);
        m_WanderIdleState.AddTransition(eFSMTransition.Go_Chase, m_Chasestate);

        m_WanderState.AddTransition(eFSMTransition.Go_WanderIdle, m_WanderIdleState);
        m_WanderState.AddTransition(eFSMTransition.Go_Chase, m_Chasestate);

        FSMFishGetHurtState m_GetHurtState = new FSMFishGetHurtState();
        FSMDeadState        m_DeadState    = new FSMDeadState();

        m_GetHurtState.AddTransition(eFSMTransition.Go_Chase, m_Chasestate);
        m_GetHurtState.AddTransition(eFSMTransition.Go_Attack, m_Attackstate);

        m_DeadState.AddTransition(eFSMTransition.Go_Respawn, m_RespawnState);

        m_FSM.AddGlobalTransition(eFSMTransition.Go_WanderIdle, m_WanderIdleState);
        m_FSM.AddGlobalTransition(eFSMTransition.Go_FishGetHurt, m_GetHurtState);
        m_FSM.AddGlobalTransition(eFSMTransition.Go_Dead, m_DeadState);

        m_FSM.AddState(m_RespawnState);
        m_FSM.AddState(m_WanderIdleState);
        m_FSM.AddState(m_IdleState);
        m_FSM.AddState(m_Chasestate);
        m_FSM.AddState(m_Attackstate);
        m_FSM.AddState(m_GetHurtState);
        m_FSM.AddState(m_DeadState);
        m_FSM.AddState(m_WanderState);
        #endregion
    }
Esempio n. 17
0
        public void OnSceneGUI()
        {
            bool            flag            = GUIUtility.hotControl == this.m_HandleControlID;
            CapsuleCollider capsuleCollider = (CapsuleCollider)this.target;
            Color           color           = Handles.color;

            if (capsuleCollider.enabled)
            {
                Handles.color = Handles.s_ColliderHandleColor;
            }
            else
            {
                Handles.color = Handles.s_ColliderHandleColorDisabled;
            }
            bool enabled = GUI.enabled;

            if (!base.editingCollider && !flag)
            {
                GUI.enabled   = false;
                Handles.color = new Color(1f, 0f, 0f, 0.001f);
            }
            Vector3   capsuleExtents = ColliderUtil.GetCapsuleExtents(capsuleCollider);
            float     num            = capsuleExtents.y + 2f * capsuleExtents.x;
            float     x          = capsuleExtents.x;
            Matrix4x4 matrix     = ColliderUtil.CalculateCapsuleTransform(capsuleCollider);
            int       hotControl = GUIUtility.hotControl;
            float     num2       = capsuleCollider.height;
            Vector3   vector     = Vector3.left * num * 0.5f;
            float     num3       = CapsuleColliderEditor.SizeHandle(vector, Vector3.left, matrix, true);

            if (!GUI.changed)
            {
                num3 = CapsuleColliderEditor.SizeHandle(-vector, Vector3.right, matrix, true);
            }
            if (GUI.changed)
            {
                float num4 = num / capsuleCollider.height;
                num2 += num3 / num4;
            }
            float num5 = capsuleCollider.radius;

            num3 = CapsuleColliderEditor.SizeHandle(Vector3.forward * x, Vector3.forward, matrix, true);
            if (!GUI.changed)
            {
                num3 = CapsuleColliderEditor.SizeHandle(-Vector3.forward * x, -Vector3.forward, matrix, true);
            }
            if (!GUI.changed)
            {
                num3 = CapsuleColliderEditor.SizeHandle(Vector3.up * x, Vector3.up, matrix, true);
            }
            if (!GUI.changed)
            {
                num3 = CapsuleColliderEditor.SizeHandle(-Vector3.up * x, -Vector3.up, matrix, true);
            }
            if (GUI.changed)
            {
                float num6 = Mathf.Max(capsuleExtents.z / capsuleCollider.radius, capsuleExtents.x / capsuleCollider.radius);
                num5 += num3 / num6;
            }
            if (hotControl != GUIUtility.hotControl && GUIUtility.hotControl != 0)
            {
                this.m_HandleControlID = GUIUtility.hotControl;
            }
            if (GUI.changed)
            {
                Undo.RecordObject(capsuleCollider, "Modify Capsule Collider");
                capsuleCollider.radius = Mathf.Max(num5, 1E-05f);
                capsuleCollider.height = Mathf.Max(num2, 1E-05f);
            }
            Handles.color = color;
            GUI.enabled   = enabled;
        }
Esempio n. 18
0
 // Start is called before the first frame update
 void Start()
 {
     _rb          = GetComponent <Rigidbody>();
     _col         = GetComponent <CapsuleCollider>();
     _gameManager = GameObject.Find("Game Manager").GetComponent <GameBehavior>();
 }
Esempio n. 19
0
 void Start()
 {
     _rb  = GetComponent <Rigidbody>();
     _col = GetComponent <CapsuleCollider>();
 }
Esempio n. 20
0
        public bool UpdateGameObject(GameObject GameObjectNow, int FrameNo)
        {
            /* MEMO: No Transform-Datas, Not Changing "GameObject" */
            if ((0 >= AnimationDataPosition.Length) && (0 >= AnimationDataRotation.Length) && (0 >= AnimationDataScaling.Length))
            {
                return(false);                  /* Hide */
            }

            /* Transform Update */
            GameObjectNow.transform.localPosition    = (0 < AnimationDataPosition.Length) ? AnimationDataPosition[FrameNo] : Vector3.zero;
            GameObjectNow.transform.localEulerAngles = (0 < AnimationDataRotation.Length) ? AnimationDataRotation[FrameNo] : Vector3.zero;
            Vector3 Scale = Vector3.one;

            if (0 < AnimationDataScaling.Length)
            {
                Scale.x = AnimationDataScaling[FrameNo].x;
                Scale.y = AnimationDataScaling[FrameNo].y;
            }
            GameObjectNow.transform.localScale = Scale;

            /* Collider-Setting */
            if (null != CollisionComponent)
            {
                switch (CollisionKind)
                {
                case KindCollision.SQUARE:
                {
                    /* Calculate Sprite-Parts size */
                    Vector2 SizeNew  = Vector2.one;
                    Vector2 PivotNew = Vector2.zero;
                    {
                        Rect RectCell = Rect.MinMaxRect(0.0f, 0.0f, 64.0f, 64.0f);
                        if (0 < AnimationDataCell.Length)
                        {
                            RectCell = AnimationDataCell[FrameNo].Rectangle;
                        }

                        Vector2 RateScaleMesh = Vector2.one;
                        if (0 < AnimationDataFlags.Length)
                        {
                            RateScaleMesh.x = (true == AnimationDataFlags[FrameNo].IsFlipX) ? -1.0f : 1.0f;
                            RateScaleMesh.y = (true == AnimationDataFlags[FrameNo].IsFlipY) ? -1.0f : 1.0f;
                        }

                        /* Accommodate Pivot's-Offset */
                        Vector2 PivotOffset = (0 < AnimationDataOriginOffset.Length) ? AnimationDataOriginOffset[FrameNo] : Vector2.zero;
                        PivotNew.x += (RectCell.width * PivotOffset.x) * RateScaleMesh.x;
                        PivotNew.y -= (RectCell.height * PivotOffset.y) * RateScaleMesh.y;

                        /* Get Collision-Size */
                        SizeNew.x = RectCell.width;
                        SizeNew.y = RectCell.height;
                    }

                    if ((PivotNew != ColliderRectPivotPrevious) || (SizeNew != ColliderRectSizePrevious))
                    {                                           /* Update */
                                                                /* Update Previous Buffer */
                        ColliderRectPivotPrevious = PivotNew;
                        ColliderRectSizePrevious  = SizeNew;

                        /* Update Collider */
                        BoxCollider InstanceCollider = CollisionComponent as BoxCollider;
                        InstanceCollider.enabled = true;
                        InstanceCollider.size    = ColliderRectSizePrevious;
                        InstanceCollider.center  = ColliderRectPivotPrevious;
                    }
                }
                break;

                case KindCollision.CIRCLE:
                {
                    float RadiusNew = (0 < AnimationDataCollisionRadius.Length) ? AnimationDataCollisionRadius[FrameNo] : 1.0f;
                    if (RadiusNew != ColliderRadiusPrevious)
                    {                                           /* Update */
                                                                /* Update Previous Buffer */
                        ColliderRadiusPrevious = RadiusNew;

                        /* Update Collider */
                        CapsuleCollider InstanceCollider = CollisionComponent as CapsuleCollider;
                        InstanceCollider.enabled = true;
                        InstanceCollider.radius  = ColliderRadiusPrevious;
                        InstanceCollider.center  = Vector3.zero;
                    }
                }
                break;

                default:
                    break;
                }
            }

            /* Return-Value is "Inversed Hide-Flag"  */
            return(!AnimationDataFlags[FrameNo].IsHide);
        }
Esempio n. 21
0
        public void Collapse()
        {
            if (!BoltNetwork.isClient)
            {
                for (int i = base.transform.childCount - 1; i >= 0; i--)
                {
                    Transform      child     = base.transform.GetChild(i);
                    BuildingHealth component = child.GetComponent <BuildingHealth>();
                    if (component)
                    {
                        child.parent = null;
                        component.Collapse(child.position);
                    }
                    else
                    {
                        FoundationHealth component2 = child.GetComponent <FoundationHealth>();
                        if (component2)
                        {
                            child.parent = null;
                            component2.Collapse(child.position);
                        }
                        else if (BoltNetwork.isRunning && child.GetComponent <BoltEntity>())
                        {
                            child.parent = null;
                            destroyAfter destroyAfter = child.gameObject.AddComponent <destroyAfter>();
                            destroyAfter.destroyTime = 1f;
                        }
                    }
                }
            }
            bool flag = true;

            MeshRenderer[] componentsInChildren = (this._destroyTarget ?? base.gameObject).GetComponentsInChildren <MeshRenderer>();
            int            mask = LayerMask.GetMask(new string[]
            {
                "Default",
                "ReflectBig",
                "Prop",
                "PropSmall",
                "PickUp"
            });

            foreach (MeshRenderer renderer in componentsInChildren)
            {
                GameObject gameObject = renderer.gameObject;
                if (gameObject.activeInHierarchy && (1 << gameObject.layer & mask) != 0)
                {
                    Transform transform = renderer.transform;
                    transform.parent = null;
                    if (gameObject == base.gameObject)
                    {
                        flag = false;
                    }
                    gameObject.layer = this._detachedLayer;
                    if (!gameObject.GetComponent <Collider>())
                    {
                        CapsuleCollider capsuleCollider = gameObject.AddComponent <CapsuleCollider>();
                        capsuleCollider.radius    = 0.1f;
                        capsuleCollider.height    = 1.5f;
                        capsuleCollider.direction = (int)this._capsuleDirection;
                    }
                    Rigidbody rigidbody = gameObject.AddComponent <Rigidbody>();
                    if (rigidbody)
                    {
                        rigidbody.AddForce((transform.position.normalized + Vector3.up) * (2.5f * this._destructionForceMultiplier), ForceMode.Impulse);
                        rigidbody.AddRelativeTorque(Vector3.up * (2f * this._destructionForceMultiplier), ForceMode.Impulse);
                    }
                    destroyAfter destroyAfter2 = gameObject.AddComponent <destroyAfter>();
                    destroyAfter2.destroyTime = 2.5f;
                }
            }
            if (BoltNetwork.isClient)
            {
                BoltEntity component3 = base.GetComponent <BoltEntity>();
                if (component3 && component3.isAttached && !component3.isOwner)
                {
                    return;
                }
            }
            if (flag)
            {
                UnityEngine.Object.Destroy(base.gameObject);
            }
        }
Esempio n. 22
0
    //private float _verticalInput;
    //private float _rotationHorizontalInput;

    // Start is called before the first frame update
    void Start()
    {
        _playerRB       = gameObject.GetComponent <Rigidbody>();
        _playerCollider = gameObject.GetComponent <CapsuleCollider>();
    }
Esempio n. 23
0
 void Start()
 {
     Player   = GameObject.FindGameObjectWithTag("Player").GetComponent <CapsuleCollider> ();
     velocity = (-transform.forward * 40);
 }
    /// <summary>
    /// Copies all of the specified control's settings
    /// to this control, provided they are of the same
    /// type.  One exception is that layers are not
    /// copied as this would require a new allocation
    /// and could negatively impact performance at
    /// runtime.
    /// </summary>
    /// <param name="s">Reference to the control whose settings are to be copied to this control.</param>
    public virtual void Copy(SpriteRoot s, ControlCopyFlags flags)
    {
        if ((flags & ControlCopyFlags.Appearance) == ControlCopyFlags.Appearance)
        {
            if (Application.isPlaying && s.Started)
            {
                base.Copy(s);
            }
            else             // If we're in-editor, copy the TextureAnims too
            {
                base.CopyAll(s);
            }

            if (!(s is AutoSpriteControlBase))
            {
                if (autoResize || pixelPerfect)
                {
                    CalcSize();
                }
                else
                {
                    SetSize(s.width, s.height);
                }

                SetBleedCompensation();

                return;
            }
        }



        AutoSpriteControlBase c = (AutoSpriteControlBase)s;

        // Copy transitions:
        if ((flags & ControlCopyFlags.Transitions) == ControlCopyFlags.Transitions)
        {
            if (c is UIStateToggleBtn || !Application.isPlaying)
            {
                if (c.Transitions != null)
                {
                    Transitions = new EZTransitionList[c.Transitions.Length];
                    for (int i = 0; i < Transitions.Length; ++i)
                    {
                        Transitions[i] = new EZTransitionList();
                        c.Transitions[i].CopyToNew(Transitions[i], true);
                    }
                }
            }
            else
            {
                if (Transitions != null && c.Transitions != null)
                {
                    for (int i = 0; i < Transitions.Length && i < c.Transitions.Length; ++i)
                    {
                        c.Transitions[i].CopyTo(Transitions[i], true);
                    }
                }
            }
        }


        if ((flags & ControlCopyFlags.Text) == ControlCopyFlags.Text)
        {
            // See if we want to clone the other
            // control's text mesh:
            if (spriteText == null && c.spriteText != null)
            {
                GameObject newText = (GameObject)Instantiate(c.spriteText.gameObject);
                newText.transform.parent        = transform;
                newText.transform.localPosition = c.spriteText.transform.localPosition;
                newText.transform.localScale    = c.spriteText.transform.localScale;
                newText.transform.localRotation = c.spriteText.transform.localRotation;
            }

            if (spriteText != null)
            {
                spriteText.Copy(c.spriteText);
            }
        }

        if ((flags & ControlCopyFlags.Data) == ControlCopyFlags.Data)
        {
            data = c.data;
        }

        if ((flags & ControlCopyFlags.Appearance) == ControlCopyFlags.Appearance)
        {
            // See if we can copy the other control's collider's settings:
            if (c.collider != null)
            {
                if (collider.GetType() == c.collider.GetType())
                {
                    if (c.collider is BoxCollider)
                    {
                        if (collider == null)
                        {
                            gameObject.AddComponent(typeof(BoxCollider));
                        }

                        BoxCollider bc1 = (BoxCollider)collider;
                        BoxCollider bc2 = (BoxCollider)c.collider;
                        bc1.center = bc2.center;
                        bc1.size   = bc2.size;
                    }
                    else if (c.collider is SphereCollider)
                    {
                        if (collider == null)
                        {
                            gameObject.AddComponent(typeof(SphereCollider));
                        }

                        SphereCollider sc1 = (SphereCollider)collider;
                        SphereCollider sc2 = (SphereCollider)c.collider;
                        sc1.center = sc2.center;
                        sc1.radius = sc2.radius;
                    }
                    else if (c.collider is MeshCollider)
                    {
                        if (collider == null)
                        {
                            gameObject.AddComponent(typeof(MeshCollider));
                        }

                        MeshCollider mc1 = (MeshCollider)collider;
                        MeshCollider mc2 = (MeshCollider)c.collider;
                        mc1.smoothSphereCollisions = mc2.smoothSphereCollisions;
                        mc1.convex     = mc2.convex;
                        mc1.sharedMesh = mc2.sharedMesh;
                    }
                    else if (c.collider is CapsuleCollider)
                    {
                        if (collider == null)
                        {
                            gameObject.AddComponent(typeof(CapsuleCollider));
                        }

                        CapsuleCollider cc1 = (CapsuleCollider)collider;
                        CapsuleCollider cc2 = (CapsuleCollider)c.collider;
                        cc1.center    = cc2.center;
                        cc1.radius    = cc2.radius;
                        cc1.height    = cc2.height;
                        cc1.direction = cc2.direction;
                    }

                    if (collider != null)
                    {
                        collider.isTrigger = c.collider.isTrigger;
                    }
                }
            }
            else if (Application.isPlaying)            // Don't create a collider if we're in edit mode
            {
                // Create a default box collider to fit so
                // long as the control isn't of 0 size:
                if (collider == null &&
                    width != 0 && height != 0 &&
                    !float.IsNaN(width) && !float.IsNaN(height))
                {
                    BoxCollider bc = (BoxCollider)gameObject.AddComponent(typeof(BoxCollider));
                    bc.size      = new Vector3(c.width, c.height, 0.001f);
                    bc.center    = c.GetCenterPoint();
                    bc.isTrigger = true;
                }
                else
                {
                    if (collider is BoxCollider)
                    {
                        BoxCollider bc = (BoxCollider)collider;
                        bc.size   = new Vector3(c.width, c.height, 0.001f);
                        bc.center = c.GetCenterPoint();
                    }
                    else if (collider is SphereCollider)
                    {
                        SphereCollider sc = (SphereCollider)collider;
                        sc.radius = Mathf.Max(c.width, c.height);
                        sc.center = c.GetCenterPoint();
                    }
                    // Else Fuhgettaboutit
                }
            }
        }

        if ((flags & ControlCopyFlags.Invocation) == ControlCopyFlags.Invocation)
        {
            changeDelegate = c.changeDelegate;
            inputDelegate  = c.inputDelegate;
        }

        if ((flags & ControlCopyFlags.State) == ControlCopyFlags.State ||
            (flags & ControlCopyFlags.Appearance) == ControlCopyFlags.Appearance)
        {
            Container = c.Container;

            if (Application.isPlaying)
            {
                controlIsEnabled = c.controlIsEnabled;
                Hide(c.IsHidden());
            }

            if (curAnim != null)
            {
                if (curAnim.index == -1)
                {
                    PlayAnim(curAnim);
                }
                else
                {
                    SetState(curAnim.index);
                }
            }
            else
            {
                SetState(0);
            }
        }

/*
 *              if (autoResize || pixelPerfect)
 *                      CalcSize();
 *              else
 *                      SetSize(s.width, s.height);
 */
    }
Esempio n. 25
0
 void Start()
 {
     origin          = GetComponent <Transform>();
     audioSource     = GetComponent <AudioSource>();
     capsuleCollider = GetComponent <CapsuleCollider>();
 }
Esempio n. 26
0
 //-------------------------------------------------
 private void Awake()
 {
     capsuleCollider = GetComponent <CapsuleCollider>();
 }
Esempio n. 27
0
    protected override void Awake()
    {
        base.Awake();

        list.Clear();


        patrolSpots = _Node.transform.GetComponentsInChildren <Transform>();
        for (int i = 0; i < patrolSpots.Length - 1; i++)
        {
            list.Add(patrolSpots[i]);
        }
        _listCount = list.Count;



        if (isChangeMS04)
        {
            EMPLOOP.SetActive(true);
        }
        else if (!isChangeMS04)
        {
            EMPLOOP.SetActive(false);
        }
        //_obj.Clear();
        //list.Clear();
        //_obj.AddRange(GameObject.FindGameObjectsWithTag("Object"));         // 오브젝트 갯수 파악


        //for (int i = 0; i < _obj.Count; i++)
        //{
        //    ObjectInfo[] _objectinfo = new ObjectInfo[_obj.Count];
        //    _objectinfo[i] = _obj[i].GetComponent<ObjectInfo>();

        //    if (_objectinfo[i] == null)
        //        continue;

        //    _objType = _objectinfo[i]._ObjectType;

        //    if (_objType != ObjectType.Node)
        //    {
        //        list.Add(_obj[i]);
        //    }
        //}

        //Debug.Log(list.Count);

        SetGizmoColor(Color.blue);
        _cc   = GetComponent <CharacterController>();
        _stat = GetComponent <MS04Stat>();
        _anim = GetComponentInChildren <Animator>();

        //_playercc = GameObject.FindGameObjectWithTag("Player").GetComponent<CharacterController>();
        _playercs        = GameObject.FindGameObjectWithTag("Player").GetComponent <CapsuleCollider>();
        _playerTransform = _playercs.transform;

        //_objectbc = GameObject.FindGameObjectWithTag("Cabinet").GetComponent<BoxCollider>();



        MS04State[] stateValues = (MS04State[])System.Enum.GetValues(typeof(MS04State));
        foreach (MS04State s in stateValues)
        {
            System.Type  FSMType = System.Type.GetType("MS04" + s.ToString());
            MS04FSMState state   = (MS04FSMState)GetComponent(FSMType);
            if (null == state)
            {
                state = (MS04FSMState)gameObject.AddComponent(FSMType);
            }

            _states.Add(s, state);
            state.enabled = false;
        }
    }
Esempio n. 28
0
 // Start is called before the first frame update
 void Start()
 {
     monkey = GetComponent <Rigidbody>();
     col    = GetComponent <CapsuleCollider>();
 }
Esempio n. 29
0
    // Update is called once per frame
    void Update()
    {
        if (parent != null && Camera.main != null)
        {
            Vector3 point = Camera.main.transform.position;
            if (type < 3)
            {
                if (type == 2)
                {
                    point.y = gameObject.transform.position.y;
                }
                transform.LookAt(point);
            }

            float rot = transform.rotation.y;
            if (rot < 0)
            {
                rot += 180f;
            }
            float aps = 360 / sideCount;
            rot -= aps / 2;
            int angle = (int)(rot / aps);

            for (int s = 0; s < sides.Count; s++)
            {
                if (s == angle)
                {
                    int frame = currentFrame * sideCount + s;
                    if (frame != lastframe)
                    {
                        sides[s].GetComponent <MeshRenderer>().material = frames[frame];
                        float scalex     = ((float)frames[frame].mainTexture.width / 1024f) * scale;
                        float scaley     = ((float)frames[frame].mainTexture.height / 1024f) * scale;
                        float lastHeight = 0;

                        sides[s].transform.localScale = new Vector3(scalex, scaley, 1);
                        if (parent.GetComponent <CapsuleCollider>() != null)
                        {
                            CapsuleCollider cc = parent.GetComponent <CapsuleCollider>();
                            lastHeight = cc.height;
                            if (scaley > scalex)
                            {
                                cc.radius = scalex / 2;
                                cc.height = scaley;
                            }
                            else
                            {
                                cc.height = scaley;
                                cc.radius = scaley / 2;
                            }
                        }
                        else
                        {
                            BoxCollider bc = parent.GetComponent <BoxCollider>();
                            lastHeight = bc.size.x;
                            bc.size    = new Vector3(scalex, scaley, scalex);
                        }
                        // Debug.Log(lastHeight);
                        // Debug.Log(scalex);
                        float vChange = (lastHeight - scaley) / 2f;
                        if (fromCeiling)
                        {
                            vChange = 0 - vChange;
                        }
                        parent.transform.position = new Vector3(parent.transform.position.x,
                                                                parent.transform.position.y - vChange,
                                                                parent.transform.position.z);
                        lastframe = frame;
                    }
                    sides[s].SetActive(true);


                    if (type == 1 || type == 2)
                    {
                        //GameObject camera;
                        //Quaternion q = GameObject.Find("playerCamera").transform.rotation;
                        //GameObject player = GameObject.Find("player/playerCamera");
                        Quaternion cameraQ = GameObject.Find("player/playerCamera").transform.rotation;

                        //camera = GameObject.Find("playerCamera");
                        if (type == 1)
                        {
                            sides[s].transform.rotation = Quaternion.Euler(cameraQ.eulerAngles.x, cameraQ.eulerAngles.y, cameraQ.eulerAngles.z);
                        }
                        else
                        {
                            sides[s].transform.rotation = Quaternion.Euler(0, cameraQ.eulerAngles.y, 0);
                        }
                    }
                }
                else
                {
                    sides[s].SetActive(false);
                }
            }
        }
    }
Esempio n. 30
0
        private static void DrawColliderGizmos(CinemachineConfiner confiner, GizmoType type)
        {
            CinemachineVirtualCameraBase vcam = (confiner != null) ? confiner.VirtualCamera : null;

            if (vcam != null && confiner.IsValid)
            {
                Matrix4x4 oldMatrix = Gizmos.matrix;
                Color     oldColor  = Gizmos.color;
                Gizmos.color = Color.yellow;

                if (confiner.m_ConfineMode == CinemachineConfiner.Mode.Confine3D)
                {
                    Transform t = confiner.m_BoundingVolume.transform;
                    Gizmos.matrix = Matrix4x4.TRS(t.position, t.rotation, t.lossyScale);

                    Type colliderType = confiner.m_BoundingVolume.GetType();
                    if (colliderType == typeof(BoxCollider))
                    {
                        BoxCollider c = confiner.m_BoundingVolume as BoxCollider;
                        Gizmos.DrawWireCube(c.center, c.size);
                    }
                    else if (colliderType == typeof(SphereCollider))
                    {
                        SphereCollider c = confiner.m_BoundingVolume as SphereCollider;
                        Gizmos.DrawWireSphere(c.center, c.radius);
                    }
                    else if (colliderType == typeof(CapsuleCollider))
                    {
                        CapsuleCollider c    = confiner.m_BoundingVolume as CapsuleCollider;
                        Vector3         size = Vector3.one * c.radius * 2;
                        switch (c.direction)
                        {
                        case 0: size.x = c.height; break;

                        case 1: size.y = c.height; break;

                        case 2: size.z = c.height; break;
                        }
                        Gizmos.DrawWireCube(c.center, size);
                    }
                    else if (colliderType == typeof(MeshCollider))
                    {
                        MeshCollider c = confiner.m_BoundingVolume as MeshCollider;
                        Gizmos.DrawWireMesh(c.sharedMesh);
                    }
                    else
                    {
                        // Just draw an AABB - not very nice!
                        Gizmos.matrix = oldMatrix;
                        Bounds bounds = confiner.m_BoundingVolume.bounds;
                        Gizmos.DrawWireCube(t.position, bounds.extents * 2);
                    }
                }
                else
                {
                    Transform t = confiner.m_BoundingShape2D.transform;
                    Gizmos.matrix = Matrix4x4.TRS(t.position, t.rotation, t.lossyScale);

                    Type colliderType = confiner.m_BoundingShape2D.GetType();
                    if (colliderType == typeof(PolygonCollider2D))
                    {
                        PolygonCollider2D poly = confiner.m_BoundingShape2D as PolygonCollider2D;
                        for (int i = 0; i < poly.pathCount; ++i)
                        {
                            DrawPath(poly.GetPath(i), -1);
                        }
                    }
                    else if (colliderType == typeof(CompositeCollider2D))
                    {
                        CompositeCollider2D poly = confiner.m_BoundingShape2D as CompositeCollider2D;
                        Vector2[]           path = new Vector2[poly.pointCount];
                        for (int i = 0; i < poly.pathCount; ++i)
                        {
                            int numPoints = poly.GetPath(i, path);
                            DrawPath(path, numPoints);
                        }
                    }
                }
                Gizmos.color  = oldColor;
                Gizmos.matrix = oldMatrix;
            }
        }