コード例 #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_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");
    }
コード例 #3
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");
    }
コード例 #4
0
    public void _0_3_RunImporter()
    {
        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 sImporter = new SampleImporter_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"];
        };

        sImporter.Run("ID_0_3_RunImporter", "CONNECTION_0_3_RunImporter", string.Empty, source, new List <string>(), Out);

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

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

        Debug.LogError("failed to collect importerd resource currentOutputs.Count:" + currentOutputs.Count);
    }
コード例 #5
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");
    }
コード例 #6
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);
    }
コード例 #7
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);
    }
コード例 #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 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");
    }
コード例 #10
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");
    }
コード例 #11
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);
    }
コード例 #12
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");
    }
コード例 #13
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");
    }
コード例 #14
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");
    }
コード例 #15
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");
    }
コード例 #16
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");
    }
コード例 #17
0
    public void _5_1_PlatformChanging_rev()
    {
        GraphStackController.CleanCache();
        GraphStackController.CleanSetting();

        EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.StandaloneOSXIntel);

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

        // load
        var dataStr = string.Empty;

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

        Action setup = () => {
            var EndpointNodeIdsAndNodeDatasAndConnectionDatas = GraphStackController.SerializeNodeRoute(graphDict, string.Empty);

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

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

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

        Action run = () => {
            var EndpointNodeIdsAndNodeDatasAndConnectionDatas = GraphStackController.SerializeNodeRoute(graphDict, string.Empty);

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

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

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

        setup();
        run();

        // cache generated.
        uint before_iOSAssetGUID;

        BuildPipeline.GetCRCForAssetBundle("Assets/AssetGraph/Cache/BundleBuilt/c464cf25-acf0-4678-aae3-d598e44dcc60/StandaloneOSXIntel/chara_0.assetbundle", out before_iOSAssetGUID);

        // change platform.
        EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.iOS);
        setup();
        run();


        // change platform again.
        EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.StandaloneOSXIntel);

        // should cache.

        setup();
        run();
        // the GUID of assetBundle for iOS platform should be keep. = cached.

        uint after_iOSAssetGUID;

        BuildPipeline.GetCRCForAssetBundle("Assets/AssetGraph/Cache/BundleBuilt/c464cf25-acf0-4678-aae3-d598e44dcc60/StandaloneOSXIntel/chara_0.assetbundle", out after_iOSAssetGUID);

        if (after_iOSAssetGUID != before_iOSAssetGUID)
        {
            Debug.LogError("failed to cache after_iOSAssetGUID:" + after_iOSAssetGUID + " before_iOSAssetGUID:" + before_iOSAssetGUID);
        }
    }
コード例 #18
0
    public void _4_1_ImporterUnuseCache()
    {
        GraphStackController.CleanCache();
        GraphStackController.CleanSetting();

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

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

        // load
        var dataStr = string.Empty;

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

        // setup first.
        {
            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> > >();

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


        Action act = () => {
            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> > >();

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

        // set import target data by direct copy.


        // import internal resources.
        act();


        // reset cacheDict for retake.
        cacheDict = new Dictionary <string, List <string> >();

        /*
         *      change import setting, emulate "setting is changed but old caches are already exists."
         */
        {
            var targetSettingFile = FileController.PathCombine(AssetGraphSettings.IMPORTER_SAMPLING_PLACE, "18139977-3750-4efc-bee0-0351a73f2da7", AssetGraphSettings.PLATFORM_DEFAULT_PACKAGE, "sample.fbx");
            if (!File.Exists(targetSettingFile))
            {
                Debug.LogError("failed to read file:" + targetSettingFile);
                return;
            }
            var targetSettingImporter = AssetImporter.GetAtPath(targetSettingFile) as ModelImporter;
            if (!targetSettingImporter)
            {
                Debug.LogError("failed to read targetSettingImporter:" + targetSettingImporter);
                return;
            }

            targetSettingImporter.meshCompression = ModelImporterMeshCompression.High;
        }

        // act again.
        act();

        // no files should be appeared.
        foreach (var nodeId in cacheDict.Keys)
        {
            var cachedContents = cacheDict[nodeId];
            foreach (var cached in cachedContents)
            {
                Debug.LogError("shoud not appear, cached:" + cached);
            }
        }
    }
コード例 #19
0
    public void _4_2_PrefabricatorUnuseCache()
    {
        GraphStackController.CleanCache();
        GraphStackController.CleanSetting();

        // setup first.
        {
            var cacheDict = new Dictionary <string, List <string> >();

            var dataPath      = Path.Combine(Application.dataPath, "AssetGraphTest/Editor/TestData");
            var graphDataPath = Path.Combine(dataPath, "_4_2_PrefabricatorUnuseCache.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> > >();

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

        // create prefab cache.
        {
            var cacheDict = new Dictionary <string, List <string> >();

            var dataPath      = Path.Combine(Application.dataPath, "AssetGraphTest/Editor/TestData");
            var graphDataPath = Path.Combine(dataPath, "_4_2_PrefabricatorUnuseCache.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> > >();

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

        // change importer setting of file.
        {
            var targetSettingFile     = FileController.PathCombine(AssetGraphSettings.IMPORTER_SAMPLING_PLACE, "1b73b22a-41bc-46d3-bbfb-5fe7fa846881", AssetGraphSettings.PLATFORM_DEFAULT_PACKAGE, "sample.fbx");
            var targetSettingImporter = AssetImporter.GetAtPath(targetSettingFile) as ModelImporter;

            targetSettingImporter.meshCompression = ModelImporterMeshCompression.High;;
        }

        // run again. part of prefab is changed, should create new prefab.
        {
            var cacheDict = new Dictionary <string, List <string> >();

            var dataPath      = Path.Combine(Application.dataPath, "AssetGraphTest/Editor/TestData");
            var graphDataPath = Path.Combine(dataPath, "_4_2_PrefabricatorUnuseCache.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> > >();

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

            // all prefabs are new. cached prefabs should not be appeared.

            var cachedContents = cacheDict["eab1a805-4399-4960-bc7f-4d6db602a411"];
            foreach (var cached in cachedContents)
            {
                Debug.LogError("shoud not appear, cached:" + cached);
            }
        }
    }
コード例 #20
0
    public void _4_3_ImporterFromInside()
    {
        GraphStackController.CleanCache();
        GraphStackController.CleanSetting();

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

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

        // load
        var dataStr = string.Empty;

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


        // setup first.
        {
            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> > >();

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

        Action act = () => {
            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> > >();

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

        // import internal resources.
        act();

        // reset cacheDict for retake.
        cacheDict = new Dictionary <string, List <string> >();

        // act again, resources are already inside of unity.
        act();

        int count = 0;        //should be 3. 3files will be cached.

        foreach (var nodeId in cacheDict.Keys)
        {
            var cachedContents = cacheDict[nodeId];
            foreach (var cached in cachedContents)
            {
                count++;
            }
        }

        if (count == 3)
        {
            return;
        }

        Debug.LogError("failed to use cache. count:" + count);
    }
コード例 #21
0
    public void _4_0_RunThenCachedGUI()
    {
        GraphStackController.CleanCache();

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

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

        // load
        var dataStr = string.Empty;

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

        // get cached asset dictionary.
        var createdDataDict = new Dictionary <string, List <string> >();


        Action act = () => {
            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> > >();

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

            /*
             *      create first data result.
             */
            foreach (var node in nodeDatas)
            {
                var nodeId          = node.nodeId;
                var nodeKind        = node.nodeKind;
                var cachedDataPaths = GraphStackController.GetCachedDataByNodeKind(nodeKind, nodeId, string.Empty);

                createdDataDict[nodeId] = cachedDataPaths;
            }
        };

        act();

        // reset cacheDict for retake.
        cacheDict = new Dictionary <string, List <string> >();


        act();

        /*
         *      check results.
         */
        foreach (var nodeId in createdDataDict.Keys)
        {
            if (!cacheDict.Keys.Contains(nodeId))
            {
                if (nodeId == "TestExporter")
                {
                    continue;
                }
                Debug.LogError("cacheDict did not contained:" + nodeId);
            }
        }

        foreach (var nodeId in cacheDict.Keys)
        {
            if (!createdDataDict.Keys.Contains(nodeId))
            {
                Debug.LogError("createdDataDict did not contained:" + nodeId);
            }
        }


        foreach (var key in createdDataDict.Keys)
        {
            if (!cacheDict.ContainsKey(key))
            {
                continue;
            }

            var basePaths   = createdDataDict[key];
            var targetPaths = cacheDict[key];

            foreach (var basePath in basePaths)
            {
                // ignore meta files.
                if (GraphStackController.IsMetaFile(basePath))
                {
                    continue;
                }

                // avoid sub-creating assets. sub-creating assets never appear as cached.
                if (basePath.StartsWith("Assets/AssetGraph/Cache/Imported/Testimporter1/" + GraphStackController.Current_Platform_Package_Folder(string.Empty) + "/models/ID_0/Materials"))
                {
                    continue;
                }
                if (basePath.StartsWith("Assets/AssetGraph/Cache/Imported/Testimporter1/" + GraphStackController.Current_Platform_Package_Folder(string.Empty) + "/models/ID_1/Materials"))
                {
                    continue;
                }
                if (basePath.StartsWith("Assets/AssetGraph/Cache/Imported/Testimporter1/" + GraphStackController.Current_Platform_Package_Folder(string.Empty) + "/models/ID_2/Materials"))
                {
                    continue;
                }

                if (!targetPaths.Contains(basePath))
                {
                    Debug.LogError("contained in result, but not in cached:" + basePath);
                }
            }

            foreach (var targetPath in targetPaths)
            {
                // ignore meta files.
                if (GraphStackController.IsMetaFile(targetPath))
                {
                    continue;
                }

                if (!basePaths.Contains(targetPath))
                {
                    Debug.LogError("contained in cache, but not in result:" + targetPath);
                }
            }
        }
    }