Ejemplo n.º 1
0
    public static void OnPostprocessBuild(BuildTarget buildTarget, string buildPath)
    {
        BuildCfgAttributeInfo baf = null;
        int collection            = EditorPrefs.GetInt(savecollection, -1);

        if (collection == -1)
        {
            return;
        }
        List <BuildCfgAttributeInfo> buildcfgs = BuildCfgAttribute.GetAllAttribute(buildTarget, Channel,
                                                                                   collection, out baf);

        foreach (BuildCfgAttributeInfo cfg in buildcfgs)
        {
            cfg.obj.BuildAfter(buildPath);
        }
    }
Ejemplo n.º 2
0
    public static void BuildPlayer(BuildCollectionResInfo buildInfo, BuildTargetGroup target)
    {
        BuildTarget ta = BuildTarget.StandaloneWindows;

        switch (target)
        {
        case BuildTargetGroup.Standalone:
            ta = BuildTarget.StandaloneWindows;
            break;

        case BuildTargetGroup.Android:
            ta = BuildTarget.Android;
            break;

        case BuildTargetGroup.iOS:
            ta = BuildTarget.iOS;
            break;

        default:
            ta = BuildTarget.StandaloneWindows;
            break;
        }
        BuildCfgAttributeInfo        baf       = null;
        List <BuildCfgAttributeInfo> buildcfgs = BuildCfgAttribute.GetAllAttribute(ta, Channel,
                                                                                   buildInfo.CollectionID, out baf);

        string[]     scs = null;
        BuildOptions bop = BuildOptions.None;

        if (baf != null)
        {
            PropertyInfo buildpro = baf.type.GetProperty("BuildScenes");
            scs = buildpro.GetValue(baf.obj, null) as string[];
            PropertyInfo op = baf.type.GetProperty("BuildOptions");
            bop = (BuildOptions)op.GetValue(baf.obj, null);
        }
        foreach (BuildCfgAttributeInfo cfg in buildcfgs)
        {
            cfg.obj.BuildBefore();
        }
        scs = scs == null ? GetBuildScenes : scs;

        BuildPipeline.BuildPlayer(scs, outpath, ta, bop);
    }
Ejemplo n.º 3
0
    public static List <BuildCfgAttributeInfo> GetAllAttribute(BuildTarget target,
                                                               int _channel, int _collectionID, out BuildCfgAttributeInfo buildPlayersetting)
    {
        buildPlayersetting = null;
        List <Type> types = CustomSettings.GetcustomTypesList <BuildCfgAttribute, Type>();
        List <BuildCfgAttributeInfo> sortList = new List <BuildCfgAttributeInfo>();

        foreach (Type t in types)
        {
            object[] objs = t.GetCustomAttributes(typeof(BuildCfgAttribute), false);

            if (objs != null && objs.Length > 0)
            {
                BuildCfgAttributeInfo ba = new BuildCfgAttributeInfo();
                ba.att  = objs[0] as BuildCfgAttribute;
                ba.type = t;
                ba.obj  = System.Activator.CreateInstance(t) as IBuildCfg;
                if (ba.att.target != target ||
                    (ba.att.collectionID != -1 && ba.att.collectionID != _collectionID) ||
                    (ba.att.channel != -1 && ba.att.channel != _channel)
                    )
                {
                    continue;
                }

                int pos = 0;
                for (int i = 0; i < sortList.Count; i++)
                {
                    if (sortList[i].att.priority < ba.att.priority)
                    {
                        break;
                    }
                    pos++;
                }
                if (t.IsDefined(typeof(BuildSetBuildOptionAndScenesAttribute), false))
                {
                    buildPlayersetting = ba;
                }

                sortList.Insert(pos, ba);
            }
        }
        return(sortList);
    }