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

Custom InnerNetObjects #92

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

Custom InnerNetObjects #92

wants to merge 15 commits into from

Conversation

D1GQ
Copy link

@D1GQ D1GQ commented Mar 23, 2025

Introducing Custom InnerNetObjects


This PR introduces a set of improvements to make working with custom InnerNetObject easier, and more intuitive. The changes include:

  1. Comprehensive XML Documentation:

    • Added detailed documentation for key methods to improve code clarity and developer experience.
    • Examples and usage instructions are provided to help developers quickly integrate custom InnerNetObject prefabs.
  2. Utility Methods for Prefab Handling:

    • Added methods like GetNetObjPrefab<T>, SpawnNewNetObject<T>, and SpawnNetObject to simplify the process of retrieving, instantiating, and spawning custom InnerNetObject prefabs.

Key Changes:

1. GetNetObjPrefab<T>

  • Purpose: Retrieves the prefab for a custom InnerNetObject of type T.
  • Usage:
    var prefab = InnerNetObjectManager.GetNetObjPrefab<MyCustomObject>();

2. SpawnNewNetObject<T>

  • Purpose: Spawns a new InnerNetObject locally and on the network of type "T".
  • Usage:
    var newObject = InnerNetObjectManager.SpawnNewNetObject<MyCustomObject>(ownerId: 1, spawnFlags: SpawnFlags.None);

3. SpawnNetObject<T> (Extension Method)

  • Purpose: Spawns an existing InnerNetObject instance on the network.
  • Usage:
    var existingObject = new MyCustomObject();
    existingObject.SpawnNetObject(ownerId: 1, spawnFlags: SpawnFlags.None);

@Pietrodjaowjao
Copy link
Contributor

i just dont get the InnerNetObject attribute, it seems really unecessary since this can be done by checking subtypes in the assembly

@Galster-dev
Copy link
Contributor

I think example class should be an actual simple example of what you can do with this instead of just a stub.

@D1GQ
Copy link
Author

D1GQ commented Mar 23, 2025

i just dont get the InnerNetObject attribute, it seems really unecessary since this can be done by checking subtypes in the assembly

The first reason is do to the issue with abstract monobehaviors and compiling it into il2cpp, second reason is I feel like it's more consistent using a attribute as the original class with Reactor, now I'm probably going to change the method of loading the prefab for it.

If y'all really want it to just be a custom subclass then I'll rework the logic.

D1GQ added 2 commits March 23, 2025 13:06
Replaced InnerNetObjectAttribute with IgnoreInnerNetObjectAttribute, now automatically registers InnerNetObjects.
Added more methods to load prefab.
@D1GQ
Copy link
Author

D1GQ commented Mar 23, 2025

i just dont get the InnerNetObject attribute, it seems really unecessary since this can be done by checking subtypes in the assembly

I've added some changes.

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.

3 participants