Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added NetworkIdentity Spawn Methods & Tests #3201

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

realQuartzi
Copy link

I have absolutely no clue why I felt like doing this <3

Adds the option to use NetworkIdentities to spawn Objects instead of the Object itself... sometimes saving a nasty GetComponent<> call.

SpawnObject(NetworkIdentity identity, NetworkConnection ownerConnection)

Spawn(NetworkIdentity identity, NetworkConnection ownerConnection = null)
Spawn(NetworkIdentity spawnIdentity, GameObject ownerPlayer)
Spawn(NetworkIdentity spawnIdentity, NetworkIdentity ownerIdentity)
Spawn(NetworkIdentity identity, Guid assetId, NetworkConnection ownerConnection = null)

No other functions modified, only new ones added... possibly some obsolete but I guess nice to have.
Hope none of the comments are wrong

Attempted to add Tests with the new Spawn Methods... these are possibly obsolete D:

ServerMode_IsFlags_Identity_Test()
HostMode_IsFlags_Identity_Test()
SpawnNetworkPrefab(GameObject prefab)

As well as fixed on minor issue with a already existing Test method which was using the wrong variable :)

Shutdown_DisablesAllSpawnedPrefabs()

And all tests still work just fine :D
image

Added possibly obsolete tests for Spawn using Network Identity
Fixed Shutdown_DisabledAllSpawnedPrefabs() using wrong identity
@miwarnec
Copy link
Collaborator

@realQuartzi nice work.
shouldn't the Spawn(GameObject) methods then simply reuse Spawn(NetworkIdentity)?
it's the same code, right?

@realQuartzi
Copy link
Author

@vis2k I guess one can do that yea... in reality I guess we are just doing one extra call to save an early GetComponent<>
I'll look into that when I get home 👍

@realQuartzi
Copy link
Author

@vis2k I made some adjustments.
All the GameObject Spawns now use the NetworkIdentity SpawnObject method

I also added extra checks for the GameObject related methods to return the object name in an error log.
I have additionally moved the identity check to the top of SpawnObject as it is the first thing to look for now. Doing that skips the whole step of adding separate error checks in all the Spawn methods themselves as SpawnObject would take care of that.

It might be a little different than what you asked for but this might be better... at least in my thinking, it was.

@realQuartzi
Copy link
Author

I hope this is okay. Got very confused midway. o.o
Should be up to date with the latest master branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants