示例#1
0
    public void _1_7_RunBundlizer()
    {
        GraphStackController.CleanCache();
        EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.iOS);

        var importedPath = "Assets/AssetGraphTest/PrefabricatorTestResource/SpanPath/a.png";

        var source = new Dictionary <string, List <InternalAssetData> > {
            { "0",
              new List <InternalAssetData> {
                  InternalAssetData.InternalAssetDataByImporter(
                      "traceId_1_7_RunBundlizer",
                      Path.Combine(Application.dataPath, importedPath),
                      Application.dataPath,
                      Path.GetFileName(importedPath),
                      string.Empty,
                      importedPath,
                      AssetDatabase.AssetPathToGUID(importedPath),
                      AssetGraphInternalFunctions.GetAssetType(importedPath)
                      )
              } }
        };

        var results = new Dictionary <string, List <InternalAssetData> >();

        var bundleNameTemplate = "a_*.bundle";

        var integratedGUIBundlizer = new IntegratedGUIBundlizer(bundleNameTemplate);
        Action <string, string, Dictionary <string, List <InternalAssetData> >, List <string> > Out = (string nodeId, string connectionId, Dictionary <string, List <InternalAssetData> > output, List <string> cached) => {
            results[connectionId] = output["0"];
        };

        integratedGUIBundlizer.Run("ID_1_7_RunBundlizer", "CONNECTION_1_7_RunBundlizer", string.Empty, source, new List <string>(), Out);

        var currentOutputs = results["CONNECTION_1_7_RunBundlizer"];

        if (currentOutputs.Count == 1)
        {
            // should be a_0.bundle
            if (currentOutputs[0].pathUnderConnectionId != "iOS/a_0.bundle.ios")
            {
                Debug.LogError("failed to bundlize, name not match:" + currentOutputs[0].pathUnderConnectionId);
                return;
            }

            // passed, erase bundle name setting.
            var bundledAssetSourcePath = "Assets/AssetGraphTest/PrefabricatorTestResource/SpanPath/a.png";
            if (!File.Exists(bundledAssetSourcePath))
            {
                Debug.LogError("failed to delete bundle setting. bundledAssetSourcePath:" + bundledAssetSourcePath);
                return;
            }

            var assetImporter = AssetImporter.GetAtPath(bundledAssetSourcePath);
            assetImporter.assetBundleName = string.Empty;
            return;
        }

        Debug.LogError("failed to bundlize");
    }
示例#2
0
    public void _1_3_RunImporter()
    {
        var projectFolderPath = Directory.GetParent(Application.dataPath).ToString();
        var definedSourcePath = Path.Combine(projectFolderPath, "TestResources/TestResources0/");

        var source = new Dictionary <string, List <InternalAssetData> > {
            { "0",
              new List <InternalAssetData> {
                  InternalAssetData.InternalAssetDataByLoader(Path.Combine(definedSourcePath, "dummy.png"), definedSourcePath),
                  InternalAssetData.InternalAssetDataByLoader(Path.Combine(definedSourcePath, "model/sample.fbx"), definedSourcePath)
              } }
        };

        var results = new Dictionary <string, List <InternalAssetData> >();

        var integratedGUIImporter = new IntegratedGUIImporter(AssetGraphSettings.PLATFORM_DEFAULT_NAME);
        Action <string, string, Dictionary <string, List <InternalAssetData> >, List <string> > Out = (string nodeId, string connectionId, Dictionary <string, List <InternalAssetData> > output, List <string> cached) => {
            results[connectionId] = output["0"];
        };

        integratedGUIImporter.Run("ID_1_3_RunImporter", "CONNECTION_1_3_RunImporter", string.Empty, source, new List <string>(), Out);

        var currentOutputs = results["CONNECTION_1_3_RunImporter"].Where(path => !GraphStackController.IsMetaFile(path.importedPath)).ToList();

        if (currentOutputs.Count == 3)
        {
            Debug.Log("passed _1_3_RunImporter");
            return;
        }

        Debug.LogError("failed to collect importerd resource:" + currentOutputs.Count);
    }
示例#3
0
    // there is no GUI Prefabricator.

    public void _1_6_SetupBundlizer()
    {
        GraphStackController.CleanCache();

        var importedPath = "Assets/AssetGraphTest/PrefabricatorTestResource/SpanPath/a.png";

        var source = new Dictionary <string, List <InternalAssetData> > {
            { "0",
              new List <InternalAssetData> {
                  InternalAssetData.InternalAssetDataByImporter(
                      "traceId_1_6_SetupBundlizer",
                      Path.Combine(Application.dataPath, importedPath),
                      Application.dataPath,
                      Path.GetFileName(importedPath),
                      string.Empty,
                      importedPath,
                      AssetDatabase.AssetPathToGUID(importedPath),
                      AssetGraphInternalFunctions.GetAssetType(importedPath)
                      )
              } }
        };

        var results = new Dictionary <string, List <InternalAssetData> >();

        var bundleNameTemplate = "a_*.bundle";

        var integratedGUIBundlizer = new IntegratedGUIBundlizer(bundleNameTemplate);
        Action <string, string, Dictionary <string, List <InternalAssetData> >, List <string> > Out = (string nodeId, string connectionId, Dictionary <string, List <InternalAssetData> > output, List <string> cached) => {
            results[connectionId] = output["0"];
        };

        integratedGUIBundlizer.Setup("ID_1_6_SetupBundlizer", "CONNECTION_1_6_SetupBundlizer", string.Empty, source, new List <string>(), Out);
        Debug.Log("passed _1_6_SetupBundlizer");
    }
示例#4
0
    public void _1_9_RunStackedGraph()
    {
        GraphStackController.CleanCache();

        var basePath      = Path.Combine(Application.dataPath, "AssetGraphTest/Editor/TestData");
        var graphDataPath = Path.Combine(basePath, "_1_9_RunStackedGraph.json");

        // load
        var dataStr = string.Empty;

        using (var sr = new StreamReader(graphDataPath)) {
            dataStr = sr.ReadToEnd();
        }
        var graphDict = Json.Deserialize(dataStr) as Dictionary <string, object>;

        GraphStackController.RunStackedGraph(graphDict, string.Empty);

        var projectFolderPath      = Directory.GetParent(Application.dataPath).ToString();
        var expectedExportDestPath = Path.Combine(projectFolderPath, "TestExportPlace/For_1_9_SerializedGraphJSONByExporter");

        if (File.Exists(Path.Combine(expectedExportDestPath, "iOS/model/Materials/kiosk_0001.mat")) &&
            File.Exists(Path.Combine(expectedExportDestPath, "iOS/model/sample.fbx")) &&
            File.Exists(Path.Combine(expectedExportDestPath, "iOS/dummy.png"))
            )
        {
            Debug.Log("passed _1_9_RunStackedGraph");
            return;
        }

        Debug.LogError("failed to export");
    }
示例#5
0
    public void _1_2_SetupImporter()
    {
        GraphStackController.CleanCache();

        var projectFolderPath = Directory.GetParent(Application.dataPath).ToString();
        var definedSourcePath = Path.Combine(projectFolderPath, "TestResources/TestResources0/");

        var source = new Dictionary <string, List <InternalAssetData> > {
            { "0",
              new List <InternalAssetData> {
                  InternalAssetData.InternalAssetDataByLoader(Path.Combine(definedSourcePath, "dummy.png"), definedSourcePath),
                  InternalAssetData.InternalAssetDataByLoader(Path.Combine(definedSourcePath, "model/sample.fbx"), definedSourcePath)
              } }
        };

        var results = new Dictionary <string, List <InternalAssetData> >();

        var integratedGUIImporter = new IntegratedGUIImporter(AssetGraphSettings.PLATFORM_DEFAULT_NAME);
        Action <string, string, Dictionary <string, List <InternalAssetData> >, List <string> > Out = (string nodeId, string connectionId, Dictionary <string, List <InternalAssetData> > output, List <string> cached) => {
            results[connectionId] = output["0"];
        };

        integratedGUIImporter.Setup("ID_1_2_SetupImporter", "CONNECTION_1_2_SetupImporter", string.Empty, source, new List <string>(), Out);
        Debug.Log("passed _1_2_SetupImporter");
    }
示例#6
0
    public void _1_13_SetupStackedGraph_FullStacked()
    {
        GraphStackController.CleanCache();

        var basePath      = Path.Combine(Application.dataPath, "AssetGraphTest/Editor/TestData");
        var graphDataPath = Path.Combine(basePath, "_1_12_RunStackedGraph_FullStacked.json");

        // load
        var dataStr = string.Empty;

        using (var sr = new StreamReader(graphDataPath)) {
            dataStr = sr.ReadToEnd();
        }
        var graphDict = Json.Deserialize(dataStr) as Dictionary <string, object>;

        var resultDict = GraphStackController.SetupStackedGraph(graphDict, string.Empty);

        // 11 is count of connections. 3 is count of end nodes.
        if (resultDict.Count == 11 + 3)
        {
            Debug.Log("passed _1_13_SetupStackedGraph_FullStacked");
            return;
        }

        Debug.LogError("shortage or excess of connections:" + resultDict.Count);
    }
示例#7
0
    public void _1_0_1_RunLoader()
    {
        GraphStackController.CleanCache();

        // contains 2 resources.
        var projectFolderPath = Directory.GetParent(Application.dataPath).ToString();
        var definedSourcePath = Path.Combine(projectFolderPath, "TestResources/TestResources0/");

        var emptySource = new Dictionary <string, List <InternalAssetData> >();

        var results = new Dictionary <string, List <InternalAssetData> >();

        var integratedGUILoader = new IntegratedGUILoader(definedSourcePath);
        Action <string, string, Dictionary <string, List <InternalAssetData> >, List <string> > Out = (string nodeId, string connectionId, Dictionary <string, List <InternalAssetData> > output, List <string> cached) => {
            results[connectionId] = output["0"];
        };

        integratedGUILoader.Run("ID_1_0_1_RunLoader", "CONNECTION_1_0_1_RunLoader", string.Empty, emptySource, new List <string>(), Out);

        var outputs = results["CONNECTION_1_0_1_RunLoader"];

        if (outputs.Count == 2)
        {
            Debug.Log("passed _1_0_1_RunLoader");
            return;
        }

        Debug.LogError("not match 2, actual:" + outputs.Count);
    }
示例#8
0
    public void _1_15_RunStackedGraph_Sample()
    {
        GraphStackController.CleanCache();

        var basePath      = Path.Combine(Application.dataPath, "AssetGraphTest/Editor/TestData");
        var graphDataPath = Path.Combine(basePath, "_1_14_RunStackedGraph_Sample.json");

        // load
        var dataStr = string.Empty;

        using (var sr = new StreamReader(graphDataPath)) {
            dataStr = sr.ReadToEnd();
        }
        var graphDict = Json.Deserialize(dataStr) as Dictionary <string, object>;

        GraphStackController.RunStackedGraph(graphDict, string.Empty);

        var projectFolderPath      = Directory.GetParent(Application.dataPath).ToString();
        var expectedExportDestPath = Path.Combine(projectFolderPath, "TestExportPlace/TestExportFor_1_14_RunStackedGraph_Sample");

        var the1stBundlePath = Path.Combine(expectedExportDestPath, "iOS/chara_0.assetbundle.ios");
        var the2ndBundlePath = Path.Combine(expectedExportDestPath, "iOS/chara_1.assetbundle.ios");
        var soundBundlePath  = Path.Combine(expectedExportDestPath, "iOS/sounds_0.assetbundle.ios");

        if (
            File.Exists(the1stBundlePath) &&
            File.Exists(the2ndBundlePath) &&
            File.Exists(soundBundlePath))
        {
            Debug.Log("passed _1_15_RunStackedGraph_Sample");
            return;
        }

        Debug.LogError("failed to generate");
    }
