Exemplo n.º 1
0
        void IBundleExporter.Hanlde(List <BundleFile> input)
        {
            string exproterPath = Path.GetFullPath(m_ExproterPath);

            EditorCRUtlity.DeleteDirectory(exproterPath);

            List <string> bundleMd5CodeInfo = new List <string>();

            foreach (var bundleFile in input)
            {
                string outPath         = bundleFile.m_BFType == BundleFile.BFType.Manifest? Path.Combine(exproterPath, "manifest"):  Path.Combine(exproterPath, bundleFile.m_BundleName);
                string outManifestPath = outPath + ".manifest";

                EditorCRUtlity.CopyFile(bundleFile.m_Path, outPath);

                if (bundleFile.m_BFType != BundleFile.BFType.Location)
                {
                    EditorCRUtlity.CopyFile(bundleFile.m_Path + ".manifest", outManifestPath);
                }
                bundleMd5CodeInfo.Add(bundleFile.m_BundleName + " " + EditorCRUtlity.CalauateMD5CodeFile(outPath));
            }

            bundleMd5CodeInfo.Sort();
            File.WriteAllLines(Path.Combine(Path.GetDirectoryName(exproterPath), System.DateTime.Now.ToString("yy-MM-dd-HH-mm-ss") + "bunldeBuild.txt"), bundleMd5CodeInfo.ToArray());
            System.Diagnostics.Process.Start(exproterPath);
        }
        public OperatonUINode(BundleBuildPipeline pipeline, List <Operation> operations, string headName, System.Type attributeType, bool isMultple)
        {
            m_Operations = operations;
            m_IsMultple  = isMultple;

            m_OperationListUI = new ReorderableList(m_Operations, typeof(ScriptableObject), true, true, true, true);
            m_OperationListUI.elementHeight      = 30;
            m_OperationListUI.drawHeaderCallback = (Rect rect) => {
                EditorGUI.LabelField(rect, headName, EditorStyles.boldLabel);
            };

            m_OperationListUI.drawElementCallback = (Rect rect, int index, bool selected, bool focused) =>
            {
                GUI.DrawTexture(new Rect(rect.x, rect.y + 4, 16, 16), EditorGUIUtility.IconContent("ScriptableObject Icon").image as Texture2D);

                EditorGUI.LabelField(new Rect(rect.x + 20, rect.y + 4, rect.width - 20, 16), m_Operations[index].name, EditorStyles.miniBoldLabel);
                if (selected)
                {
                    m_ActiveObject = m_Operations[index];
                }
            };

            m_OperationListUI.onMouseUpCallback = (ReorderableList list) =>
            {
                EditorGUIUtility.PingObject(m_ActiveObject);
            };

            m_OperationListUI.onAddDropdownCallback = (Rect rect, ReorderableList list) =>
            {
                var menu = new GenericMenu();
                List <System.Type> types = EditorCRUtlity.GetTypes(attributeType);

                for (int i = 0; i < types.Count; i++)
                {
                    string itemName = EditorCRUtlity.GetClassName(types[i]);
                    menu.AddItem(new GUIContent(itemName), false,
                                 (object obj) =>
                    {
                        System.Type operatorType = obj as System.Type;
                        Operation noperator      = ScriptableObject.CreateInstance(operatorType) as Operation;
                        noperator.name           = EditorCRUtlity.GetClassName(operatorType);
                        pipeline.AddOperation(m_Operations, noperator, m_IsMultple);
                    },
                                 types[i]);
                }
                menu.ShowAsContext();
            };

            m_OperationListUI.onRemoveCallback = (ReorderableList lis) =>
            {
                pipeline.DeleteOperation(m_Operations, m_ActiveObject);
            };
        }
        void GenerateSharedAssetGroups(Dictionary <string, List <string> > sharedAssets, ref Dictionary <string, AssetFileGroup> sharedGroups)
        {
            foreach (var sAsset in sharedAssets)
            {
                string bundleGUID = sAsset.Value[0];


                if (sAsset.Value.Count > 1)
                {
                    for (int i = 1; i < sAsset.Value.Count; i++)
                    {
                        bundleGUID = EditorCRUtlity.StringOrOperation(bundleGUID, sAsset.Value[i]);
                    }
                    bundleGUID = EditorCRUtlity.CalauateMD5Code(bundleGUID);
                }
                bool isLoadAsset = false;
                if (sAsset.Value.Count == 1)
                {
                    isLoadAsset = true;
                    bundleGUID  = "load/" + bundleGUID;
                }
                else
                {
                    isLoadAsset = false;
                    bundleGUID  = "sharedassets/" + bundleGUID;
                }


                AssetFileGroup group = null;
                if (!sharedGroups.ContainsKey(bundleGUID))
                {
                    group = new AssetFileGroup();
                    group.m_IsLoadAsset = isLoadAsset;
                    group.m_BundleName  = bundleGUID;
                    sharedGroups.Add(bundleGUID, group);
                }
                group = sharedGroups[bundleGUID];
                group.m_AssetFiles.Add(new AssetFile()
                {
                    m_AssetDatabaseId = AssetDatabase.AssetPathToGUID(sAsset.Key),
                    m_FilePath        = sAsset.Key,
                    m_FileLowrPath    = sAsset.Key.ToLower()
                });
            }
        }
        void CollectLoadAndSharedAssets(List <AssetFile> input, ref Dictionary <string, List <string> > sharedAssets)
        {
            Dictionary <string, HashSet <string> > temp = new Dictionary <string, HashSet <string> >();

            foreach (var assetFile in input)
            {
                if (EditorCRUtlity.CyclicReferenceCheck(assetFile.m_FilePath))
                {
                    throw new CResourcesException("Have Cyclic Reference :" + assetFile.m_FilePath);
                }
                string[] deps = AssetDatabase.GetDependencies(assetFile.m_FilePath);
                foreach (var aPath in deps)
                {
                    string extension = System.IO.Path.GetExtension(aPath);
                    if (extension.Equals(".cs") || extension.Equals(".js"))
                    {
                        continue;
                    }

                    HashSet <string> refs;
                    if (!temp.ContainsKey(aPath))
                    {
                        refs = new HashSet <string>();
                        temp.Add(aPath, refs);
                    }
                    else
                    {
                        refs = temp[aPath];
                    }

                    if (!refs.Contains(assetFile.m_AssetDatabaseId))
                    {
                        refs.Add(assetFile.m_AssetDatabaseId);
                    }
                }
            }
            foreach (var item in temp)
            {
                sharedAssets.Add(item.Key, new List <string>(item.Value));
            }
        }