Placeholder-Software / Dissonance

Unity Voice Chat Asset
69 stars 5 forks source link

[help] CustomCommsNetwork not hitting Initialize method #262

Closed HaleyMueller closed 1 year ago

HaleyMueller commented 1 year ago

How am I supposed to start the customcommsnetwork? I override the Initialize method and it doesn't get hitting resulting in it not continuing onto the Update method. It is attached to a GameObject in the scene.

protected override void Initialize()
    {
        Debug.Log("Initializing");
        //Network.DoSomethingImportant();

        // Don't forget to call base.Initialize!
        base.Initialize();
    }
protected override void Update()
    {
        Debug.Log("IsInitialized: " + IsInitialized);
        if (IsInitialized)//IsInitialized)
        {
            // Check if the HLAPI is ready
            var networkActive = NetworkManager.Singleton.Server.IsRunning;
            Debug.Log("Network active: " + NetworkManager.Singleton.Server.IsRunning);
            if (networkActive)
            {
                // Check what mode the HLAPI is in
                var server = true;
                var client = false;

                // Check what mode Dissonance is in and if
                // they're different then call the correct method
                if (Mode.IsServerEnabled() != server || Mode.IsClientEnabled() != client)
                {
                    // HLAPI is server and client, so run as a non-dedicated
                    // host (passing in the correct parameters)
                    if (server && client)
                        RunAsHost(new CustomServerParam(), new CustomClientParam());

                    // HLAPI is just a server, so run as a dedicated host
                    else if (server)
                        RunAsDedicatedServer(new CustomServerParam());

                    // HLAPI is just a client, so run as a client
                    else if (client)
                        RunAsClient(new CustomClientParam());
                }
            }
            else if (Mode != NetworkMode.None)
            {
                //Network is not active, make sure Dissonance is not active
                Stop();
            }
        }

        base.Update();
    }

Screenshot

martindevans commented 1 year ago

Your screenshot shows that there is no DissonanceComms component. A custom comms network must be placed next to your DissonanceComms component for it to work.

HaleyMueller commented 1 year ago

I didn't get that far in the guide in the docs yet. Thanks!