示例#9
0
        public static void RemoveBundleSettings(string nodePath)
        {
            EditorUtility.DisplayProgressBar("AssetBundleGraph unbundlize all resources...", nodePath, 0);
            var filePathsInFolder = FileController.FilePathsInFolder(nodePath);

            foreach (var filePath in filePathsInFolder)
            {
                if (GraphStackController.IsMetaFile(filePath))
                {
                    continue;
                }
                if (GraphStackController.ContainsHiddenFiles(filePath))
                {
                    continue;
                }
                var assetImporter = AssetImporter.GetAtPath(filePath);

                // assetImporter is null when the asset is not accepted by Unity.
                // e.g. file.my_new_extension is ignored by Unity.
                if (assetImporter == null)
                {
                    continue;
                }

                if (assetImporter.GetType() == typeof(UnityEditor.MonoImporter))
                {
                    continue;
                }

                assetImporter.assetBundleName = string.Empty;
            }
            EditorUtility.ClearProgressBar();
        }
示例#10
0
    public void _1_8_0_SerializeGraph_hasValidEndpoint()
    {
        GraphStackController.CleanCache();

        var basePath      = Path.Combine(Application.dataPath, "AssetGraphTest/Editor/TestData");
        var graphDataPath = Path.Combine(basePath, "_1_8_SerializeGraph.json");

        // load
        var dataStr = string.Empty;

        using (var sr = new StreamReader(graphDataPath)) {
            dataStr = sr.ReadToEnd();
        }

        var graphDict = Json.Deserialize(dataStr) as Dictionary <string, object>;

        var endpointNodeIdsAndNodeDatas = GraphStackController.SerializeNodeRoute(graphDict, string.Empty);

        if (endpointNodeIdsAndNodeDatas.endpointNodeIds.Contains("2nd_Importer"))
        {
            Debug.Log("passed _1_8_0_SerializeGraph_hasValidEndpoint");
            return;
        }

        Debug.LogError("not valid endpoint");
    }
示例#11
0
    public void _1_10_SetupExporter()
    {
        GraphStackController.CleanCache();

        var projectFolderPath = Directory.GetParent(Application.dataPath).ToString();
        var exportFilePath    = Path.Combine(projectFolderPath, "TestExportPlace/For_1_10_SetupExport");

        // delete all if exist
        if (Directory.Exists(exportFilePath))
        {
            Directory.Delete(exportFilePath, true);
        }

        Directory.CreateDirectory(exportFilePath);

        var importedPath = "Assets/AssetGraphTest/ExporterTestResource/SpanTempPath/SpanPath/a.png";
        var assetId      = AssetDatabase.AssetPathToGUID(importedPath);
        var assetType    = AssetGraphInternalFunctions.GetAssetType(importedPath);

        var exportTargets = new Dictionary <string, List <InternalAssetData> > {
            { "0",
              new List <InternalAssetData> {
                  InternalAssetData.InternalAssetDataGeneratedByImporterOrPrefabricator(importedPath, assetId, assetType, true),
              } }
        };

        var integratedGUIExporter = new IntegratedGUIExporter(exportFilePath);
        Action <string, string, Dictionary <string, List <InternalAssetData> >, List <string> > Out = (string nodeId, string connectionId, Dictionary <string, List <InternalAssetData> > output, List <string> cached) => {
        };

        integratedGUIExporter.Setup("ID_1_10_SetupExport", "CONNECTION_1_10_SetupExport", string.Empty, exportTargets, new List <string>(), Out);
        Debug.Log("passed _1_10_SetupExporter");
    }
示例#12
0
        public string BundlizeAssets(string groupkey, List <InternalAssetData> sources, string recommendedBundleOutputDir, bool isRun)
        {
            var invalids = new List <string>();

            foreach (var source in sources)
            {
                if (string.IsNullOrEmpty(source.importedPath))
                {
                    invalids.Add(source.pathUnderSourceBase);
                }
            }
            if (invalids.Any())
            {
                throw new Exception("bundlizer:" + string.Join(", ", invalids.ToArray()) + " is not imported yet, should import before bundlize.");
            }

            var bundleName = bundleNameTemplate;

            /*
             *      if contains KEYWORD_WILDCARD, use group identifier to bundlize name.
             */
            if (bundleNameTemplate.Contains(AssetBundleGraphSettings.KEYWORD_WILDCARD))
            {
                var templateHead = bundleNameTemplate.Split(AssetBundleGraphSettings.KEYWORD_WILDCARD)[0];
                var templateTail = bundleNameTemplate.Split(AssetBundleGraphSettings.KEYWORD_WILDCARD)[1];

                bundleName = (templateHead + groupkey + templateTail + "." + GraphStackController.Platform_Dot_Package()).ToLower();
            }

            var bundlePath = FileController.PathCombine(recommendedBundleOutputDir, bundleName);

            foreach (var source in sources)
            {
                // if already bundled in this running, avoid changing that name.
                if (source.isBundled)
                {
                    continue;
                }

                if (isRun)
                {
                    if (GraphStackController.IsMetaFile(source.importedPath))
                    {
                        continue;
                    }
                    var assetImporter = AssetImporter.GetAtPath(source.importedPath);
                    if (assetImporter == null)
                    {
                        continue;
                    }
                    assetImporter.assetBundleName = bundleName;
                }

                // set as this resource is already bundled.
                source.isBundled = true;
            }

            return(bundlePath);
        }
