// This method is called from the LoginManager component inside the sample Scene. // This is the same LoginManager used in the Reflect Viewers. // While in the Editor, the user is the current Unity account logged into the Unity Editor. // Once logged in, we can list available projects by using a ProjectLister with an AuthClient. public void OnUserLoggedIn(UnityUser user) { m_State = State.ListingProjects; // A storage is required to specify where data are saved and cached m_Storage = new PlayerStorage(Path.Combine(Application.dataPath, ".ReflectSamplesTemp"), false, false); // Create a Authentication client from the current Unity user m_AuthClient = new AuthClient(user, m_Storage); var projectListerSettings = new ProjectListerSettings { OnProjectsRefreshCompleted = new ProjectListerSettings.ProjectsEvents(), OnProjectsRefreshStarted = new UnityEvent() }; projectListerSettings.OnProjectsRefreshCompleted.AddListener((projects) => { // This is the callback for when all projects are done listing. // For this sample, we populate a list that will be displayed as UI in the OnGUI method. m_State = State.ProjectListed; m_AvailableProjects = projects; }); // Create a ProjectLister to enumerate all available projects in the cloud for this user m_ProjectsLister = new ProjectsLister(projectListerSettings) { client = m_AuthClient }; // Since ProjectLister runs in another thread, make sure to set the UpdateDelegate to be able to collect received data into the main thread. m_ProjectsLister.SetUpdateDelegate(this); // Start the ProjectLister thread. OnProjectsRefreshCompleted callback will be called when all projects are done listing. m_ProjectsLister.Run(); }
public static void RefreshProjects() { s_ProjectLister?.Run(); }