Beispiel #1
0
        IEnumerator ScanProject()
        {
            _scanned  = false;
            _scanning = true;
            foundPaths.Clear();
            CB_prefabs.Clear();
            string[]   prefabPaths = E_Helpers.GetAllPrefabs(true, false);
            GameObject target;

            foreach (string prefabPath in prefabPaths)
            {
                Object prefab = AssetDatabase.LoadMainAssetAtPath(prefabPath);
                try
                {
                    target = (GameObject)prefab;
                    CB_CHECK_CORE_HasComp(target, _cItemCollection, _cvBreakableObjects, _cvHealthController, prefabPath);
                    CB_SHOOTER_HasShooterComp(target, _cvShooterWeapons, prefabPath);
                }
                catch
                {
                    Debug.LogWarning("Unable to cast: " + prefabPath + " to GameObject, skipping");
                }
            }
            _scrollHeight = CB_prefabs.Count * 39;
            _scanning     = false;
            _scanned      = true;
            yield return(null);
        }
Beispiel #2
0
 public static void CB_AddPlayersToExampleUI()
 {
     if (EditorUtility.DisplayDialog("About To Add Players",
                                     "This will scan all the prefabs in your root Resources folder and attempt to find all " +
                                     "of the player prefabs. Then it will assign these found prefabs to the \"players\" gameobject " +
                                     "array in the \"ExampleUI\" component. This will overwrite any settings currently there.\n\n" +
                                     "Do you want to continue?",
                                     "Continue", "Cancel"))
     {
         UICoreLogic ui = FindObjectOfType <UICoreLogic>();
         if (ui == null)
         {
             if (EditorUtility.DisplayDialog("Missing ExampleUI",
                                             "You are missing an example UI from the scene. Please add it before trying this again.",
                                             "Okay"))
             {
             }
         }
         else
         {
             string[]          prefabPaths = E_Helpers.GetAllPrefabs(false, true);
             GameObject        target;
             List <GameObject> foundPlayers = new List <GameObject>();
             foreach (string prefabPath in prefabPaths)
             {
                 try
                 {
                     UnityEngine.Object prefab = AssetDatabase.LoadMainAssetAtPath(prefabPath);
                     target = (GameObject)prefab;
                     if (target.GetComponent <vThirdPersonController>())
                     {
                         foundPlayers.Add(target);
                     }
                 }
                 catch
                 {
                     continue;
                 }
             }
             ui.selectablePlayers = foundPlayers.ToArray();
             if (EditorUtility.DisplayDialog("Completed!",
                                             "The found player prefabs of the resources folder have been added to the ExampleUI. \n\n" +
                                             "Remember to save this to the prefab otherwise it will be removed when you click play.",
                                             "Great!"))
             {
                 Selection.activeGameObject = ui.gameObject;
             }
         }
     }
 }