示例#13
0
        public void Run(string nodeId, string labelToNext, string package, Dictionary <string, List <InternalAssetData> > groupedSources, List <string> alreadyCached, Action <string, string, Dictionary <string, List <InternalAssetData> >, List <string> > Output)
        {
            var recommendedBundleOutputDir = FileController.PathCombine(AssetGraphSettings.BUNDLIZER_CACHE_PLACE, nodeId);

            FileController.RemakeDirectory(recommendedBundleOutputDir);

            var outputDict = new Dictionary <string, List <InternalAssetData> >();

            foreach (var groupKey in groupedSources.Keys)
            {
                var inputSources = groupedSources[groupKey];

                var assets = new List <AssetInfo>();
                foreach (var assetData in inputSources)
                {
                    var assetName = assetData.fileNameAndExtension;
                    var assetType = assetData.assetType;
                    var assetPath = assetData.importedPath;
                    var assetId   = assetData.assetId;
                    assets.Add(new AssetInfo(assetName, assetType, assetPath, assetId));
                }

                var localFilePathsBeforeBundlize = FileController.FilePathsInFolder(AssetGraphSettings.UNITY_LOCAL_DATAPATH);
                try {
                    In(groupKey, assets, recommendedBundleOutputDir);
                } catch (Exception e) {
                    Debug.LogError("Bundlizer:" + this + " error:" + e);
                }

                AssetDatabase.Refresh(ImportAssetOptions.ImportRecursive);
                AssetDatabase.SaveAssets();

                var localFilePathsAfterBundlize = FileController.FilePathsInFolder(AssetGraphSettings.UNITY_LOCAL_DATAPATH);

                var outputSources = new List <InternalAssetData>();

                var generatedAssetBundlePaths = localFilePathsAfterBundlize.Except(localFilePathsBeforeBundlize);

                foreach (var newAssetPath in generatedAssetBundlePaths)
                {
                    if (GraphStackController.IsMetaFile(newAssetPath))
                    {
                        continue;
                    }
                    var newAssetData = InternalAssetData.InternalAssetDataGeneratedByImporterOrPrefabricator(
                        newAssetPath,
                        AssetDatabase.AssetPathToGUID(newAssetPath),
                        AssetGraphInternalFunctions.GetAssetType(newAssetPath),
                        true,
                        false
                        );
                    outputSources.Add(newAssetData);
                }

                outputDict[groupKey] = outputSources;
            }

            Output(nodeId, labelToNext, outputDict, new List <string>());
        }
示例#14
0
    public void _0_5_RunPrefabricator()
    {
        GraphStackController.CleanCache();

        var importedPath = "Assets/AssetGraphTest/PrefabricatorTestResource/SpanPath/a.png";

        var source = new Dictionary <string, List <InternalAssetData> > {
            { "0",
              new List <InternalAssetData> {
                  InternalAssetData.InternalAssetDataByImporter(
                      "traceId_0_5_RunPrefabricator",
                      Path.Combine(Application.dataPath, importedPath),
                      Application.dataPath,
                      Path.GetFileName(importedPath),
                      string.Empty,
                      importedPath,
                      AssetDatabase.AssetPathToGUID(importedPath),
                      AssetGraphInternalFunctions.GetAssetType(importedPath)
                      )
              } }
        };

        var results = new Dictionary <string, List <InternalAssetData> >();

        var sPrefabricator = new SamplePrefabricator_0();
        Action <string, string, Dictionary <string, List <InternalAssetData> >, List <string> > Out = (string nodeId, string connectionId, Dictionary <string, List <InternalAssetData> > output, List <string> cached) => {
            results[connectionId] = output["0"];
        };

        sPrefabricator.Run("ID_0_5_RunPrefabricator", "CONNECTION_0_5_RunPrefabricator", string.Empty, source, new List <string>(), Out);

        var currentOutputs = results["CONNECTION_0_5_RunPrefabricator"].Where(assetData => !GraphStackController.IsMetaFile(assetData.importedPath)).ToList();

        if (currentOutputs.Count == 3)
        {
            // material.mat
            // prefab.prefab
            // a.png

            if (!currentOutputs[0].fileNameAndExtension.Contains("material.mat"))
            {
                Debug.LogError("not contained 'material.mat'");
            }
            if (!currentOutputs[1].fileNameAndExtension.Contains("prefab.prefab"))
            {
                Debug.LogError("not contained 'prefab.prefab'");
            }
            if (!currentOutputs[2].fileNameAndExtension.Contains("a.png"))
            {
                Debug.LogError("not contained 'a.png'");
            }

            Debug.Log("passed _0_5_RunPrefabricator");
            return;
        }

        Debug.LogError("failed to prefabricate:" + currentOutputs.Count);
    }
示例#15
0
        /**
         *      returns file paths which are located in the folder.
         *
         *      this method is main point for supporting path format of cross platform.
         *
         *      Usually Unity Editor uses '/' as folder delimter.
         *
         *      e.g.
         *              Application.dataPath returns
         *                      C:/somewhere/projectPath/Assets @ Windows.
         *                              or
         *                      /somewhere/projectPath/Assets @ Mac, Linux.
         *
         *
         *      but "Directory.GetFiles(localFolderPath + "/")" method returns different formatted path by platform.
         *
         *      @ Windows:
         *              localFolderPath + / + somewhere\folder\file.extention
         *
         *      @ Mac/Linux:
         *              localFolderPath + / + somewhere/folder/file.extention
         *
         *      the problem is, "Directory.GetFiles" returns mixed format path of files @ Windows.
         *      this is the point of failure.
         *
         *      this method replaces folder delimiters to '/'.
         */
        public static List <string> FilePathsInFolderOnly1Level(string localFolderPath)
        {
            // change platform-depends folder delimiter -> '/'
            var filePaths = ConvertSeparater(Directory.GetFiles(localFolderPath)
                                             .Where(path => !(Path.GetFileName(path).StartsWith(AssetGraphSettings.DOTSTART_HIDDEN_FILE_HEADSTRING)))
                                             .ToList());

            if (AssetGraphSettings.IGNORE_META)
            {
                filePaths = filePaths.Where(path => !GraphStackController.IsMetaFile(path)).ToList();
            }

            return(filePaths);
        }
示例#16
0
        private void DoInspectorGroupingGUI(Node node)
        {
            if (node.groupingKeyword == null)
            {
                return;
            }

            EditorGUILayout.HelpBox("Grouping: Create group of assets.", MessageType.Info);
            UpdateNodeName(node);

            GUILayout.Space(10f);

            node.currentPlatform = UpdateCurrentPlatform(node.currentPlatform);

            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                var newGroupingKeyword = EditorGUILayout.TextField(
                    "Grouping Keyword",
                    GraphStackController.ValueFromPlatformAndPackage(
                        node.groupingKeyword.ReadonlyDict(),
                        node.currentPlatform
                        ).ToString()
                    );
                EditorGUILayout.HelpBox("Grouping Keyword requires \"*\" in itself. It assumes there is a pattern such as \"ID_0\" in incoming paths when configured as \"ID_*\" ", MessageType.Info);


                IntegratedGUIGrouping.ValidateGroupingKeyword(
                    newGroupingKeyword,
                    () => {
//						EditorGUILayout.HelpBox("groupingKeyword is empty.", MessageType.Error);
                },
                    () => {
//						EditorGUILayout.HelpBox("grouping keyword does not contain " + AssetBundleGraphSettings.KEYWORD_WILDCARD + " groupingKeyword:" + newGroupingKeyword, MessageType.Error);
                }
                    );

                if (newGroupingKeyword != GraphStackController.ValueFromPlatformAndPackage(
                        node.groupingKeyword.ReadonlyDict(),
                        node.currentPlatform
                        ).ToString()
                    )
                {
                    node.BeforeSave();
                    node.groupingKeyword.Add(GraphStackController.Platform_Package_Key(node.currentPlatform), newGroupingKeyword);
                    node.Save();
                }
            }

            UpdateDeleteSetting(node);
        }
