コード例 #1
0
    protected virtual GameObject InstantiateColliderContainer(GameObject objectToClone, string name, Transform parent)
    {
        GameObject generatedContainer = Instantiate(objectToClone, parent);

        generatedContainer.name = VRTK_SharedMethods.GenerateVRTKObjectName(true, name);
        VRTK_PlayerObject.SetPlayerObject(generatedContainer, VRTK_PlayerObject.ObjectTypes.Collider);

        return(generatedContainer);
    }
コード例 #2
0
    protected override void CreatePointerOriginTransformFollow()
    {
        pointerOriginTransformFollowGameObject    = new GameObject(VRTK_SharedMethods.GenerateVRTKObjectName(true, gameObject.name, "BasePointerRenderer_Origin_Smoothed"));
        pointerOriginTransformFollow              = pointerOriginTransformFollowGameObject.AddComponent <VRTK_TransformFollow>();
        pointerOriginTransformFollow.enabled      = false;
        pointerOriginTransformFollow.followsScale = false;

        // Set the moment to onUpdate so it is unaffected by Time.timeScale
        pointerOriginTransformFollow.moment = VRTK_TransformFollow.FollowMoment.OnUpdate;
    }
コード例 #3
0
        /// <summary>
        /// The CreateTrackPoint method sets up the point of grab to track on the grabbed object.
        /// </summary>
        /// <param name="controllerPoint">The point on the controller where the grab was initiated.</param>
        /// <param name="currentGrabbedObject">The GameObject that is currently being grabbed.</param>
        /// <param name="currentGrabbingObject">The GameObject that is currently doing the grabbing.</param>
        /// <param name="customTrackPoint">A reference to whether the created track point is an auto generated custom object.</param>
        /// <returns>The Transform of the created track point.</returns>
        public override Transform CreateTrackPoint(Transform controllerPoint, GameObject currentGrabbedObject, GameObject currentGrabbingObject, ref bool customTrackPoint)
        {
            Transform returnTrackpoint = null;

            customTrackPoint = true;
            returnTrackpoint = new GameObject(VRTK_SharedMethods.GenerateVRTKObjectName(true, currentGrabbedObject.name, "ControlAnimation", "AttachPoint")).transform;
            returnTrackpoint.SetParent(null);
            returnTrackpoint.position = (precisionGrab ? controllerPoint.position : currentGrabbedObject.transform.position);
            return(returnTrackpoint);
        }
 protected virtual void CopyCustomJoint()
 {
     if (customJoint != null)
     {
         jointHolder = new GameObject();
         jointHolder.transform.SetParent(transform);
         jointHolder.AddComponent <Rigidbody>().isKinematic = true;
         VRTK_SharedMethods.CloneComponent(customJoint, jointHolder, true);
         jointHolder.name = VRTK_SharedMethods.GenerateVRTKObjectName(true, "JointHolder");
         jointHolder.SetActive(false);
         Destroy(customJoint);
         customJoint = jointHolder.GetComponent <Joint>();
     }
 }
コード例 #5
0
    protected virtual GameObject CreateColliderContainer(string name, Transform parent)
    {
        GameObject generatedContainer = new GameObject(VRTK_SharedMethods.GenerateVRTKObjectName(true, name));

        generatedContainer.transform.SetParent(parent);
        generatedContainer.transform.localPosition = Vector3.zero;
        generatedContainer.transform.localRotation = Quaternion.identity;
        generatedContainer.transform.localScale    = Vector3.one;

        generatedContainer.layer = LayerMask.NameToLayer("Ignore Raycast");
        VRTK_PlayerObject.SetPlayerObject(generatedContainer, VRTK_PlayerObject.ObjectTypes.Collider);

        return(generatedContainer);
    }
