Esempio n. 1
0
        private static void    OnGUINetworkManager()
        {
            // assign offline scene in NetworkManager

            if (EditorBuildSettings.scenes.Length > 1)
            {
                var    nm   = FindObjectOfType <UnityEngine.Networking.NetworkManager> ();
                string name = GetSceneNameFromPath(EditorBuildSettings.scenes [1].path);

                if (Utilities2.DisabledButtonWithCalculatedSize(nm != null && nm.offlineScene != name, "Assign offline scene in Network Manager"))
                {
                    nm.offlineScene = name;
                    Debug.Log("Assigned offline scene in Network Manager : " + nm.offlineScene);
                    EditorUtility.SetDirty(nm);
                }

                GUILayout.Space(10);

                if (null == nm)
                {
                    EditorGUILayout.HelpBox("Network Manager not found in scene.", MessageType.Warning);
                }
            }
            else
            {
                EditorGUILayout.HelpBox("Offline scene is not added to build settings.", MessageType.Warning);
            }
        }
Esempio n. 2
0
//		private	static	string	RemoveStringFromEnd( string str, string strToRemove ) {
//
//
//		}


        private void OnGUIDemoScenes()
        {
            GUILayout.Label("Would you like to also add demo scenes to build settings ?", m_centeredLabelStyle);

            GUILayout.Label("This is recommended if you are installing for the first time.", m_centeredLabelStyle);

            GUILayout.Space(20);


            var demoScenes          = GetDemoScenePaths();
            var buildSettingsScenes = EditorBuildSettings.scenes.ToList();
            int numNotAdded         = 0;


            GUILayout.Label("Available demo scenes:");
            GUILayout.Space(10);

            m_scrollViewPosDemoScenes = EditorGUILayout.BeginScrollView(m_scrollViewPosDemoScenes, GUILayout.MaxHeight(150));

            foreach (var demoScene in demoScenes)
            {
                if (buildSettingsScenes.Any(s => s.path == demoScene))
                {
                    // already in build settings
                    GUILayout.Label("(added) " + demoScene);
                }
                else
                {
                    GUILayout.Label("+ " + demoScene);
                    numNotAdded++;
                }
            }

            EditorGUILayout.EndScrollView();

            GUILayout.Space(20);

            if (Utilities2.DisabledButtonWithCalculatedSize(numNotAdded > 0, "Add demo scenes"))
            {
                AddDemoScenesToBuildSettings();
            }
        }
Esempio n. 3
0
        private void OnGUICreatePrefabs()
        {
            string s = "This asset is consisted of so called modules (which are actually prefabs)." +
                       " Each prefab has it's own features which bring functionality to the game.\n\n" +
                       "To see all available prefabs, click Find prefabs.\n" +
                       "After that, you can select which ones you want to create.\n" +
                       "When you are done, you can create them by clicking Create prefabs.";

            GUILayout.Label(s);

            GUILayout.Space(20);

            GUILayout.Label("Note that this may take a while depending on the size of your project.");

            if (Utilities2.ButtonWithCalculatedSize("Find prefabs"))
            {
                this.FindPrefabs();
            }

            GUILayout.Space(20);

            // display some stats
            GUILayout.Label("Found prefabs: " + m_foundPrefabs.Count + ", new: " + m_foundPrefabs.Count(item => !item.isAlreadyCreated));

            GUILayout.Space(10);

            // display found prefabs in a scroll view

            //	m_scrollViewPosFoundPrefabs = EditorGUILayout.BeginScrollView( m_scrollViewPosFoundPrefabs,
            //		GUILayout.MinHeight( m_foundPrefabs.Count * 15 ), GUILayout.MaxHeight( 450 ), GUILayout.Width(this.position.width - 15) );

            for (int i = 0; i < m_foundPrefabs.Count; i++)
            {
                var foundPrefab = m_foundPrefabs [i];

                string text = foundPrefab.prefab.name + "        " + foundPrefab.prefabPath;

                if (foundPrefab.isAlreadyCreated)
                {
                    // this one is already created
                    GUILayout.Label(text);
                }
                else
                {
                    // add option to select him
                    foundPrefab.checkboxState = GUILayout.Toggle(foundPrefab.checkboxState, text);
                }
            }

            //	EditorGUILayout.EndScrollView ();

            GUILayout.Space(20);

            if (OnGUIEnsureStartupSceneIsLoaded("This is not the startup scene, so prefabs can not be created."))
            {
                // this is the startup scene

                m_groupPrefabsAfterCreating = EditorGUILayout.Toggle("group prefabs after creating", m_groupPrefabsAfterCreating);

                // prefabs can be created
                if (Utilities2.DisabledButtonWithCalculatedSize(m_foundPrefabs.Any(p => p.checkboxState && !p.isAlreadyCreated), "Create prefabs"))
                {
                    this.CreatePrefabs();

                    if (m_groupPrefabsAfterCreating)
                    {
                        Utilities.GroupAllModules();
                        Utilities.GroupAllMenusAndCanvases();
                    }

                    // clear list
                    //	this.ClearFoundPrefabsList ();
                }
            }

            GUILayout.Space(10);
        }