예제 #1
0
    public static void ExportBundlesEx()
    {
        ExportScenesManager.AutoSwitchTarget();
        var dirs = Directory.GetDirectories(ExportScenesManager.GetFolderPath(ExportScenesManager.ExportPath));
        //if (files.Length != 0)
        //{
        var currentVersion = new VersionCodeInfo("0.0.0.1");

        foreach (var item in dirs)
        {
            var fileVersion = new VersionCodeInfo(new DirectoryInfo(item).Name);
            if (fileVersion.Compare(currentVersion) > 0)
            {
                currentVersion = fileVersion;
            }
        }
        //var m_currentVersion = currentVersion.GetLowerVersion();
        var m_newVersion       = currentVersion.ToString();
        var m_newVersionFolder = Path.Combine(ExportScenesManager.GetFolderPath(ExportScenesManager.ExportPath), m_newVersion).Replace("\\", "/");

        var targetPath = m_newVersionFolder + BuildProjectExWizard.ExportFilesPath;

        var selection = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.DeepAssets);
        var paths     = (from s in selection
                         let path = AssetDatabase.GetAssetPath(s)
                                    where File.Exists(path)
                                    select path).ToArray();

        foreach (string item in paths)
        {
            Debug.Log("ex " + item);
            ExportBundle(new string[] { item }, targetPath);
        }
    }
예제 #2
0
    private static void ExportPackedExportable(string path, string exportPath)
    {
        System.Diagnostics.Stopwatch watcher = new System.Diagnostics.Stopwatch();
        watcher.Start();
        exportTimes++;
        if (!File.Exists(path))
        {
            return;
        }
        if (path.EndsWith(".unity"))
        {
#if UNITY_IPHONE
            BuildPipeline.BuildStreamedSceneAssetBundle(new string[] { path }, exportPath, BuildTarget.iOS);
#else
            BuildPipeline.BuildStreamedSceneAssetBundle(new string[] { path }, exportPath, ExportScenesManager.CurrentBuildTarget);
#endif
        }
        else
        {
            var obj = AssetDatabase.LoadMainAssetAtPath(path);
#if UNITY_IPHONE
            if (!BuildPipeline.BuildAssetBundle(obj, null, exportPath, Options, BuildTarget.iOS))
#else
            if (!BuildPipeline.BuildAssetBundle(obj, null, exportPath, Options, ExportScenesManager.CurrentBuildTarget))
#endif

            {
                throw new InvalidOperationException(exportPath + " 导出失败。");
            }
        }
        watcher.Stop();
        ExportScenesManager.LogDebug(exportTimes + "/" + m_dependencyTree.Count + ":" + watcher.ElapsedMilliseconds + "     " + path);
    }
예제 #3
0
    public static void ExportAllBundles()
    {
        ExportScenesManager.AutoSwitchTarget();
        string path     = "Assets/Resources/GUI";
        var    rootPath = ExportScenesManager.GetFolderPath(ExportScenesManager.SubMogoResources);

        fileList.Clear();
        GetSubDir(path);
        var files = fileList.Select(x => x.Replace('\\', '/')).Where(x => x.EndsWith(".prefab")).ToArray();

        ExportScenesManager.LogDebug(files.PackArray('\n'));
        BuildBundleWithRoot(files, rootPath, true);
    }
