Removing PhotonViews via Code
Options
Stekon
✭
Hello!
I have been having an issue where I need to remove a PhotonView from a GameObject. I can't just use Destroy(PhotonView) because it needs to be with any other PhotonViews syncing with it (so I guess any other PhotonViews with the same ViewID).
Is there any way to to do this?
Thanks!
Edit:
Fixed gibberish (I said gameObject.removeComponent instead of Destroy(), when in fact removeComponent doesn't exist! *Self-Facepalm*)
I have been having an issue where I need to remove a PhotonView from a GameObject. I can't just use Destroy(PhotonView) because it needs to be with any other PhotonViews syncing with it (so I guess any other PhotonViews with the same ViewID).
Is there any way to to do this?
Thanks!
Edit:
Fixed gibberish (I said gameObject.removeComponent instead of Destroy(), when in fact removeComponent doesn't exist! *Self-Facepalm*)
0
Best Answer
-
Use PhotonNetwork.Destroy(PhotonView targetView), if you created the object with PhotonNetwork.Instantiate().
That should turn the Destroy-call into a networked one.0
Answers
-
Use PhotonNetwork.Destroy(PhotonView targetView), if you created the object with PhotonNetwork.Instantiate().
That should turn the Destroy-call into a networked one.0 -
Ok so I wasn't actually able to implement this at the time, but it looked like it was what I needed. But this destroys the GameObject with the PhotonView, where I need to just destroy the PhotonView on the GameObject, without destroying the GameObject itself. Sorry about this. Any ideas?Tobias said:Use PhotonNetwork.Destroy(PhotonView targetView), if you created the object with PhotonNetwork.Instantiate().
That should turn the Destroy-call into a networked one.0 -
I'm looking for this solution as well, if someone has the right way to do this id appreciate it.
0 -
You could look into Manual Instantiation, described here. With it, you can add and remove PhotonViews from objects of your liking.
We can't really provide samples for that, sorry.
0