Ejemplo n.º 1
0
    /// <summary>
    /// Create prefabs with current selection
    /// </summary
    public static GameObject CreatePrefabFromActiveGO(string path)
    {
        var go = Selection.activeGameObject;

        // Check for folder
        var localPath = path;

        if (!DirUtil.CheckForProjectPath(localPath))
        {
            DirUtil.CreateFolderTree(localPath);
        }

        // Fill array of prefabs
        var prefab = PrefabUtility.CreatePrefab(localPath + go.name + ".prefab", go);

        return(prefab);
    }
    /// <summary>
    /// Creates an asset bundle for an specific platform and return its manifest
    /// </summary>
    /// <param name="prefab">Prefab to create the asset from</param>
    /// <param name="name">Name of the asset bundle</param>
    /// <param name="path">Temporal path</param>
    /// <returns>The asset bundle manifest</returns>
    public static AssetBundleManifest CreateAssetBundle(GameObject prefab, string name, string path, BuildTarget platform)
    {
        var assetName = AssetDatabase.GetAssetPath(prefab);

        // Check for folder
        var localPath = path;

        if (!DirUtil.CheckForProjectPath(localPath))
        {
            DirUtil.CreateFolderTree(localPath);
        }

        // Create bundle
        AssetBundleBuild[] buildMap = new AssetBundleBuild[1];
        buildMap[0] = new AssetBundleBuild();
        buildMap[0].assetBundleName = name;
        buildMap[0].assetNames      = new string[] { assetName };
        var manifest = BuildPipeline.BuildAssetBundles(path, buildMap, BuildAssetBundleOptions.ChunkBasedCompression, platform);

        return(manifest);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Create prefabs with current selection
    /// </summary
    public static GameObject[] CreatePrefabs(string path)
    {
        var selectedObjects = Selection.gameObjects;
        var selectedCount   = selectedObjects.Length;

        // Check for folder
        var localPath = path;

        if (!DirUtil.CheckForProjectPath(localPath))
        {
            DirUtil.CreateFolderTree(localPath);
        }

        // Fill array of prefabs
        var prefabs = new GameObject[selectedCount];

        for (int i = 0; i < selectedCount; i++)
        {
            var go = selectedObjects[i];
            prefabs[i] = PrefabUtility.CreatePrefab(localPath + go.name + ".prefab", go);
        }

        return(prefabs);
    }