示例#17
0
    public void _1_0_SetupFilter()
    {
        GraphStackController.CleanCache();

        var source = new Dictionary <string, List <InternalAssetData> > {
            { "0",
              new List <InternalAssetData> {
                  InternalAssetData.InternalAssetDataByLoader("A/1st", "A"),
                  InternalAssetData.InternalAssetDataByLoader("A/2nd", "A")
              } }
        };

        var results = new Dictionary <string, List <InternalAssetData> >();

        var keywords = new List <string> {
            "A/1st", "A/2nd"
        };

        var integratedGUIFilter = new IntegratedGUIFilter(keywords);
        Action <string, string, Dictionary <string, List <InternalAssetData> >, List <string> > Out = (string nodeId, string connectionId, Dictionary <string, List <InternalAssetData> > output, List <string> cached) => {
            results[connectionId] = output["0"];
        };

        integratedGUIFilter.Setup("ID_1_0_SetupFilter", "CONNECTION_1_0_SetupFilter", string.Empty, source, new List <string>(), Out);

        /*
         *      in GUI Filter, output result connection id is it's keyword.
         */
        if (results.ContainsKey("A/1st"))
        {
            var result1 = results["A/1st"];

            if (result1[0].absoluteSourcePath == "A/1st")
            {
                if (results.ContainsKey("A/2nd"))
                {
                    var resut2 = results["A/2nd"];
                    if (resut2[0].absoluteSourcePath == "A/2nd")
                    {
                        Debug.Log("passed _1_0_SetupFilter");
                        return;
                    }
                }
            }
        }

        Debug.LogError("failed to split by filter");
    }
示例#18
0
    public void _0_7_RunBundlizer()
    {
        GraphStackController.CleanCache();

        var importedPath = "Assets/AssetGraphTest/PrefabricatorTestResource/SpanPath/a.png";

        var source = new Dictionary <string, List <InternalAssetData> > {
            { "0",
              new List <InternalAssetData> {
                  InternalAssetData.InternalAssetDataByImporter(
                      "traceId_0_7_RunBundlizer",
                      Path.Combine(Application.dataPath, importedPath),
                      Application.dataPath,
                      Path.GetFileName(importedPath),
                      string.Empty,
                      importedPath,
                      AssetDatabase.AssetPathToGUID(importedPath),
                      AssetGraphInternalFunctions.GetAssetType(importedPath)
                      )
              } }
        };

        var results = new Dictionary <string, List <InternalAssetData> >();

        var sBundlizer = new SampleBundlizer_0();
        Action <string, string, Dictionary <string, List <InternalAssetData> >, List <string> > Out = (string nodeId, string connectionId, Dictionary <string, List <InternalAssetData> > output, List <string> cached) => {
            results[connectionId] = output["0"];
        };

        sBundlizer.Run("ID_0_7_RunBundlizer", "CONNECTION_0_7_RunBundlizer", string.Empty, source, new List <string>(), Out);

        var currentOutputs = results["CONNECTION_0_7_RunBundlizer"];

        if (currentOutputs.Count == 1)
        {
            // should be bundle.assetbundle
            if (currentOutputs[0].pathUnderConnectionId != "bundle.assetbundle")
            {
                Debug.LogError("failed to bundlize, name not match:" + currentOutputs[0].pathUnderConnectionId);
                return;
            }

            Debug.Log("passed _0_7_RunBundlizer");
            return;
        }

        Debug.LogError("failed to bundlize");
    }
        private void RemoveBundleSettings(string nodePath)
        {
            EditorUtility.DisplayProgressBar("AssetGraph BundleBuilder unbundlize resources...", nodePath, 0);
            var filePathsInFolder = FileController.FilePathsInFolder(nodePath);

            foreach (var filePath in filePathsInFolder)
            {
                if (GraphStackController.IsMetaFile(filePath))
                {
                    continue;
                }
                var assetImporter = AssetImporter.GetAtPath(filePath);
                assetImporter.assetBundleName = string.Empty;
            }
            EditorUtility.ClearProgressBar();
        }
        private void RemoveOtherPlatformAndPackageBundleSettings(List <string> nodeIds, string package)
        {
            if (!Directory.Exists(AssetGraphSettings.APPLICATIONDATAPATH_CACHE_PATH))
            {
                return;
            }

            /*
             *      get all cache folder of node from cache path.
             */
            var cachedNodeKindFolderPaths = FileController.FolderPathsInFolder(AssetGraphSettings.APPLICATIONDATAPATH_CACHE_PATH);

            foreach (var cachedNodeKindFolderPath in cachedNodeKindFolderPaths)
            {
                var nodeIdFolderPaths = FileController.FolderPathsInFolder(cachedNodeKindFolderPath);
                foreach (var nodeIdFolderPath in nodeIdFolderPaths)
                {
                    var nodeIdFromFolder = nodeIdFolderPath.Split(AssetGraphSettings.UNITY_FOLDER_SEPARATOR).Last();

                    // remove all bundle settings from unrelated nodes.
                    if (!nodeIds.Contains(nodeIdFromFolder))
                    {
                        RemoveBundleSettings(nodeIdFolderPath);
                        continue;
                    }

                    // related nodes, contains platform_package folder.

                    // remove all bundle settings from unrelated platforms + packages.
                    var platformFolderPaths = FileController.FolderPathsInFolder(nodeIdFolderPath);
                    foreach (var platformFolderPath in platformFolderPaths)
                    {
                        var platformNameFromFolder = platformFolderPath.Split(AssetGraphSettings.UNITY_FOLDER_SEPARATOR).Last();

                        if (platformNameFromFolder == GraphStackController.Current_Platform_Package_Folder(package))
                        {
                            continue;
                        }

                        RemoveBundleSettings(platformFolderPath);
                    }
                }
            }
        }