コード例 #6
0
        /// <summary>
        /// The CreateTrackPoint method sets up the point of grab to track on the grabbed object.
        /// </summary>
        /// <param name="controllerPoint">The point on the controller where the grab was initiated.</param>
        /// <param name="currentGrabbedObject">The GameObject that is currently being grabbed.</param>
        /// <param name="currentGrabbingObject">The GameObject that is currently doing the grabbing.</param>
        /// <param name="customTrackPoint">A reference to whether the created track point is an auto generated custom object.</param>
        /// <returns>The Transform of the created track point.</returns>
        public Transform CreateTrackPoint(string name, ref bool customTrackPoint, Transform p = null)
        {
            Transform returnTrackpoint = null;

            customTrackPoint = true;
            returnTrackpoint = new GameObject(VRTK_SharedMethods.GenerateVRTKObjectName(true, name, "ControlAnimation", "AttachPoint")).transform;
            returnTrackpoint.SetParent(p);
            GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);

            sphere.transform.SetParent(returnTrackpoint);
            sphere.transform.GetComponent <Collider>().enabled = false;
            sphere.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
            //returnTrackpoint.position = (precisionGrab ? controllerPoint.position : currentGrabbedObject.transform.position);
            return(returnTrackpoint);
        }
コード例 #7
0
        /// <summary>
        /// The CreateTrackPoint method sets up the point of grab to track on the grabbed object.
        /// </summary>
        /// <param name="controllerPoint">The point on the controller where the grab was initiated.</param>
        /// <param name="currentGrabbedObject">The object that is currently being grabbed.</param>
        /// <param name="currentGrabbingObject">The object that is currently doing the grabbing.</param>
        /// <param name="customTrackPoint">A reference to whether the created track point is an auto generated custom object.</param>
        /// <returns>The transform of the created track point.</returns>
        public override Transform CreateTrackPoint(Transform controllerPoint, GameObject currentGrabbedObject, GameObject currentGrabbingObject, ref bool customTrackPoint)
        {
            Transform trackPoint = null;

            if (precisionGrab)
            {
                trackPoint        = new GameObject(VRTK_SharedMethods.GenerateVRTKObjectName(true, currentGrabbedObject.name, "TrackObject", "PrecisionSnap", "AttachPoint")).transform;
                trackPoint.parent = currentGrabbingObject.transform;
                SetTrackPointOrientation(ref trackPoint, currentGrabbedObject.transform, controllerPoint);
                customTrackPoint = true;
            }
            else
            {
                trackPoint = base.CreateTrackPoint(controllerPoint, currentGrabbedObject, currentGrabbingObject, ref customTrackPoint);
            }
            return(trackPoint);
        }
コード例 #8
0
 // Token: 0x06001D68 RID: 7528 RVA: 0x00096478 File Offset: 0x00094678
 protected virtual void CopyCustomJoint()
 {
     if (this.customJoint)
     {
         this.jointHolder = new GameObject();
         this.jointHolder.transform.SetParent(base.transform);
         this.jointHolder.AddComponent <Rigidbody>().isKinematic = true;
         VRTK_SharedMethods.CloneComponent(this.customJoint, this.jointHolder, true);
         this.jointHolder.name = VRTK_SharedMethods.GenerateVRTKObjectName(true, new object[]
         {
             "JointHolder"
         });
         this.jointHolder.SetActive(false);
         Object.Destroy(this.customJoint);
         this.customJoint = this.jointHolder.GetComponent <Joint>();
     }
 }
コード例 #9
0
 protected virtual void SetupParentContainer()
 {
     if (hingePoint != null)
     {
         hingePoint.transform.SetParent(transform.parent);
         Vector3 storedScale = transform.localScale;
         rotatorContainer = new GameObject(VRTK_SharedMethods.GenerateVRTKObjectName(true, name, "Controllable", "ArtificialBased", "RotatorContainer"));
         rotatorContainer.transform.SetParent(transform.parent);
         rotatorContainer.transform.localPosition = transform.localPosition;
         rotatorContainer.transform.localRotation = transform.localRotation;
         rotatorContainer.transform.localScale    = Vector3.one;
         transform.SetParent(rotatorContainer.transform);
         rotatorContainer.transform.localPosition = hingePoint.localPosition;
         transform.localPosition = -hingePoint.localPosition;
         transform.localScale    = storedScale;
         hingePoint.transform.SetParent(transform);
     }
 }