예제 #4
0
    public static void RemoveGearsScript()
    {
        var gsSpare = ExportScenesManager.GetFromRoot <GameObject>(EXPORT_GEAR_FILE_PATH, true, ".prefab");

        LoggerHelper.Debug("gsSpare: " + gsSpare.Count);

        List <GameObject> gosSpare        = new List <GameObject>();
        Queue <Transform> queueTransSpare = new Queue <Transform>();

        foreach (var gSpare in gsSpare)
        {
            queueTransSpare.Enqueue((gSpare as GameObject).transform);
        }

        while (queueTransSpare.Count != 0)
        {
            Transform temp = queueTransSpare.Dequeue();
            gosSpare.Add(temp.gameObject);
            foreach (Transform child in temp)
            {
                queueTransSpare.Enqueue(child);
            }
        }

        LoggerHelper.Debug("gosSpare: " + gosSpare.Count);

        foreach (GameObject gSpare in gosSpare)
        {
            var gpsSpare = gSpare.GetComponents <GearParent>();
            foreach (var gpSpare in gpsSpare)
            {
                LoggerHelper.Debug("gpSpare: " + gpSpare.name);
                DestroyImmediate(gpSpare, true);
            }

            var gsfxsSpare = gSpare.GetComponents <SfxHandler>();
            foreach (var gsfxSpare in gsfxsSpare)
            {
                DestroyImmediate(gsfxSpare, true);
            }

            var gmotorsSpare = gSpare.GetComponents <MogoSimpleMotor>();
            foreach (var gmotorSpare in gmotorsSpare)
            {
                DestroyImmediate(gmotorSpare, true);
            }
        }
    }
예제 #5
0
    private static void ExportBundle(string[] files, string exportRootPath)
    {
        Clean();
        BuildDependencyTree(files);
        var sorted = (from dependency in m_dependencyTree
                      group dependency by dependency.Value into g
                      select new { Layer = g.Key, Dependencies = from pair in g select pair.Key })
                     .OrderByDescending((x) => x.Layer);

        Debug.Log("statck depth will be " + sorted.Count());
        for (int i = 0; i < sorted.Count(); ++i)
        {
            BuildPipeline.PushAssetDependencies();

            foreach (string dependency in sorted.ElementAt(i).Dependencies)
            {
                Debug.Log("layer " + i + " build " + dependency);
                ExportScenesManager.LogDebug(dependency);
                var relativePath = GetRelativePath(dependency);
                //var exportFileName = ResourceManager.GetExportFileName(relativePath);
                var exportPath = string.Concat(exportRootPath, "/", relativePath);
                //Debug.Log(exportPath);
                var exportDirectory = Path.GetDirectoryName(exportPath);
                if (!Directory.Exists(exportDirectory))
                {
                    Directory.CreateDirectory(exportDirectory);
                }
                IEnumerable <string> lowerDependencies = null;

                if (i < sorted.Count() && i > 0 && dependenciesDic.ContainsKey(dependency) && dependenciesDic[dependency].Count != 0) //
                {
                    lowerDependencies = sorted.ElementAt(i - 1).Dependencies.Where(t => dependenciesDic[dependency].Contains(t));     //修改成获取精确依赖
                }
                if (ExportBundleWithoutMetaData(dependency, Mogo.Util.ResourceManager.WithSuffix(exportPath)))
                {
                    WriteMetaData(exportRootPath, relativePath, lowerDependencies, exportRootPath);
                    ExportScenesManager.LogDebug(exportPath + " 导出成功。");
                }
            }
        }
        for (int i = 0; i < sorted.Count(); ++i)
        {
            BuildPipeline.PopAssetDependencies();
        }
    }
예제 #6
0
 public static void BuildBundleWithRoot(string[] roots, string exportRootPath, bool isMerge = false)
 {
     System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
     sw.Start();
     if (isMerge)
     {
         ExportBundle(roots, exportRootPath);
     }
     else
     {
         foreach (var item in roots)
         {
             ExportBundle(new string[] { item }, exportRootPath);
         }
     }
     sw.Stop();
     ExportScenesManager.LogDebug("cost time: " + sw.ElapsedMilliseconds);
 }