示例#21
0
    public void _1_8_1_SerializeGraph_hasValidOrder()
    {
        GraphStackController.CleanCache();

        var basePath      = Path.Combine(Application.dataPath, "AssetGraphTest/Editor/TestData");
        var graphDataPath = Path.Combine(basePath, "_1_8_SerializeGraph.json");

        // load
        var dataStr = string.Empty;

        using (var sr = new StreamReader(graphDataPath)) {
            dataStr = sr.ReadToEnd();
        }


        var graphDict = Json.Deserialize(dataStr) as Dictionary <string, object>;

        var endpointNodeIdsAndNodeDatasAndConnectionDatas = GraphStackController.SerializeNodeRoute(graphDict, string.Empty);

        var endPoint0       = endpointNodeIdsAndNodeDatasAndConnectionDatas.endpointNodeIds[0];
        var nodeDatas       = endpointNodeIdsAndNodeDatasAndConnectionDatas.nodeDatas;
        var connectionDatas = endpointNodeIdsAndNodeDatasAndConnectionDatas.connectionDatas;

        var resultDict           = new Dictionary <string, Dictionary <string, List <InternalAssetData> > >();
        var cacheDict            = new Dictionary <string, List <string> >();
        var orderedConnectionIds = GraphStackController.RunSerializedRoute(endPoint0, nodeDatas, connectionDatas, resultDict, cacheDict, string.Empty);

        if (orderedConnectionIds.Count == 0)
        {
            Debug.LogError("list is empty");
            return;
        }

        if (orderedConnectionIds[0] == "ローダーからフィルタへ" &&
            orderedConnectionIds[1] == "フィルタからインポータへ1" &&
            orderedConnectionIds[2] == "フィルタからインポータへ2")
        {
            Debug.Log("passed _1_8_1_SerializeGraph_hasValidOrder");
            return;
        }

        Debug.LogError("failed to validate order");
    }
示例#22
0
    public void _3_0_OrderWithDone0()
    {
        // contained filter at the root of 4 filter. should not create source again.
        var basePath      = Path.Combine(Application.dataPath, "AssetGraphTest/Editor/TestData");
        var graphDataPath = Path.Combine(basePath, "_3_0_OrderWithDone0.json");

        // load
        var dataStr = string.Empty;

        using (var sr = new StreamReader(graphDataPath)) {
            dataStr = sr.ReadToEnd();
        }
        var graphDict = Json.Deserialize(dataStr) as Dictionary <string, object>;

        var EndpointNodeIdsAndNodeDatasAndConnectionDatas = GraphStackController.SerializeNodeRoute(graphDict, string.Empty);

        var endpointNodeIds = EndpointNodeIdsAndNodeDatasAndConnectionDatas.endpointNodeIds;
        var nodeDatas       = EndpointNodeIdsAndNodeDatasAndConnectionDatas.nodeDatas;
        var connectionDatas = EndpointNodeIdsAndNodeDatasAndConnectionDatas.connectionDatas;

        var resultDict = new Dictionary <string, Dictionary <string, List <InternalAssetData> > >();

        var cacheDict = new Dictionary <string, List <string> >();

        foreach (var endNodeId in endpointNodeIds)
        {
            GraphStackController.RunSerializedRoute(endNodeId, nodeDatas, connectionDatas, resultDict, cacheDict, string.Empty);
        }

        var connectionIds = resultDict.Keys.ToList();

        if (connectionIds.Contains("ロードからフィルタへ"))
        {
            connectionIds.Remove("ロードからフィルタへ");
        }

        if (!connectionIds.Contains("ロードからフィルタへ"))
        {
            return;
        }

        Debug.LogError("multiple same connectionId contains.");
    }
示例#23
0
    public void _1_14_SetupStackedGraph_Sample()
    {
        GraphStackController.CleanCache();

        var basePath      = Path.Combine(Application.dataPath, "AssetGraphTest/Editor/TestData");
        var graphDataPath = Path.Combine(basePath, "_1_14_RunStackedGraph_Sample.json");

        // load
        var dataStr = string.Empty;

        using (var sr = new StreamReader(graphDataPath)) {
            dataStr = sr.ReadToEnd();
        }

        var graphDict = Json.Deserialize(dataStr) as Dictionary <string, object>;

        GraphStackController.SetupStackedGraph(graphDict, string.Empty);

        Debug.Log("passed _1_14_SetupStackedGraph_Sample");
    }
示例#24
0
    public void _0_1_RunFilter()
    {
        GraphStackController.CleanCache();

        var source = new Dictionary <string, List <InternalAssetData> > {
            { "0",
              new List <InternalAssetData> {
                  InternalAssetData.InternalAssetDataByLoader("A/1st", "A"),
                  InternalAssetData.InternalAssetDataByLoader("A/2nd", "A")
              } }
        };

        var results = new Dictionary <string, List <InternalAssetData> >();

        var sFilter = new SampleFilter_0();
        Action <string, string, Dictionary <string, List <InternalAssetData> >, List <string> > Out = (string nodeId, string connectionId, Dictionary <string, List <InternalAssetData> > output, List <string> cached) => {
            results[connectionId] = output["0"];
        };

        sFilter.Run("ID_0_1_RunFilter", "CONNECTION_0_1_RunFilter", string.Empty, source, new List <string>(), Out);

        if (results.ContainsKey("SampleFilter_0_LabelOf1st"))
        {
            var result1 = results["SampleFilter_0_LabelOf1st"];
            if (result1[0].absoluteSourcePath == "A/1st")
            {
                if (results.ContainsKey("SampleFilter_0_LabelOf2nd"))
                {
                    var resut2 = results["SampleFilter_0_LabelOf2nd"];
                    if (resut2[0].absoluteSourcePath == "A/2nd")
                    {
                        Debug.Log("passed _0_1_RunFilter");
                        return;
                    }
                }
            }
        }

        Debug.LogError("failed to split by filter");
    }
