Exemplo n.º 1
0
        /// <summary>
        ///      Place right hand on selected object
        /// </summary>
        public void PlaceRightHand()
        {
            GameObject go             = selectObject.GetObject();
            Vector3    hitPoint       = selectObject.GetHitPoint();
            Vector3    hitPointNormal = selectObject.GetHitPointNormal();

            selectObject.ResetColor();

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

                    Vector3 rotationRight = new Vector3();

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

                    //Add a BoxCollider to the hand
                    _boxColliderRightHand = rightHand.AddComponent <BoxCollider>();
                    adjustBoxCollider(_boxColliderRightHand, 1);
                }
            }
        }