예제 #7
0
    public static void BuildAssetVersion(string[] files, string rootPath)
    {
        Clean();
        var sw = new System.Diagnostics.Stopwatch();

        sw.Start();
        BuildDependencyTree(files);
        sw.Stop();
        ExportScenesManager.LogDebug("BuildDependencyTree time: " + sw.ElapsedMilliseconds);
        //Debug.Log(m_dependencyTree.PackMap(':', '\n'));
        var sorted = (from dependency in m_dependencyTree
                      group dependency by dependency.Value into g
                      select new { Layer = g.Key, Dependencies = from pair in g select pair.Key })
                     .OrderByDescending((x) => x.Layer);
        var count = sorted.Count();

        ExportScenesManager.LogDebug("sorted.Count: " + count);
        for (int i = 0; i < count; ++i)
        {
            foreach (var dependency in sorted.ElementAt(i).Dependencies)
            {
                var relativePath = GetRelativePath(dependency);
                //Debug.Log("relativePath: " + relativePath);
                //var exportFileName = ResourceManager.GetExportFileName(relativePath);
                var exportPath = string.Concat(rootPath, "/", relativePath);
                //Debug.Log("exportPath: " + exportPath);
                //Debug.Log(exportPath);
                var exportDirectory = Path.GetDirectoryName(exportPath);
                if (!Directory.Exists(exportDirectory))
                {
                    Directory.CreateDirectory(exportDirectory);
                }
                IEnumerable <string> lowerDependencies = null;

                if (i < sorted.Count() && i > 0 && dependenciesDic.ContainsKey(dependency) && dependenciesDic[dependency].Count != 0)
                {
                    lowerDependencies = sorted.ElementAt(i - 1).Dependencies.Where(t => dependenciesDic[dependency].Contains(t));//修改成获取精确依赖
                }
                WriteMetaData(rootPath, relativePath, lowerDependencies, Application.dataPath, false);
                //Debug.Log(exportPath + " 生成成功。");
            }
        }
    }
예제 #8
0
    public static void ExportBundles()
    {
        ExportScenesManager.AutoSwitchTarget();
        //ExportScenesManager.CurrentBuildTarget = BuildTarget.StandaloneWindows64;
        var rootPath  = ExportScenesManager.GetFolderPath(ExportScenesManager.SubMogoResources);
        var selection = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.DeepAssets);
        var paths     = (from s in selection
                         let path = AssetDatabase.GetAssetPath(s)
                                    where File.Exists(path)
                                    select path).ToArray();

        foreach (var item in paths)
        {
            ExportBundle(new string[] { item }, rootPath);
        }
        //var shederPath = ExportScenesManager.GetFolderPath("Shader_PC");
        //ExportScenesManager.DirectoryCopy(shederPath, rootPath, true, true);
        //var path = AssetDatabase.GetAssetPath(Selection.activeObject);
        //if (File.Exists(path))
        //    ExportBundleIfNeeded(path, rootPath);
        //else if (Directory.Exists(path))
        //    ExportDirectoryIfNeeded(path);
    }
예제 #9
0
    /// <summary>
    /// Draw the custom wizard.
    /// </summary>
    void OnGUI()
    {
        EditorGUIUtility.LookLikeControls(80f);

        GUILayout.BeginHorizontal();
        GUILayout.Label("当前版本号:", GUILayout.Width(120f));
        v = GUILayout.TextField(v);
        GUILayout.EndHorizontal();

        NGUIEditorTools.DrawSeparator();
        GUILayout.BeginHorizontal();
        bool create = GUILayout.Button("确定", GUILayout.Width(120f));
        bool backup = GUILayout.Button("备份", GUILayout.Width(120f));

        GUILayout.EndHorizontal();
        if (create)
        {
            ExportScenesManager.PackManually(new VersionCodeInfo(v));
        }
        if (backup)
        {
            ExportScenesManager.BackupVersion(new VersionCodeInfo(v));
        }
    }
