private async void Start() { //Initial Checks { const string environmentTag = "Environment"; parent = GameObject.FindGameObjectWithTag(environmentTag).transform; Debug.Assert(parent != null, $"Could not find parent target GameObject with tag \"{environmentTag}\"", this); } if (streamParentPrefab == null) { Debug.LogError($"{nameof(streamParentPrefab)} was unassigned", this); return; } var defaultAccount = AccountManager.GetDefaultAccount(); if (defaultAccount == null) { Debug.Log("Please set a default account in the Speckle Manager desktop application", this); //TODO proper exceptions that are handled by UI return; } //Setup List <SpeckleStream> streamList = await SpeckleStreams.List(); if (!streamList.Any()) { Debug.Log("There are no streams in your account, please create one online."); //TODO proper exceptions that are handled by UI return; } foreach (SpeckleStream s in streamList) { StreamFromID.Add(s.id, s); } OnReadyToReceive?.Invoke(defaultAccount.userInfo, defaultAccount.serverInfo); //If there is already a model imported GameObject environment = GameObject.FindGameObjectWithTag("Environment"); if (environment.GetComponentInChildren <Renderer>(false) != null) { OnBusyChange?.Invoke(false); } }
/// <summary> /// Adds a <paramref name="receiver"/> to the <see cref="ImportManager"/> /// </summary> /// <param name="receiver">The receiver to be added</param> /// <returns>true if the receiver was successfully added</returns> public bool RegisterExisting(Receiver receiver) { string streamID = receiver.StreamId; if (Receivers.ContainsKey(streamID)) { Debug.LogWarning($"Failed to add {typeof(Receiver)} because one already existed for {nameof(streamID)}:{streamID}"); return(false); } if (!StreamFromID.ContainsKey(streamID)) { Debug.LogWarning($"Failed to add {typeof(Receiver)} because no {typeof(SpeckleStream)} with {nameof(streamID)}:{streamID} could be found"); return(false); } SpeckleStream stream = StreamFromID[streamID]; Receivers.Add(streamID, receiver); OnReceiverAdd?.Invoke(stream, receiver); return(true); }