Example #1
0
 public string this[BuildTarget index] {
     get {
         return(this[BuildTargetUtility.TargetToGroup(index)]);
     }
     set {
         this[BuildTargetUtility.TargetToGroup(index)] = value;
     }
 }
Example #2
0
        public override void Build(BuildTarget target,
                                   Model.NodeData node,
                                   IEnumerable <PerformGraph.AssetGroups> incoming,
                                   IEnumerable <Model.ConnectionData> connectionsToOutput,
                                   PerformGraph.Output Output,
                                   Action <Model.NodeData, string, float> progressFunc)
        {
            if (incoming == null)
            {
                return;
            }

            if (!Directory.Exists(m_buildLocations[target]))
            {
                Directory.CreateDirectory(m_buildLocations[target]);
            }

            var sceneGUIDs = m_scenes[target].Split(',');

#if UNITY_5_5_OR_NEWER
            string manifestPath = string.Empty;

            foreach (var ag in incoming)
            {
                foreach (var assets in ag.assetGroups.Values)
                {
                    var manifestBundle = assets.Where(a => a.assetType == typeof(AssetBundleManifestReference));
                    if (manifestBundle.Any())
                    {
                        manifestPath = manifestBundle.First().importFrom;
                    }
                }
            }

            BuildPlayerOptions opt = new BuildPlayerOptions();
            opt.options                 = (BuildOptions)m_buildOptions[target];
            opt.locationPathName        = m_buildLocations[target] + "/" + m_playerName[target];
            opt.assetBundleManifestPath = manifestPath;
            opt.scenes = sceneGUIDs.Select(guid => AssetDatabase.GUIDToAssetPath(guid)).Where(path => !string.IsNullOrEmpty(path) && !path.Contains("__DELETED_GUID_Trash")).ToArray();
            opt.target = target;
#if UNITY_5_6_OR_NEWER
            opt.targetGroup = BuildTargetUtility.TargetToGroup(target);
#endif
            var errorMsg = BuildPipeline.BuildPlayer(opt);
#else
            string[]     levels           = sceneGUIDs.Select(guid => AssetDatabase.GUIDToAssetPath(guid)).Where(path => !string.IsNullOrEmpty(path) && !path.Contains("__DELETED_GUID_Trash")).ToArray();
            string       locationPathName = m_buildLocations[target] + "/" + m_playerName[target];
            BuildOptions opt = (BuildOptions)m_buildOptions[target];

            var errorMsg = BuildPipeline.BuildPlayer(levels, locationPathName, target, opt);
#endif
            if (!string.IsNullOrEmpty(errorMsg))
            {
                throw new NodeException(node.Name + ":Player build failed:" + errorMsg, node.Id);
            }
        }
Example #3
0
        public static bool IsBuildTargetSupported(BuildTarget t)
        {
            var objType = typeof(UnityEditor.BuildPipeline);
            var method  = objType.GetMethod("IsBuildTargetSupported", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);

                        #if UNITY_5_6 || UNITY_5_6_OR_NEWER
            BuildTargetGroup g = BuildTargetUtility.TargetToGroup(t);
            //internal static extern bool IsBuildTargetSupported (BuildTargetGroup buildTargetGroup, BuildTarget target);
            var retval = method.Invoke(null, new object[] {
                System.Enum.ToObject(typeof(BuildTargetGroup), g),
                System.Enum.ToObject(typeof(BuildTarget), t)
            });
                        #else
            //internal static extern bool IsBuildTargetSupported (BuildTarget target);
            var retval = method.Invoke(null, new object[] { System.Enum.ToObject(typeof(BuildTarget), t) });
                        #endif
            return(Convert.ToBoolean(retval));
        }
Example #4
0
            public void SetupSupportedBuildTargets()
            {
                if (supportedBuildTargets == null)
                {
                    supportedBuildTargets      = new List <BuildTarget>();
                    supportedBuildTargetGroups = new List <BuildTargetGroup>();

                    try {
                        foreach (BuildTarget target in Enum.GetValues(typeof(BuildTarget)))
                        {
                            if (BuildTargetUtility.IsBuildTargetSupported(target))
                            {
                                if (!supportedBuildTargets.Contains(target))
                                {
                                    supportedBuildTargets.Add(target);
                                }
                                BuildTargetGroup g = BuildTargetUtility.TargetToGroup(target);
                                if (g == BuildTargetGroup.Unknown)
                                {
                                    // skip unknown platform
                                    continue;
                                }
                                if (!supportedBuildTargetGroups.Contains(g))
                                {
                                    supportedBuildTargetGroups.Add(g);
                                }
                            }
                        }

                        supportedBuildTargetNames = new string[supportedBuildTargets.Count];
                        for (int i = 0; i < supportedBuildTargets.Count; ++i)
                        {
                            supportedBuildTargetNames[i] = BuildTargetUtility.TargetToHumaneString(supportedBuildTargets[i]);
                        }
                    } catch (Exception e) {
                        LogUtility.Logger.LogError(LogUtility.kTag, e);
                    }
                }
            }
