コード例 #1
0
 private static void IncludeAssetsInBuild()
 {
     BuildProcessing.ProcessScene(GameInitializer.SCENE_NAME, true, (Scene scene) =>
     {
         GameInitializer gameInitializer = GameObject.FindObjectOfType <GameInitializer>();
         Type[] types = BuildProcessing.GetAllTypesWithAttributeType(typeof(IncludeInStartUpAttribute), false);
         for (int i = 0; i < types.Length; i++)
         {
             string[] assetsToInclude = AssetDatabase.FindAssets("t:" + types[i].Name);
             for (int ii = 0; ii < assetsToInclude.Length; ii++)
             {
                 string assetPath         = AssetDatabase.GUIDToAssetPath(assetsToInclude[ii]);
                 UnityEngine.Object asset = AssetDatabase.LoadAssetAtPath(assetPath, types[i]);
                 gameInitializer.AddAsset(asset);
                 if (EditorUtility.DisplayCancelableProgressBar("Adding Assets", "Processing " + types[i].Name + "s: \"" + assetsToInclude + "\"", ((float)i / types.Length) + ((float)ii / assetsToInclude.Length) / types.Length))
                 {
                     Debug.LogWarning("Adding Assets To Build canceled by user.");
                     break;
                 }
             }
         }
     });
 }
コード例 #2
0
 public static void GrabAllAssets()
 {
     if (Application.isPlaying)
     {
         System.Type        type  = typeof(IncludeInStartUpAttribute);
         List <System.Type> types = new List <System.Type>();
         types.AddRange(Assembly.GetAssembly(typeof(GameInitializer)).GetTypes()
                        .Where(m => m.GetCustomAttributes(type, false).Length > 0));
         for (int i = 0; i < types.Count; i++)
         {
             assets().AddRange(AssetDatabase.FindAssets("t:" + types[i].Name).Select(x => AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(x), types[i])).Where(x => x != null && !GameInitializer.assets().Contains(x)).ToArray());
         }
     }
 }