Beispiel #1
0
        public void Init()
        {
            m_windowForm = new RenderForm(m_title);
            m_windowForm.AllowUserResizing = true;



            EditorGraphicsManager.Instance.Init();
            //test
            //var testwind = RigelEGUIWindow.GetWindow<RigelEditorAboutPage>();
            //var consolewin = RigelEGUIWindow.GetWindow<RigelEditorConsoleWindow>();

            EditorModuleManager.Instance.Init();
            EditorGUI = EditorModuleManager.Instance.FindModule <EditorGUIManager>();
        }
    static void ExportWarehouseBundle()
    {
        Object folder = Selection.activeObject;

        Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);

        // Bring up save panel
        string saveLocation = EditorUtility.SaveFilePanel("Build Warehouse Pack", "", folder.name + "_w", "unity3d");

        if (saveLocation.Length != 0)
        {
            // Build the resource file from the active selection.
            string[] saveSplit  = saveLocation.Split(new char[] { '/' });
            string   bundleName = saveSplit[saveSplit.Length - 1];

            // find all maya, fbx and prefab files within the selection.
            List <Object> tiles = new List <Object>();
            List <Object> gibs  = new List <Object>();
            for (int i = 0; i < selection.Length; i++)
            {
                string path = AssetDatabase.GetAssetPath(selection[i]);
                if (path.EndsWith(".ma") || path.EndsWith(".mb") || path.EndsWith(".fbx") || path.EndsWith(".obj") || path.EndsWith(".prefab"))
                {
                    // split the files into two lists, one for gibs specifically and one for tiles.
                    if (path.Contains("/Gibs/"))
                    {
                        gibs.Add(selection[i]);
                    }
                    else
                    {
                        tiles.Add(selection[i]);
                    }
                }
            }

            // create prefabs for each of the selected objects.
            List <string> prefabPaths = new List <string>();
            foreach (Object obj in tiles)
            {
                bool success = EditorGUIManager.MakePrefabFromSelection(obj, bundleName, ref prefabPaths);
                if (success == false)
                {
                    return;
                }
            }

            // create prefabs for each of the selected gibs. link them to their owner objects appropriately.
            foreach (Object obj in gibs)
            {
                bool success = EditorGUIManager.MakeGibPrefabFromSelection(obj, bundleName, ref prefabPaths);
                if (success == false)
                {
                    return;
                }
            }

            // Create an array of names for the assets placed into the bundle.
            Object[] prefabs = new Object[prefabPaths.Count];
            for (int i = 0; i < prefabs.Length; i++)
            {
                prefabs[i] = AssetDatabase.LoadAssetAtPath(prefabPaths[i], typeof(Object));
            }

            string[] objectNames = new string[prefabs.Length];
            for (int i = 0; i < prefabs.Length; i++)
            {
                string   prefabPath = AssetDatabase.GetAssetPath(prefabs[i]);
                string[] split      = prefabPath.Split(new char[] { '/' });
                objectNames[i] = split[split.Length - 2] + "/" + split[split.Length - 1];
            }

            AssetBundleBuild[] buildMap = new AssetBundleBuild[1];

            string[] assetPaths = new string[prefabPaths.Count];
            for (int i = 0; i < prefabPaths.Count; i++)
            {
                assetPaths [i] = prefabPaths [i];
            }

            buildMap [0].assetBundleName = bundleName;
            buildMap [0].assetNames      = assetPaths;

            // Remove the file name from the save path
            saveLocation = saveLocation.Remove(saveLocation.LastIndexOf("/"));
            BuildPipeline.BuildAssetBundles(saveLocation, buildMap, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows);

//			BuildPipeline.BuildAssetBundleExplicitAssetNames( prefabs, objectNames, saveLocation, BuildAssetBundleOptions.CollectDependencies, BuildTarget.StandaloneWindows );
            // Selection.objects = prefabs;

            // make sure the new bundle shows up in the project window.
            AssetDatabase.Refresh();
        }
    }