Example #5
0
        /**
         * Build from commandline - entrypoint.
         */
        public static void BuildFromCommandline()
        {
            try {
                var arguments = new List <string>(System.Environment.GetCommandLineArgs());

                Application.SetStackTraceLogType(LogType.Log, StackTraceLogType.None);
                Application.SetStackTraceLogType(LogType.Error, StackTraceLogType.None);
                Application.SetStackTraceLogType(LogType.Warning, StackTraceLogType.None);

                BuildTarget target = EditorUserBuildSettings.activeBuildTarget;

                int targetIndex = arguments.FindIndex(a => a == "-target");

                if (targetIndex >= 0)
                {
                    var targetStr = arguments[targetIndex + 1];
                    LogUtility.Logger.Log("Target specified:" + targetStr);

                    var newTarget = BuildTargetUtility.BuildTargetFromString(arguments[targetIndex + 1]);
                    if (!BuildTargetUtility.IsBuildTargetSupported(newTarget))
                    {
                        throw new AssetBundleGraphException(newTarget + " is not supported to build with this Unity. Please install platform support with installer(s).");
                    }

                    if (newTarget != target)
                    {
                                                #if UNITY_5_6 || UNITY_5_6_OR_NEWER
                        EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetUtility.TargetToGroup(newTarget), newTarget);
                                                #else
                        EditorUserBuildSettings.SwitchActiveBuildTarget(newTarget);
                                                #endif
                        target = newTarget;
                    }
                }

                int graphIndex      = arguments.FindIndex(a => a == "-graph");
                int collectionIndex = arguments.FindIndex(a => a == "-collection");

                if (graphIndex >= 0 && collectionIndex >= 0)
                {
                    LogUtility.Logger.Log("-graph and -collection can not be used at once. Aborting...");
                    return;
                }

                Model.ConfigGraph graph = null;

                if (graphIndex >= 0)
                {
                    var graphPath = arguments[graphIndex + 1];
                    LogUtility.Logger.Log("Graph path:" + graphPath);

                    graph = AssetDatabase.LoadAssetAtPath <Model.ConfigGraph>(graphPath);

                    LogUtility.Logger.Log("AssetReference bundle building for:" + BuildTargetUtility.TargetToHumaneString(target));

                    if (graph == null)
                    {
                        LogUtility.Logger.Log("Graph data not found. To specify graph to execute, use -graph [path]. Aborting...");
                        return;
                    }

                    var result = AssetBundleGraphUtility.ExecuteGraph(target, graph);

                    if (result.IsAnyIssueFound)
                    {
                        LogUtility.Logger.Log("Building asset bundles terminated because of following errors. Please fix issues by opening editor.");
                        foreach (var e in result.Issues)
                        {
                            LogUtility.Logger.LogError(LogUtility.kTag, e.reason);
                        }
                    }
                }

                if (collectionIndex >= 0)
                {
                    var collectionName = arguments[collectionIndex + 1];
                    LogUtility.Logger.Log("Collection Name:" + collectionName);

                    LogUtility.Logger.Log("AssetReference bundle building for:" + BuildTargetUtility.TargetToHumaneString(target));

                    if (collectionName == null)
                    {
                        LogUtility.Logger.Log("Collection name not specified. To specify collection to execute, use -collection [name]. Aborting...");
                        return;
                    }
                    BatchBuildConfig.GraphCollection c = BatchBuildConfig.GetConfig().Find(collectionName);
                    if (c == null)
                    {
                        LogUtility.Logger.Log("Collection not found. Please open project and configure graph collection. Aborting...");
                        return;
                    }

                    var result = AssetBundleGraphUtility.ExecuteGraphCollection(target, c);

                    foreach (var r in result)
                    {
                        if (r.IsAnyIssueFound)
                        {
                            foreach (var e in r.Issues)
                            {
                                LogUtility.Logger.LogError(LogUtility.kTag, r.Graph.name + ":" + e.reason);
                            }
                        }
                    }
                }
            } catch (Exception e) {
                LogUtility.Logger.LogError(LogUtility.kTag, e);
                LogUtility.Logger.LogError(LogUtility.kTag, "Building asset bundles terminated due to unexpected error.");
            } finally {
                LogUtility.Logger.Log("End of build.");
            }
        }
 public void CopyDefaultValueTo(BuildTarget t)
 {
     CopyDefaultValueTo(BuildTargetUtility.TargetToGroup(t));
 }
 public void Set(BuildTarget t, object value)
 {
     Set(BuildTargetUtility.TargetToGroup(t), value);
 }
 public T Get <T>(BuildTarget t)
 {
     return(Get <T>(BuildTargetUtility.TargetToGroup(t)));
 }