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; }
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(); }
protected override void Initialise() { base.Initialise(); interactableObject = GetComponent <VRTK_InteractableObject>(); rigidBody = GetComponent <Rigidbody>(); networkReference = NetworkReference.FromObject(this.gameObject); interactableObject.InteractableObjectUngrabbed += objectUngrabbed; }
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); } } }
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; } }
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); }
private void HandleSnappedToDropZone(object sender, SnapDropZoneEventArgs e) { var nref = NetworkReference.FromObject(e.snappedObject); photonView.RPC("SetPanoramaFromObject", PhotonTargets.AllBufferedViaServer, nref.parentHandleId, nref.pathFromParent); }
private void InitState(NetworkReference nref) { dropZoneNetRef = nref; }
private void HandleUnsnappedFromDropZone(object sender, InteractableObjectEventArgs e) { dropZone = null; dropZoneNetRef = NetworkReference.INVALID; }
private void HandleSnappedToDropZone(object sender, InteractableObjectEventArgs e) { dropZone = io.GetStoredSnapDropZone(); dropZoneNetRef = NetworkReference.FromTransform(dropZone.transform); }