예제 #10
0
    public static void ExportXmlFile()
    {
        #region Export Gear

        XmlDocument xmldoc = new XmlDocument();
        // xmldoc.Load(Path.Combine(EXPORT_FILE_PATH, EXPORT_FILE_NAME));
        // XmlNode root = xmldoc.GetElementsByTagName("root")[0];

        // int index = root.ChildNodes.Count + 1;

        XmlNode root  = xmldoc.CreateNode(XmlNodeType.Element, "root", "");
        int     index = root.ChildNodes.Count + 1;

        //GameObject[] gos = (GameObject[])(UnityEngine.Object.FindObjectsOfType(typeof(GameObject)));

        var gs = ExportScenesManager.GetFromRoot <GameObject>(GEAR_FILE_PATH, true, ".prefab");

        List <GameObject> gos        = new List <GameObject>();
        Queue <Transform> queueTrans = new Queue <Transform>();

        foreach (var g in gs)
        {
            queueTrans.Enqueue((g as GameObject).transform);
        }

        while (queueTrans.Count != 0)
        {
            Transform temp = queueTrans.Dequeue();
            gos.Add(temp.gameObject);
            foreach (Transform child in temp)
            {
                queueTrans.Enqueue(child);
            }
        }

        if (gos != null)
        {
            LoggerHelper.Debug("All GameObjects Totally: " + gos.Count);

            foreach (GameObject go in gos)
            {
                if (!go)
                {
                    continue;
                }

                LoggerHelper.Debug("GameObject: " + go.name);

                var gps = go.GetComponents <GearParent>();
                if (gps != null)
                {
                    foreach (var g in gps)
                    {
                        Type    t        = g.GetType();
                        XmlNode entities = xmldoc.CreateElement("gears");

                        LoggerHelper.Debug("gear: " + g);

                        XmlNode gearID = xmldoc.CreateElement("id");
                        gearID.InnerText = index.ToString();
                        entities.AppendChild(gearID);
                        index++;

                        XmlNode gearType = xmldoc.CreateElement("type");
                        gearType.InnerText = t.Name;
                        entities.AppendChild(gearType);

                        LoggerHelper.Debug("type: " + t.Name);

                        XmlNode gearGameObjectName = xmldoc.CreateElement("gameObjectName");

                        Transform xmlTransform = go.transform;
                        string    xmlNameStr   = xmlTransform.name;

                        while (xmlTransform.parent != null)
                        {
                            xmlNameStr   = xmlTransform.parent.name + "/" + xmlNameStr;
                            xmlTransform = xmlTransform.parent;
                        }
                        gearGameObjectName.InnerText = xmlNameStr;
                        entities.AppendChild(gearGameObjectName);

                        LoggerHelper.Debug("gameObjectName: " + xmlNameStr);

                        XmlNode gearMapID = xmldoc.CreateElement("map");
                        gearMapID.InnerText = int.Parse(xmlNameStr.Remove(5)).ToString();
                        entities.AppendChild(gearMapID);

                        StringBuilder propName  = new StringBuilder();
                        StringBuilder propType  = new StringBuilder();
                        StringBuilder propValue = new StringBuilder();

                        //foreach (var prop in t.GetFields(~(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.FlattenHierarchy)))
                        foreach (var prop in t.GetFields())
                        {
                            var v = prop.GetValue(g);
                            LoggerHelper.Debug("Field: " + v);

                            Type vt = prop.FieldType;
                            LoggerHelper.Debug("Field Type: " + vt);

                            if (vt.IsArray)
                            {
                                Type pt = vt.GetElementType();

                                if (pt == typeof(AnimationClip))
                                {
                                    propName.Append(prop.Name);
                                    propName.Append("|");
                                    propType.Append(pt.ToString());
                                    propType.Append("|");

                                    var animationChipArray = v as AnimationClip[];

                                    string valueStr = "";

                                    foreach (var animationChip in animationChipArray)
                                    {
                                        valueStr += animationChip.name + "anim";
                                        valueStr += ":";
                                    }

                                    if (valueStr.Length > 0)
                                    {
                                        valueStr.Remove(valueStr.Length - 1, 1);
                                    }

                                    propValue.Append(valueStr);
                                    propValue.Append("|");
                                }
                                else if (pt.IsSubclassOf(typeof(GearParent)) || pt == typeof(GearParent))
                                {
                                    propName.Append(prop.Name);
                                    propName.Append("|");
                                    propType.Append(pt.ToString());
                                    propType.Append("|");

                                    GearParent[] theGearArray = v as GearParent[];

                                    string valueStr      = "";
                                    string innerValueStr = "";

                                    if (theGearArray != null && theGearArray.Length > 0)
                                    {
                                        for (int i = 0; i < theGearArray.Length; i++)
                                        {
                                            var theTransform = theGearArray[i].gameObject.transform;

                                            LoggerHelper.Debug("FFFFFFFFFFFFFFFFFF " + valueStr);

                                            innerValueStr = theTransform.name;

                                            while (theTransform.parent != null)
                                            {
                                                innerValueStr = theTransform.parent.name + "/" + innerValueStr;
                                                theTransform  = theTransform.parent;
                                            }

                                            valueStr += innerValueStr;
                                            valueStr += ":";
                                        }

                                        if (valueStr.Length > 0)
                                        {
                                            valueStr = valueStr.Remove(valueStr.Length - 1, 1);
                                        }

                                        propValue.Append(valueStr);
                                        propValue.Append("|");
                                    }
                                    else
                                    {
                                        propValue.Append("|");
                                    }
                                }
                                else if (pt == typeof(GameObject))
                                {
                                    LoggerHelper.Debug("Going to deal with: " + pt);
                                    propName.Append(prop.Name);
                                    propName.Append("|");
                                    propType.Append(pt.ToString());
                                    propType.Append("|");

                                    GameObject[] theGameOjectArray = v as GameObject[];

                                    string valueStr      = "";
                                    string innerValueStr = "";

                                    if (theGameOjectArray != null && theGameOjectArray.Length > 0)
                                    {
                                        for (int i = 0; i < theGameOjectArray.Length; i++)
                                        {
                                            Transform theTransform = theGameOjectArray[i].transform;

                                            innerValueStr = theTransform.name;

                                            while (theTransform.parent != null)
                                            {
                                                innerValueStr = theTransform.parent.name + "/" + innerValueStr;
                                                theTransform  = theTransform.parent;
                                            }

                                            valueStr += innerValueStr;
                                            valueStr += ":";
                                        }

                                        if (valueStr.Length > 0)
                                        {
                                            valueStr = valueStr.Remove(valueStr.Length - 1, 1);
                                        }

                                        propValue.Append(valueStr);
                                        propValue.Append("|");
                                    }
                                    else
                                    {
                                        propValue.Append("|");
                                    }
                                }
                                else if (pt == typeof(Transform))
                                {
                                    LoggerHelper.Debug("Going to deal with: " + pt);
                                    propName.Append(prop.Name);
                                    propName.Append("|");
                                    propType.Append(pt.ToString());
                                    propType.Append("|");

                                    Transform[] theTransformArray = v as Transform[];

                                    string valueStr      = "";
                                    string innerValueStr = "";

                                    if (theTransformArray != null && theTransformArray.Length > 0)
                                    {
                                        for (int i = 0; i < theTransformArray.Length; i++)
                                        {
                                            Transform theTransform = theTransformArray[i];

                                            innerValueStr = theTransform.name;

                                            while (theTransform.parent != null)
                                            {
                                                innerValueStr = theTransform.parent.name + "/" + innerValueStr;
                                                theTransform  = theTransform.parent;
                                            }

                                            valueStr += innerValueStr;
                                            valueStr += ":";
                                        }

                                        if (valueStr.Length > 0)
                                        {
                                            valueStr = valueStr.Remove(valueStr.Length - 1, 1);
                                        }

                                        propValue.Append(valueStr);
                                        propValue.Append("|");
                                    }
                                    else
                                    {
                                        propValue.Append("|");
                                    }
                                }
                                else if (pt == typeof(Animation))
                                {
                                    LoggerHelper.Debug("Going to deal with: " + pt);
                                    propName.Append(prop.Name);
                                    propName.Append("|");
                                    propType.Append(pt.ToString());
                                    propType.Append("|");

                                    Animation[] theAnimationArray = v as Animation[];

                                    string valueStr      = "";
                                    string innerValueStr = "";

                                    if (theAnimationArray != null && theAnimationArray.Length > 0)
                                    {
                                        for (int i = 0; i < theAnimationArray.Length; i++)
                                        {
                                            Transform theTransform = theAnimationArray[i].gameObject.transform;

                                            innerValueStr = theTransform.name;

                                            while (theTransform.parent != null)
                                            {
                                                innerValueStr = theTransform.parent.name + "/" + innerValueStr;
                                                theTransform  = theTransform.parent;
                                            }

                                            valueStr += innerValueStr;
                                            valueStr += ":";
                                        }

                                        if (valueStr.Length > 0)
                                        {
                                            valueStr = valueStr.Remove(valueStr.Length - 1, 1);
                                        }

                                        propValue.Append(valueStr);
                                        propValue.Append("|");
                                    }
                                    else
                                    {
                                        propValue.Append("|");
                                    }
                                }
                                else if (pt == typeof(Vector3))
                                {
                                    LoggerHelper.Debug("Going to deal with: " + pt);
                                    propName.Append(prop.Name);
                                    propName.Append("|");
                                    propType.Append(pt.ToString());
                                    propType.Append("|");

                                    Vector3[] theVectorArray = v as Vector3[];

                                    string valueStr      = "";
                                    string innerValueStr = "";

                                    if (theVectorArray != null && theVectorArray.Length > 0)
                                    {
                                        for (int i = 0; i < theVectorArray.Length; i++)
                                        {
                                            innerValueStr = theVectorArray[i].x + "," + theVectorArray[i].y + "," + theVectorArray[i].z;

                                            valueStr += innerValueStr;
                                            valueStr += ":";
                                        }

                                        if (valueStr.Length > 0)
                                        {
                                            valueStr = valueStr.Remove(valueStr.Length - 1, 1);
                                        }

                                        propValue.Append(valueStr);
                                        propValue.Append("|");
                                    }
                                    else
                                    {
                                        propValue.Append("|");
                                    }
                                }
                                else if (pt == typeof(int))
                                {
                                    LoggerHelper.Debug("Going to deal with: " + pt);
                                    propName.Append(prop.Name);
                                    propName.Append("|");
                                    propType.Append(pt.ToString());
                                    propType.Append("|");

                                    int[] theIntArray = v as int[];

                                    string valueStr      = "";
                                    string innerValueStr = "";

                                    if (theIntArray != null && theIntArray.Length > 0)
                                    {
                                        for (int i = 0; i < theIntArray.Length; i++)
                                        {
                                            innerValueStr = theIntArray[i].ToString();

                                            valueStr += innerValueStr;
                                            valueStr += ":";
                                        }

                                        if (valueStr.Length > 0)
                                        {
                                            valueStr = valueStr.Remove(valueStr.Length - 1, 1);
                                        }

                                        propValue.Append(valueStr);
                                    }

                                    propValue.Append("|");
                                }
                                else
                                {
                                    LoggerHelper.Debug("Can't find a way for this gear");
                                    propValue.Append("|");

                                    //propName.Append(prop.Name);
                                    //propName.Append(",");
                                    //propType.Append(pt.ToString());
                                    //propType.Append(",");
                                    //propValue.Append(v.ToString());
                                    //propValue.Append(",");
                                }
                            }
                            else
                            {
                                if (vt == typeof(AnimationClip))
                                {
                                    propName.Append(prop.Name);
                                    propName.Append("|");
                                    propType.Append(vt.ToString());
                                    propType.Append("|");

                                    if ((v as AnimationClip) != null)
                                    {
                                        propValue.Append((v as AnimationClip).name + ".anim");
                                    }
                                    else
                                    {
                                        propValue.Append("null.anim");
                                    }

                                    propValue.Append("|");
                                }
                                else if (vt.IsSubclassOf(typeof(GearParent)))
                                {
                                    propName.Append(prop.Name);
                                    propName.Append("|");
                                    propType.Append(vt.ToString());
                                    propType.Append("|");
                                    Transform theTransform = (v as GearParent).gameObject.transform;

                                    string valueStr = theTransform.name;

                                    while (theTransform.parent != null)
                                    {
                                        valueStr     = theTransform.parent.name + "/" + valueStr;
                                        theTransform = theTransform.parent;
                                    }

                                    propValue.Append(valueStr);
                                    propValue.Append("|");
                                }
                                else if (vt == typeof(GameObject))
                                {
                                    LoggerHelper.Debug("Going to deal with: " + vt);
                                    propName.Append(prop.Name);
                                    propName.Append("|");
                                    propType.Append(vt.ToString());
                                    propType.Append("|");
                                    Transform theTransform = (v as GameObject).transform;

                                    string valueStr = theTransform.name;

                                    while (theTransform.parent != null)
                                    {
                                        valueStr     = theTransform.parent.name + "/" + valueStr;
                                        theTransform = theTransform.parent;
                                    }

                                    propValue.Append(valueStr);
                                    propValue.Append("|");
                                }
                                else if (vt == typeof(Animation))
                                {
                                    LoggerHelper.Debug("Going to deal with: " + vt);
                                    propName.Append(prop.Name);
                                    propName.Append("|");
                                    propType.Append(vt.ToString());
                                    propType.Append("|");
                                    Transform theTransform = (v as Animation).gameObject.transform;

                                    if (theTransform != null)
                                    {
                                        string valueStr = theTransform.name;

                                        while (theTransform.parent != null)
                                        {
                                            valueStr     = theTransform.parent.name + "/" + valueStr;
                                            theTransform = theTransform.parent;
                                            LoggerHelper.Debug("Going to deal with: " + valueStr);
                                        }

                                        propValue.Append(valueStr);
                                        propValue.Append("|");
                                    }
                                }
                                else if (vt == typeof(Transform))
                                {
                                    LoggerHelper.Debug("Going to deal with: " + vt);
                                    propName.Append(prop.Name);
                                    propName.Append("|");
                                    propType.Append(vt.ToString());
                                    propType.Append("|");
                                    Transform theTransform = v as Transform;

                                    if (theTransform != null)
                                    {
                                        string valueStr = theTransform.name;

                                        while (theTransform.parent != null)
                                        {
                                            valueStr     = theTransform.parent.name + "/" + valueStr;
                                            theTransform = theTransform.parent;
                                            LoggerHelper.Debug("Going to deal with: " + valueStr);
                                        }

                                        propValue.Append(valueStr);
                                        propValue.Append("|");
                                    }
                                }
                                else if (vt.BaseType == typeof(Enum))
                                {
                                    propName.Append(prop.Name);
                                    propName.Append("|");
                                    propType.Append(vt.ToString());
                                    propType.Append("|");
                                    propValue.Append(Enum.Format(vt, v, "d"));
                                    propValue.Append("|");
                                }
                                else if (vt == typeof(Vector3))
                                {
                                    propName.Append(prop.Name);
                                    propName.Append("|");
                                    propType.Append(vt.ToString());
                                    propType.Append("|");

                                    Vector3 vec = (Vector3)v;
                                    propValue.Append(vec.x + "," + vec.y + "," + vec.z);
                                    propValue.Append("|");
                                }
                                else
                                {
                                    propName.Append(prop.Name);
                                    propName.Append("|");
                                    propType.Append(vt.ToString());
                                    propType.Append("|");
                                    propValue.Append(v.ToString());
                                    propValue.Append("|");
                                }
                            }
                        }
                        string propNameStr  = propName.ToString();
                        string propTypeStr  = propType.ToString();
                        string propValueStr = propValue.ToString();

                        if (propNameStr.Length > 0)
                        {
                            propNameStr = propNameStr.Remove(propNameStr.Length - 1);
                        }

                        if (propTypeStr.Length > 0)
                        {
                            propTypeStr = propTypeStr.Remove(propTypeStr.Length - 1);
                        }

                        if (propValueStr.Length > 0)
                        {
                            propValueStr = propValueStr.Remove(propValueStr.Length - 1);
                        }

                        XmlNode argNames = xmldoc.CreateElement("argNames");
                        argNames.InnerText = propNameStr;
                        entities.AppendChild(argNames);

                        XmlNode argTypes = xmldoc.CreateElement("argTypes");
                        argTypes.InnerText = propTypeStr;
                        entities.AppendChild(argTypes);

                        XmlNode args = xmldoc.CreateElement("args");
                        args.InnerText = propValueStr;
                        entities.AppendChild(args);

                        root.AppendChild(entities);
                        LoggerHelper.Debug("Gear Data Export End");
                    }
                }
            }
            LoggerHelper.Debug("Saving Data");
            xmldoc.AppendChild(root);
            xmldoc.Save(Path.Combine(EXPORT_FILE_PATH, EXPORT_FILE_NAME));
            LoggerHelper.Warning("All Gears Data Export End");
        }

        #endregion


        #region Copy GameObject

        foreach (var g in gs)
        {
            AssetDatabase.CopyAsset(AssetDatabase.GetAssetPath(g), EXPORT_PERFAB_PATH + (g as GameObject).name + ".prefab");
        }

        #endregion
    }
