Git Product home page Git Product logo

Comments (8)

MScottAdams avatar MScottAdams commented on September 2, 2024 1

Thanks that is correct now!

from gsdk.

dgkanatsios avatar dgkanatsios commented on September 2, 2024

thank you!

from gsdk.

MScottAdams avatar MScottAdams commented on September 2, 2024

Welcome! Sorry but I tried a couple of times but can't get the code indicators in the sample above working. It's probably easier to read it in original post on Unity SDK.

from gsdk.

dgkanatsios avatar dgkanatsios commented on September 2, 2024

I think I fixed that, let me know if code looks like intended now.

from gsdk.

dgkanatsios avatar dgkanatsios commented on September 2, 2024

Coming back to this, want to make a pull request on this repo adding the DontDestroyOnLoad method? We'd be more than happy to review, discuss and accept!

from gsdk.

MScottAdams avatar MScottAdams commented on September 2, 2024

Sorry as I mentioned before I just don't have the time currently to setup GIT and do all the required steps.

from gsdk.

CaptainPineapple avatar CaptainPineapple commented on September 2, 2024

I'd go a bit further and suggest a singleton approach since depending on the scenes setup a scenechange might result in multiple Object getting created. Thus i'd suggest to add these following changes instead:

public class PlayFabMultiplayerAgentView : MonoBehaviour
{
    /// <summary>
    /// Static reference to the current active instance of the PlayFabMultiplayerAgentView.
    /// </summary>
    public static PlayFabMultiplayerAgentView current;
    private float _timer;
    /// <summary>
    /// Awake constructor
    /// </summary>
    private void Awake()
    {
        Debug.Log($"{Time.fixedTime} PlayFabMultiplayerAgentView awake ");
        // Check if the static instance already contains a refernce:
        if (current)
        {
            // Destroy this instance since we only ever need one PlayFabMultiplayerAgentView
            Destroy(gameObject);
            return;
        }
        else
        {
            // Need to keep this game object alive through scene changes.
            DontDestroyOnLoad(this);
            current = this;
        }
    }

    /// <summary>
    /// Called when gameobject is destroyed
    /// </summary>
    private void OnDestroy()
    {
        Debug.Log($"{Time.fixedTime} PlayFabMultiplayerAgentView destroyed ");
    }
}

from gsdk.

dgkanatsios avatar dgkanatsios commented on September 2, 2024

I believe we can close this due to #52, thanks @MScottAdams for bringing this up and @CaptainPineapple for the PR!

from gsdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.