示例#25
0
        public static void RemoveBundleSettings(string nodePath)
        {
            EditorUtility.DisplayProgressBar("AssetBundleGraph unbundlize all resources...", nodePath, 0);
            var filePathsInFolder = FileController.FilePathsInFolder(nodePath);

            foreach (var filePath in filePathsInFolder)
            {
                if (GraphStackController.IsMetaFile(filePath))
                {
                    continue;
                }
                var assetImporter = AssetImporter.GetAtPath(filePath);

                if (assetImporter.GetType() == typeof(UnityEditor.MonoImporter))
                {
                    continue;
                }

                assetImporter.assetBundleName = string.Empty;
            }
            EditorUtility.ClearProgressBar();
        }
示例#26
0
        private bool UpdateDeleteSetting(Node currentNode)
        {
            var currentNodePlatformPackageKey = GraphStackController.Platform_Package_Key(currentNode.currentPlatform);

            if (currentNodePlatformPackageKey == AssetBundleGraphSettings.PLATFORM_DEFAULT_NAME)
            {
                return(false);
            }

            var deleted = false;

            using (new EditorGUILayout.HorizontalScope()) {
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Use Default Setting", GUILayout.Width(150)))
                {
                    currentNode.BeforeSave();
                    currentNode.DeleteCurrentPackagePlatformKey(currentNodePlatformPackageKey);
                    GUI.FocusControl(string.Empty);
                    currentNode.Save();
                    deleted = true;
                }
            }
            return(deleted);
        }
示例#27
0
        private void DoInspectorExporterGUI(Node node)
        {
            if (node.exportPath == null)
            {
                return;
            }

            EditorGUILayout.HelpBox("Exporter: Export given files to output directory.", MessageType.Info);
            UpdateNodeName(node);

            GUILayout.Space(10f);

            node.currentPlatform = UpdateCurrentPlatform(node.currentPlatform);

            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                EditorGUILayout.LabelField("Export Path:");
                var newExportPath = EditorGUILayout.TextField(
                    GraphStackController.GetProjectName(),
                    GraphStackController.ValueFromPlatformAndPackage(
                        node.exportPath.ReadonlyDict(),
                        node.currentPlatform
                        ).ToString()
                    );

                var exporterrNodePath = GraphStackController.WithProjectPath(newExportPath);
                if (IntegratedGUIExporter.ValidateExportPath(
                        newExportPath,
                        exporterrNodePath,
                        () => {
                    // TODO Make text field bold
                },
                        () => {
                    using (new EditorGUILayout.HorizontalScope()) {
                        EditorGUILayout.LabelField(exporterrNodePath + " does not exist.");
                        if (GUILayout.Button("Create directory"))
                        {
                            Directory.CreateDirectory(exporterrNodePath);
                            node.Save();
                        }
                    }
                    EditorGUILayout.Space();

                    EditorGUILayout.LabelField("Available Directories:");
                    string[] dirs = Directory.GetDirectories(Path.GetDirectoryName(exporterrNodePath));
                    foreach (string s in dirs)
                    {
                        EditorGUILayout.LabelField(s);
                    }
                }
                        ))
                {
                    using (new EditorGUILayout.HorizontalScope()) {
                        GUILayout.FlexibleSpace();
                                                #if UNITY_EDITOR_OSX
                        string buttonName = "Reveal in Finder";
                                                #else
                        string buttonName = "Show in Explorer";
                                                #endif
                        if (GUILayout.Button(buttonName))
                        {
                            EditorUtility.RevealInFinder(exporterrNodePath);
                        }
                    }
                }


                if (newExportPath != GraphStackController.ValueFromPlatformAndPackage(
                        node.exportPath.ReadonlyDict(),
                        node.currentPlatform
                        ).ToString()
                    )
                {
                    node.BeforeSave();
                    node.exportPath.Add(GraphStackController.Platform_Package_Key(node.currentPlatform), newExportPath);
                    node.Save();
                }
            }

            UpdateDeleteSetting(node);
        }
示例#28
0
        private void DoInspectorBundleBuilderGUI(Node node)
        {
            if (node.enabledBundleOptions == null)
            {
                return;
            }

            EditorGUILayout.HelpBox("BundleBuilder: Build asset bundles with given asset bundle settings.", MessageType.Info);
            UpdateNodeName(node);

            GUILayout.Space(10f);

            node.currentPlatform = UpdateCurrentPlatform(node.currentPlatform);

            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                var bundleOptions = GraphStackController.ValueFromPlatformAndPackage(
                    node.enabledBundleOptions.ReadonlyDict(),
                    node.currentPlatform
                    );

                var plartform_pakcage_key = GraphStackController.Platform_Package_Key(node.currentPlatform);

                for (var i = 0; i < AssetBundleGraphSettings.DefaultBundleOptionSettings.Count; i++)
                {
                    var enablablekey = AssetBundleGraphSettings.DefaultBundleOptionSettings[i];

                    // contains keyword == enabled. if not, disabled.
                    var isEnabled = bundleOptions.Contains(enablablekey);

                    var result = EditorGUILayout.ToggleLeft(enablablekey, isEnabled);
                    if (result != isEnabled)
                    {
                        node.BeforeSave();

                        var resultsDict = node.enabledBundleOptions.ReadonlyDict();
                        var resultList  = new List <string>();
                        if (resultsDict.ContainsKey(plartform_pakcage_key))
                        {
                            resultList = resultsDict[plartform_pakcage_key];
                        }

                        if (result)
                        {
                            if (!resultList.Contains(enablablekey))
                            {
                                var currentEnableds = new List <string>();
                                if (resultsDict.ContainsKey(plartform_pakcage_key))
                                {
                                    currentEnableds = resultsDict[plartform_pakcage_key];
                                }
                                currentEnableds.Add(enablablekey);

                                node.enabledBundleOptions.Add(
                                    GraphStackController.Platform_Package_Key(node.currentPlatform),
                                    currentEnableds
                                    );
                            }
                        }

                        if (!result)
                        {
                            if (resultList.Contains(enablablekey))
                            {
                                var currentEnableds = new List <string>();
                                if (resultsDict.ContainsKey(plartform_pakcage_key))
                                {
                                    currentEnableds = resultsDict[plartform_pakcage_key];
                                }
                                currentEnableds.Remove(enablablekey);

                                node.enabledBundleOptions.Add(
                                    GraphStackController.Platform_Package_Key(node.currentPlatform),
                                    currentEnableds
                                    );
                            }
                        }

                        /*
                         *                              Cannot use options DisableWriteTypeTree and IgnoreTypeTreeChanges at the same time.
                         */
                        if (enablablekey == "Disable Write TypeTree" && result &&
                            node.enabledBundleOptions.ReadonlyDict()[GraphStackController.Platform_Package_Key(node.currentPlatform)].Contains("Ignore TypeTree Changes"))
                        {
                            var newEnableds = node.enabledBundleOptions.ReadonlyDict()[GraphStackController.Platform_Package_Key(node.currentPlatform)];
                            newEnableds.Remove("Ignore TypeTree Changes");

                            node.enabledBundleOptions.Add(
                                GraphStackController.Platform_Package_Key(node.currentPlatform),
                                newEnableds
                                );
                        }

                        if (enablablekey == "Ignore TypeTree Changes" && result &&
                            node.enabledBundleOptions.ReadonlyDict()[GraphStackController.Platform_Package_Key(node.currentPlatform)].Contains("Disable Write TypeTree"))
                        {
                            var newEnableds = node.enabledBundleOptions.ReadonlyDict()[GraphStackController.Platform_Package_Key(node.currentPlatform)];
                            newEnableds.Remove("Disable Write TypeTree");

                            node.enabledBundleOptions.Add(
                                GraphStackController.Platform_Package_Key(node.currentPlatform),
                                newEnableds
                                );
                        }

                        node.Save();
                        return;
                    }
                }
            }

            UpdateDeleteSetting(node);
        }