예제 #11
0
    public void OnGUI()
    {
        if (GUILayout.Button("Find Missing Scripts in selected GameObjects"))
        {
            OnDoTask = (com, i, g) =>
            {
                if (com == null)
                {
                    var fullName = GetFullName(g);
                    counter.missingCount++;
                    //Debug.Log(fullName + " has an empty script attached in position: " + i, g);
                    Debug.Log(fullName + " has an empty script attached in position: " + i, g);
                }
            };
            OnTaskFinished = () => { Debug.Log(string.Format("Searched {0} GameObjects, {1} components, found {2} missing", counter.goCount, counter.componentsCount, counter.missingCount)); };
            FindInSelected();
        }
        if (GUILayout.Button("Find Scripts in selected GameObjects"))
        {
            sb       = new System.Text.StringBuilder();
            OnDoTask = (com, i, g) =>
            {
                var typeName = com.GetType().Name;
                if (com is MonoBehaviour && !ExportScenesManager.IngoreFiles.Contains(typeName))
                {
                    var fullName = GetFullName(g);
                    counter.missingCount++;
                    sb.AppendLine(String.Concat(fullName, ": ", typeName));
                }
            };
            OnTaskFinished = () =>
            {
                var path = ExportScenesManager.GetFolderPath("") + "//ScriptUsingInfo.txt";
                Mogo.Util.XMLParser.SaveText(path.Replace("\\", "/"), sb.ToString());
                Debug.Log("Find finished, total script using is " + counter.missingCount + ", please check 'ScriptUsingInfo.txt' in project folder.");
            };
            FindInSelected();
        }
        if (GUILayout.Button("Find Null UISprite Scripts"))
        {
            sb       = new System.Text.StringBuilder();
            OnDoTask = (com, i, g) =>
            {
                var typeName = com.GetType().Name;
                var spri     = com as UISprite;
                if (spri != null)
                {
                    var fullName = GetFullName(g);
                    if (spri.atlas == null)
                    {
                        sb.AppendLine(String.Concat("atlas null: ", fullName, ": ", typeName));
                    }
                    else
                    {
                        if (spri.atlas.GetSprite(spri.spriteName) == null)
                        {
                            counter.missingCount++;
                            sb.AppendLine(String.Concat(fullName, ": ", typeName));
                        }
                    }
                }
            };
            OnTaskFinished = () =>
            {
                var path = ExportScenesManager.GetFolderPath("") + "//NullUISprite.txt";
                Mogo.Util.XMLParser.SaveText(path.Replace("\\", "/"), sb.ToString());
                Debug.Log("Find finished, total Null UISprite is " + counter.missingCount + ", please check 'NullUISprite.txt' in project folder.");
            };
            FindInSelected();
        }

        GUILayout.Label(info);
    }
예제 #12
0
 public static void ShowWindow()
 {
     EditorWindow.GetWindow(typeof(FindMissingScriptsRecursively));
     ExportScenesManager.GetFindScriptIngoreList();
 }
예제 #13
0
 private void Export()
 {
     ExportScenesManager.Export(currentVersion, newVersion);
 }