示例#1
0
        /// <summary>
        ///     Place left hand on selected object
        /// </summary>
        public void PlaceLeftHand()
        {
            GameObject go             = selectObject.GetObject();
            Vector3    hitPoint       = selectObject.GetHitPoint();
            Vector3    hitPointNormal = selectObject.GetHitPointNormal();

            selectObject.ResetColor();


            if (go != null)
            {
                if (!HandChecker.HasLeftHand(go) && !HandChecker.IsAnyHand(go))
                {
                    if (go.GetComponent <Rigidbody>() != null)
                    {
                        //Destroy the RigidBody
                        Destroy(go.GetComponent <Rigidbody>());
                        //_hasRigidBody = true;
                    }

                    Vector3 rotationLeft = new Vector3();

                    //load leftHandPrefab and instantiate it with the predetermined parameters
                    GameObject leftHandPrefab =
                        Resources.Load("HandPrefab" + Path.DirectorySeparatorChar + "LeftHand") as GameObject;
                    GameObject leftHand = Instantiate(leftHandPrefab,
                                                      hitPoint + selectObject.GetDragAndRotate().GetOffsetAfterDrag() + hitPointNormal * OffSetValue,
                                                      Quaternion.Euler(rotationLeft));
                    leftHand.transform.SetParent(go.transform);
                    leftHand.transform.rotation = Quaternion.FromToRotation(-leftHand.transform.right, hitPointNormal);

                    //Add a BoxCollider to the hand
                    _boxColliderLeftHand = leftHand.AddComponent <BoxCollider>();
                    adjustBoxCollider(_boxColliderLeftHand, 0);
                }
            }
        }