示例#29
0
        private void DoInspectorBundlizerGUI(Node node)
        {
            if (node.bundleNameTemplate == null)
            {
                return;
            }

            EditorGUILayout.HelpBox("Bundlizer: Create asset bundle settings with given group of assets.", MessageType.Info);
            UpdateNodeName(node);

            GUILayout.Space(10f);

            node.currentPlatform = UpdateCurrentPlatform(node.currentPlatform);

            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                var bundleNameTemplate = EditorGUILayout.TextField(
                    "Bundle Name Template",
                    GraphStackController.ValueFromPlatformAndPackage(
                        node.bundleNameTemplate.ReadonlyDict(),
                        node.currentPlatform
                        ).ToString()
                    ).ToLower();

                IntegratedGUIBundlizer.ValidateBundleNameTemplate(
                    bundleNameTemplate,
                    () => {
//						EditorGUILayout.HelpBox("No Bundle Name Template set.", MessageType.Error);
                }
                    );

                if (bundleNameTemplate != GraphStackController.ValueFromPlatformAndPackage(
                        node.bundleNameTemplate.ReadonlyDict(),
                        node.currentPlatform
                        ).ToString()
                    )
                {
                    node.BeforeSave();
                    node.bundleNameTemplate.Add(GraphStackController.Platform_Package_Key(node.currentPlatform), bundleNameTemplate);
                    node.Save();
                }

                var isUseOutputResoruces = GraphStackController.ValueFromPlatformAndPackage(
                    node.bundleUseOutput.ReadonlyDict(),
                    node.currentPlatform
                    ).ToString().ToLower();

                var useOrNot = false;
                switch (isUseOutputResoruces)
                {
                case "true": {
                    useOrNot = true;
                    break;
                }
                }

                var result = EditorGUILayout.ToggleLeft("Asset Output for Dependency", useOrNot);

                if (result != useOrNot)
                {
                    node.BeforeSave();

                    if (result)
                    {
                        node.AddBundlizerDependencyOutput();
                    }
                    else
                    {
                        node.RemoveBundlizerDependencyOutput();
                    }

                    node.bundleUseOutput.Add(GraphStackController.Platform_Package_Key(node.currentPlatform), result.ToString());
                    node.Save();
                }

                EditorGUILayout.HelpBox("Check this to enable asset output slot to create asset bundle which has dependency to asset bundle of this node.", MessageType.Info);
            }

            UpdateDeleteSetting(node);
        }
示例#30
0
        private void DoInspectorLoaderGUI(Node node)
        {
            if (node.loadPath == null)
            {
                return;
            }

            EditorGUILayout.HelpBox("Loader: Load assets in given directory path.", MessageType.Info);
            UpdateNodeName(node);

            GUILayout.Space(10f);

            /*
             *      platform & package
             */
            if (packageEditMode)
            {
                EditorGUI.BeginDisabledGroup(true);
            }

            // update platform & package.
            node.currentPlatform = UpdateCurrentPlatform(node.currentPlatform);

            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                EditorGUILayout.LabelField("Load Path:");
                var newLoadPath = EditorGUILayout.TextField(
                    GraphStackController.GetProjectName() + AssetBundleGraphSettings.ASSETS_PATH,
                    GraphStackController.ValueFromPlatformAndPackage(
                        node.loadPath.ReadonlyDict(),
                        node.currentPlatform
                        ).ToString()
                    );
                var loaderNodePath = GraphStackController.WithAssetsPath(newLoadPath);
                IntegratedGUILoader.ValidateLoadPath(
                    newLoadPath,
                    loaderNodePath,
                    () => {
                    //EditorGUILayout.HelpBox("load path is empty.", MessageType.Error);
                },
                    () => {
                    //EditorGUILayout.HelpBox("Directory not found:" + loaderNodePath, MessageType.Error);
                }
                    );

                if (newLoadPath != GraphStackController.ValueFromPlatformAndPackage(
                        node.loadPath.ReadonlyDict(),
                        node.currentPlatform
                        ).ToString()
                    )
                {
                    node.BeforeSave();
                    node.loadPath.Add(GraphStackController.Platform_Package_Key(node.currentPlatform), newLoadPath);
                    node.Save();
                }
            }

            if (packageEditMode)
            {
                EditorGUI.EndDisabledGroup();
            }
            UpdateDeleteSetting(node);
        }