Beispiel #1
0
    void UpdateData(bool grabbed, int grabOwner, Vector3 position, Quaternion rotation, Vector3 velocity, Vector3 angularVelocity, int parentId, string parentPath)
    {
        // Parenting
        var actualNref = NetworkReference.FromTransform(transform.parent);
        var newNref    = NetworkReference.FromIdAndPath(parentId, parentPath);

        Debug.Log("Parenting: " + actualNref + "  NewRef: " + newNref + " Grabbed: " + grabbed);

        if (actualNref != newNref)
        {
            //Debug.Log("Reparenting from " + actualNref + " to " + newNref);
            GameObject newParent = newNref.FindObject();
            //Debug.Log("New parent " + newParent);
            transform.parent = newParent != null ? newParent.transform : null;
        }

        interactableObject.isKinematic = grabbed;
        SetState(grabOwner);

        if (rigidBody != null)
        {
            rigidBody.velocity        = velocity;
            rigidBody.angularVelocity = angularVelocity;
        }

        transform.position = position;
        transform.rotation = rotation;
    }
 void Awake()
 {
     interactableObject = GetComponent <VRTK_InteractableObject>();
     networkReference   = NetworkReference.FromObject(this.gameObject);
     propKey            = PROP_KEY_ID + networkReference.parentHandleId + "$" + (networkReference.pathFromParent != null ? networkReference.pathFromParent : "") + "$";
     var dummy = PropertyEventHandler.Instance;
 }
Beispiel #3
0
        protected override void RecvState(Hashtable content)
        {
            int              parentId = (int)content["pid"];
            string           path     = (string)content["pth"];
            NetworkReference nref     = NetworkReference.FromIdAndPath(parentId, path);

            InitState(nref);
            ApplyState();
        }
Beispiel #4
0
    protected override void Initialise()
    {
        base.Initialise();

        interactableObject = GetComponent <VRTK_InteractableObject>();
        rigidBody          = GetComponent <Rigidbody>();

        networkReference = NetworkReference.FromObject(this.gameObject);

        interactableObject.InteractableObjectUngrabbed += objectUngrabbed;
    }
Beispiel #5
0
        private void SetPanoramaFromObject(int refId, string refPath)
        {
            GameObject obj = NetworkReference.FromIdAndPath(refId, refPath).FindObject();

            if (obj != null)
            {
                Renderer objectRenderer = obj.GetComponent <Renderer>();
                if (objectRenderer != null)
                {
                    projSphereRenderer.material.SetTexture("_MainTex", objectRenderer.material.GetTexture("_MainTex"));
                    projSphereRenderer.material.SetColor("_Color", Color.white);
                }
            }
        }
Beispiel #6
0
 void OnEnable()
 {
     io.InteractableObjectSnappedToDropZone     += HandleSnappedToDropZone;
     io.InteractableObjectUnsnappedFromDropZone += HandleUnsnappedFromDropZone;
     if (io.IsInSnapDropZone())
     {
         dropZone       = io.GetStoredSnapDropZone();
         dropZoneNetRef = NetworkReference.FromTransform(dropZone.transform);
     }
     else
     {
         dropZone       = null;
         dropZoneNetRef = NetworkReference.INVALID;
     }
 }
Beispiel #7
0
    void UpdateDataToAllClients(bool grabbed, Rigidbody givenControllerAttachPoint)
    {
        NetworkReference parentNetworkReference = NetworkReference.FromTransform(transform.parent);

        Debug.Log("PARENT: " + parentNetworkReference);

        PhotonView.Get(this).RPC("UpdateData", PhotonTargets.OthersBuffered,
                                 grabbed,
                                 grabOwner,
                                 transform.position,
                                 transform.rotation,
                                 grabbed ? Vector3.zero : rigidBody.velocity,
                                 grabbed ? Vector3.zero : rigidBody.angularVelocity,
                                 parentNetworkReference.parentHandleId,
                                 parentNetworkReference.pathFromParent);
    }
Beispiel #8
0
        private void HandleSnappedToDropZone(object sender, SnapDropZoneEventArgs e)
        {
            var nref = NetworkReference.FromObject(e.snappedObject);

            photonView.RPC("SetPanoramaFromObject", PhotonTargets.AllBufferedViaServer, nref.parentHandleId, nref.pathFromParent);
        }
Beispiel #9
0
 private void InitState(NetworkReference nref)
 {
     dropZoneNetRef = nref;
 }
Beispiel #10
0
 private void HandleUnsnappedFromDropZone(object sender, InteractableObjectEventArgs e)
 {
     dropZone       = null;
     dropZoneNetRef = NetworkReference.INVALID;
 }
Beispiel #11
0
 private void HandleSnappedToDropZone(object sender, InteractableObjectEventArgs e)
 {
     dropZone       = io.GetStoredSnapDropZone();
     dropZoneNetRef = NetworkReference.FromTransform(dropZone.transform);
 }