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);
            }
        }
예제 #2
0
        public override async void OnInspectorGUI()
        {
            _streamManager = (StreamManager)target;


            #region Account GUI
            if (Accounts == null)
            {
                await LoadAccounts();

                return;
            }


            EditorGUILayout.BeginHorizontal();

            SelectedAccountIndex = EditorGUILayout.Popup("Accounts", SelectedAccountIndex,
                                                         Accounts.Select(x => x.userInfo.email + " | " + x.serverInfo.name).ToArray(),
                                                         GUILayout.ExpandWidth(true), GUILayout.Height(20));

            if (OldSelectedAccountIndex != SelectedAccountIndex)
            {
                await SelectAccount(SelectedAccountIndex);

                return;
            }

            if (GUILayout.Button("Refresh", GUILayout.Width(60), GUILayout.Height(20)))
            {
                await LoadAccounts();

                return;
            }

            EditorGUILayout.EndHorizontal();


            #region Speckle Account Info
            _foldOutAccount = EditorGUILayout.BeginFoldoutHeaderGroup(_foldOutAccount, "Account Info");

            if (_foldOutAccount)
            {
                EditorGUI.BeginDisabledGroup(true);

                EditorGUILayout.TextField("Name", SelectedAccount.userInfo.name,
                                          GUILayout.Height(20),
                                          GUILayout.ExpandWidth(true));

                EditorGUILayout.TextField("Server", SelectedAccount.serverInfo.name,
                                          GUILayout.Height(20),
                                          GUILayout.ExpandWidth(true));

                EditorGUILayout.TextField("URL", SelectedAccount.serverInfo.url,
                                          GUILayout.Height(20),
                                          GUILayout.ExpandWidth(true));

                EditorGUI.EndDisabledGroup();
            }

            EditorGUILayout.EndFoldoutHeaderGroup();
            #endregion
            #endregion

            #region Stream List
            if (Streams == null)
            {
                return;
            }

            EditorGUILayout.BeginHorizontal();

            SelectedStreamIndex = EditorGUILayout.Popup("Streams",
                                                        SelectedStreamIndex, Streams.Select(x => x.name).ToArray(), GUILayout.Height(20),
                                                        GUILayout.ExpandWidth(true));

            if (OldSelectedStreamIndex != SelectedStreamIndex)
            {
                await SelectStream(SelectedStreamIndex);

                return;
            }

            if (GUILayout.Button("Refresh", GUILayout.Width(60), GUILayout.Height(20)))
            {
                await LoadStreams();

                return;
            }

            EditorGUILayout.EndHorizontal();
            #endregion

            #region Branch List
            if (Branches == null)
            {
                return;
            }

            EditorGUILayout.BeginHorizontal();

            SelectedBranchIndex = EditorGUILayout.Popup("Branches",
                                                        SelectedBranchIndex, Branches.Select(x => x.name).ToArray(), GUILayout.Height(20),
                                                        GUILayout.ExpandWidth(true));
            EditorGUILayout.EndHorizontal();


            if (!Branches[SelectedBranchIndex].commits.items.Any())
            {
                return;
            }


            EditorGUILayout.BeginHorizontal();

            SelectedCommitIndex = EditorGUILayout.Popup("Commits",
                                                        SelectedCommitIndex,
                                                        Branches[SelectedBranchIndex].commits.items.Select(x => x.message).ToArray(),
                                                        GUILayout.Height(20),
                                                        GUILayout.ExpandWidth(true));

            EditorGUILayout.EndHorizontal();
            #endregion

            #region Generate Materials
            EditorGUILayout.BeginHorizontal();

            GUILayout.Label("Generate material assets");
            GUILayout.FlexibleSpace();
            StreamManager.GenerateMaterials = GUILayout.Toggle(StreamManager.GenerateMaterials, "");

            EditorGUILayout.EndHorizontal();
            #endregion


            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Receive!"))
            {
                await Receive();
            }


            GUILayout.EndHorizontal();
        }