Esempio n. 1
0
        /*
         * Checks deserialized Json Data, and make some changes if necessary
         * Returns original Json Data if there is no change necessary, and returns modified Json Data if there is some changes.
         */
        public static Dictionary <string, object> CreateSafeDecerializedJsonData(Dictionary <string, object> deserializedJsonData)
        {
            var changed = false;

            var allNodesJson          = deserializedJsonData[AssetBundleGraphSettings.ASSETBUNDLEGRAPH_DATA_NODES] as List <object>;
            var sanitizedAllNodesJson = new List <Dictionary <string, object> >();

            /*
             *      delete undetectable node.
             */
            foreach (var n in allNodesJson)
            {
                var nodeJson = n as Dictionary <string, object>;

                // copy all key and value to new Node data dictionary.
                var sanitizedNodeJson = new Dictionary <string, object>();
                foreach (var key in nodeJson.Keys)
                {
                    sanitizedNodeJson[key] = nodeJson[key];
                }

                var kind = AssetBundleGraphSettings.NodeKindFromString(nodeJson[AssetBundleGraphSettings.NODE_KIND] as string);

                switch (kind)
                {
                case AssetBundleGraphSettings.NodeKind.PREFABRICATOR_GUI:
                    break;

                case AssetBundleGraphSettings.NodeKind.BUNDLIZER_GUI:
                    if (!ValidateNodeJsonDataForBundlizer(ref nodeJson))
                    {
                        changed = true;
                        continue;
                    }
                    break;

                case AssetBundleGraphSettings.NodeKind.LOADER_GUI:
                case AssetBundleGraphSettings.NodeKind.FILTER_GUI:
                case AssetBundleGraphSettings.NodeKind.IMPORTSETTING_GUI:
                case AssetBundleGraphSettings.NodeKind.MODIFIER_GUI:
                case AssetBundleGraphSettings.NodeKind.GROUPING_GUI:
                case AssetBundleGraphSettings.NodeKind.EXPORTER_GUI:
                case AssetBundleGraphSettings.NodeKind.BUNDLEBUILDER_GUI:
                    break;

                default:
                {
                    var nodeName = nodeJson[AssetBundleGraphSettings.NODE_NAME] as string;
                    Debug.LogError(nodeName + " is defined as unknown kind of node. value:" + kind);
                    break;
                }
                }

                sanitizedAllNodesJson.Add(sanitizedNodeJson);
            }

            /*
             *      delete undetectable connection.
             *              erase no start node connection.
             *              erase no end node connection.
             *              erase connection which label does exists in the start node.
             */

            var allConnectionsJson          = deserializedJsonData[AssetBundleGraphSettings.ASSETBUNDLEGRAPH_DATA_CONNECTIONS] as List <object>;
            var sanitizedAllConnectionsJson = new List <Dictionary <string, object> >();

            foreach (var c in allConnectionsJson)
            {
                var connectionJson = c as Dictionary <string, object>;

                var connectionLabel = connectionJson[AssetBundleGraphSettings.CONNECTION_LABEL] as string;
                var fromNodeId      = connectionJson[AssetBundleGraphSettings.CONNECTION_FROMNODE] as string;
                var fromNodePointId = connectionJson[AssetBundleGraphSettings.CONNECTION_FROMNODE_CONPOINT_ID] as string;
                var toNodeId        = connectionJson[AssetBundleGraphSettings.CONNECTION_TONODE] as string;
//				var toNodePointId   = connectionJson[AssetBundleGraphSettings.CONNECTION_TONODE_CONPOINT_ID] as string;

                // detect start node.
                var fromNodeCandidates = sanitizedAllNodesJson.Where(
                    node => {
                    var nodeId = node[AssetBundleGraphSettings.NODE_ID] as string;
                    return(nodeId == fromNodeId);
                }
                    ).ToList();
                if (!fromNodeCandidates.Any())
                {
                    changed = true;
                    continue;
                }


                // start node should contain specific connection point.
                var candidateNode = fromNodeCandidates[0];
                var candidateOutputPointIdsSources = candidateNode[AssetBundleGraphSettings.NODE_OUTPUTPOINT_IDS] as List <object>;
                var candidateOutputPointIds        = new List <string>();
                foreach (var candidateOutputPointIdsSource in candidateOutputPointIdsSources)
                {
                    candidateOutputPointIds.Add(candidateOutputPointIdsSource as string);
                }
                if (!candidateOutputPointIdsSources.Contains(fromNodePointId))
                {
                    changed = true;
                    continue;
                }

                // detect end node.
                var toNodeCandidates = sanitizedAllNodesJson.Where(
                    node => {
                    var nodeId = node[AssetBundleGraphSettings.NODE_ID] as string;
                    return(nodeId == toNodeId);
                }
                    ).ToList();
                if (!toNodeCandidates.Any())
                {
                    changed = true;
                    continue;
                }

                // this connection has start node & end node.
                // detect connectionLabel.
                var fromNode = fromNodeCandidates[0];
                var connectionLabelsSource = fromNode[AssetBundleGraphSettings.NODE_OUTPUTPOINT_LABELS] as List <object>;
                var connectionLabels       = new List <string>();
                foreach (var connectionLabelSource in connectionLabelsSource)
                {
                    connectionLabels.Add(connectionLabelSource as string);
                }

                if (!connectionLabels.Contains(connectionLabel))
                {
                    changed = true;
                    continue;
                }

                sanitizedAllConnectionsJson.Add(connectionJson);
            }

            if (changed)
            {
                var validatedResultDict = new Dictionary <string, object> {
                    { AssetBundleGraphSettings.ASSETBUNDLEGRAPH_DATA_LASTMODIFIED, DateTime.Now },
                    { AssetBundleGraphSettings.ASSETBUNDLEGRAPH_DATA_NODES, sanitizedAllNodesJson },
                    { AssetBundleGraphSettings.ASSETBUNDLEGRAPH_DATA_CONNECTIONS, sanitizedAllConnectionsJson }
                };
                return(validatedResultDict);
            }

            return(deserializedJsonData);
        }
Esempio n. 2
0
        public void FromJsonDictionary(Dictionary <string, object> jsonData)
        {
            m_name             = jsonData[NODE_NAME] as string;
            m_id               = jsonData[NODE_ID] as string;
            m_kind             = AssetBundleGraphSettings.NodeKindFromString(jsonData[NODE_KIND] as string);
            m_scriptClassName  = string.Empty;
            m_nodeNeedsRevisit = false;

            if (jsonData.ContainsKey(NODE_SCRIPT_CLASSNAME))
            {
                m_scriptClassName = jsonData[NODE_SCRIPT_CLASSNAME] as string;
            }

            var pos = jsonData[NODE_POS] as Dictionary <string, object>;

            m_x = (float)Convert.ToDouble(pos[NODE_POS_X]);
            m_y = (float)Convert.ToDouble(pos[NODE_POS_Y]);

            var inputs  = jsonData[NODE_INPUTPOINTS] as List <object>;
            var outputs = jsonData[NODE_OUTPUTPOINTS] as List <object>;

            m_inputPoints  = new List <ConnectionPointData>();
            m_outputPoints = new List <ConnectionPointData>();

            foreach (var obj in inputs)
            {
                var pDic = obj as Dictionary <string, object>;
                m_inputPoints.Add(new ConnectionPointData(pDic, this, true));
            }

            foreach (var obj in outputs)
            {
                var pDic = obj as Dictionary <string, object>;
                m_outputPoints.Add(new ConnectionPointData(pDic, this, false));
            }

            switch (m_kind)
            {
            case NodeKind.IMPORTSETTING_GUI:
                // nothing to do
                break;

            case NodeKind.PREFABBUILDER_GUI:
            {
                if (jsonData.ContainsKey(NODE_PREFABBUILDER_REPLACEPREFABOPTIONS))
                {
                    m_prefabBuilderReplacePrefabOptions = Convert.ToInt32(jsonData[NODE_PREFABBUILDER_REPLACEPREFABOPTIONS]);
                }
                if (jsonData.ContainsKey(NODE_SCRIPT_INSTANCE_DATA))
                {
                    m_scriptInstanceData = new SerializableMultiTargetString(_SafeGet(jsonData, NODE_SCRIPT_INSTANCE_DATA));
                }
            }
            break;

            case NodeKind.MODIFIER_GUI:
            {
                if (jsonData.ContainsKey(NODE_SCRIPT_INSTANCE_DATA))
                {
                    m_scriptInstanceData = new SerializableMultiTargetString(_SafeGet(jsonData, NODE_SCRIPT_INSTANCE_DATA));
                }
            }
            break;

            case NodeKind.LOADER_GUI:
            {
                m_loaderLoadPath = new SerializableMultiTargetString(_SafeGet(jsonData, NODE_LOADER_LOAD_PATH));
            }
            break;

            case NodeKind.FILTER_GUI:
            {
                var filters = jsonData[NODE_FILTER] as List <object>;

                m_filter = new List <FilterEntry>();

                for (int i = 0; i < filters.Count; ++i)
                {
                    var f = filters[i] as Dictionary <string, object>;

                    var keyword = f[NODE_FILTER_KEYWORD] as string;
                    var keytype = f[NODE_FILTER_KEYTYPE] as string;
                    var pointId = f[NODE_FILTER_POINTID] as string;

                    var point = m_outputPoints.Find(p => p.Id == pointId);
                    UnityEngine.Assertions.Assert.IsNotNull(point, "Output point not found for " + keyword);
                    m_filter.Add(new FilterEntry(keyword, keytype, point));
                }
            }
            break;

            case NodeKind.GROUPING_GUI:
            {
                m_groupingKeyword = new SerializableMultiTargetString(_SafeGet(jsonData, NODE_GROUPING_KEYWORD));
            }
            break;

            case NodeKind.BUNDLECONFIG_GUI:
            {
                m_bundleConfigBundleNameTemplate = new SerializableMultiTargetString(_SafeGet(jsonData, NODE_BUNDLECONFIG_BUNDLENAME_TEMPLATE));
                if (jsonData.ContainsKey(NODE_BUNDLECONFIG_USE_GROUPASVARIANTS))
                {
                    m_bundleConfigUseGroupAsVariants = Convert.ToBoolean(jsonData[NODE_BUNDLECONFIG_USE_GROUPASVARIANTS]);
                }
                m_variants = new List <Variant>();
                if (jsonData.ContainsKey(NODE_BUNDLECONFIG_VARIANTS))
                {
                    var variants = jsonData[NODE_BUNDLECONFIG_VARIANTS] as List <object>;

                    for (int i = 0; i < variants.Count; ++i)
                    {
                        var v = variants[i] as Dictionary <string, object>;

                        var name    = v[NODE_BUNDLECONFIG_VARIANTS_NAME] as string;
                        var pointId = v[NODE_BUNDLECONFIG_VARIANTS_POINTID] as string;

                        var point = m_inputPoints.Find(p => p.Id == pointId);
                        UnityEngine.Assertions.Assert.IsNotNull(point, "Input point not found for " + name);
                        m_variants.Add(new Variant(name, point));
                    }
                }
            }
            break;

            case NodeKind.BUNDLEBUILDER_GUI:
            {
                m_bundleBuilderEnabledBundleOptions = new SerializableMultiTargetInt(_SafeGet(jsonData, NODE_BUNDLEBUILDER_ENABLEDBUNDLEOPTIONS));
            }
            break;

            case NodeKind.EXPORTER_GUI:
            {
                m_exporterExportPath   = new SerializableMultiTargetString(_SafeGet(jsonData, NODE_EXPORTER_EXPORT_PATH));
                m_exporterExportOption = new SerializableMultiTargetInt(_SafeGet(jsonData, NODE_EXPORTER_EXPORT_OPTION));
            }
            break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Esempio n. 3
0
        private Node(
            int index,
            string name,
            string nodeId,
            AssetBundleGraphSettings.NodeKind kind,
            float x,
            float y,
            string scriptType = null,
            string scriptPath = null,
            Dictionary<string, string> loadPath = null,
            Dictionary<string, string> exportPath = null,
            List<string> filterContainsKeywords = null,
            List<string> filterContainsKeytypes = null,
            Dictionary<string, string> importerPackages = null,
            Dictionary<string, string> modifierPackages = null,
            Dictionary<string, string> groupingKeyword = null,
            Dictionary<string, string> bundleNameTemplate = null,
            Dictionary<string, string> bundleUseOutput = null,
            Dictionary<string, List<string>> enabledBundleOptions = null
            )
        {
            nodeInsp = ScriptableObject.CreateInstance<NodeInspector>();
            nodeInsp.hideFlags = HideFlags.DontSave;
            this.nodeWindowId = index;
            this.name = name;
            this.nodeId = nodeId;
            this.kind = kind;
            this.scriptType = scriptType;
            this.scriptPath = scriptPath;
            if (loadPath != null) this.loadPath = new SerializablePseudoDictionary(loadPath);
            if (exportPath != null) this.exportPath = new SerializablePseudoDictionary(exportPath);
            this.filterContainsKeywords = filterContainsKeywords;
            this.filterContainsKeytypes = filterContainsKeytypes;
            if (importerPackages != null) this.importerPackages = new SerializablePseudoDictionary(importerPackages);
            if (modifierPackages != null) this.modifierPackages = new SerializablePseudoDictionary(modifierPackages);
            if (groupingKeyword != null) this.groupingKeyword = new SerializablePseudoDictionary(groupingKeyword);
            if (bundleNameTemplate != null) this.bundleNameTemplate = new SerializablePseudoDictionary(bundleNameTemplate);
            if (bundleUseOutput != null) this.bundleUseOutput = new SerializablePseudoDictionary(bundleUseOutput);
            if (enabledBundleOptions != null) this.enabledBundleOptions = new SerializablePseudoDictionary2(enabledBundleOptions);

            this.baseRect = new Rect(x, y, AssetBundleGraphGUISettings.NODE_BASE_WIDTH, AssetBundleGraphGUISettings.NODE_BASE_HEIGHT);

            switch (this.kind) {
                case AssetBundleGraphSettings.NodeKind.LOADER_GUI:
                case AssetBundleGraphSettings.NodeKind.EXPORTER_GUI: {
                    this.nodeInterfaceTypeStr = "flow node 0";
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.FILTER_SCRIPT:
                case AssetBundleGraphSettings.NodeKind.FILTER_GUI: {
                    this.nodeInterfaceTypeStr = "flow node 1";
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.IMPORTSETTING_GUI: {
                    this.nodeInterfaceTypeStr = "flow node 2";
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.MODIFIER_GUI: {
                    this.nodeInterfaceTypeStr = "flow node 4";
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.GROUPING_GUI: {
                    this.nodeInterfaceTypeStr = "flow node 3";
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.PREFABRICATOR_SCRIPT:
                case AssetBundleGraphSettings.NodeKind.PREFABRICATOR_GUI:
                 {
                    this.nodeInterfaceTypeStr = "flow node 4";
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.BUNDLIZER_GUI: {
                    this.nodeInterfaceTypeStr = "flow node 5";
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.BUNDLEBUILDER_GUI: {
                    this.nodeInterfaceTypeStr = "flow node 6";
                    break;
                }

                default: {
                    Debug.LogError("failed to match:" + this.kind);
                    break;
                }
            }
        }
Esempio n. 4
0
        private void AddNodeFromGUI(string nodeName, AssetBundleGraphSettings.NodeKind kind, string nodeId, float x, float y)
        {
            Node newNode = null;

            if (string.IsNullOrEmpty(nodeName)) nodeName = AssetBundleGraphSettings.DEFAULT_NODE_NAME[kind] + nodes.Where(node => node.kind == kind).ToList().Count;

            switch (kind) {
                case AssetBundleGraphSettings.NodeKind.LOADER_GUI: {
                    var default_platform_package_loadPath = new Dictionary<string, string> {
                        {AssetBundleGraphSettings.PLATFORM_DEFAULT_NAME, string.Empty}
                    };

                    newNode = Node.LoaderNode(nodes.Count, nodeName, nodeId, kind, default_platform_package_loadPath, x, y);
                    newNode.AddConnectionPoint(new OutputPoint(AssetBundleGraphSettings.DEFAULT_OUTPUTPOINT_LABEL));
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.FILTER_GUI: {
                    var newFilterKeywords = new List<string>();
                    var newFilterKeytypes = new List<string>();
                    newNode = Node.GUINodeForFilter(nodes.Count, nodeName, nodeId, kind, newFilterKeywords, newFilterKeytypes, x, y);
                    newNode.AddConnectionPoint(new InputPoint(AssetBundleGraphSettings.DEFAULT_INPUTPOINT_LABEL));
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.IMPORTSETTING_GUI: {
                    var importerPackages = new Dictionary<string, string> {
                        {AssetBundleGraphSettings.PLATFORM_DEFAULT_NAME, string.Empty}
                    };

                    newNode = Node.GUINodeForImport(nodes.Count, nodeName, nodeId, kind, importerPackages, x, y);
                    newNode.AddConnectionPoint(new InputPoint(AssetBundleGraphSettings.DEFAULT_INPUTPOINT_LABEL));
                    newNode.AddConnectionPoint(new OutputPoint(AssetBundleGraphSettings.DEFAULT_OUTPUTPOINT_LABEL));
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.MODIFIER_GUI: {
                    var modifierPackages = new Dictionary<string, string> {
                        {AssetBundleGraphSettings.PLATFORM_DEFAULT_NAME, string.Empty}
                    };

                    newNode = Node.GUINodeForModify(nodes.Count, nodeName, nodeId, kind, modifierPackages, x, y);
                    newNode.AddConnectionPoint(new InputPoint(AssetBundleGraphSettings.DEFAULT_INPUTPOINT_LABEL));
                    newNode.AddConnectionPoint(new OutputPoint(AssetBundleGraphSettings.DEFAULT_OUTPUTPOINT_LABEL));
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.GROUPING_GUI: {
                    var newGroupingKeywords = new Dictionary<string, string> {
                        {AssetBundleGraphSettings.PLATFORM_DEFAULT_NAME, AssetBundleGraphSettings.GROUPING_KEYWORD_DEFAULT}
                    };

                    newNode = Node.GUINodeForGrouping(nodes.Count, nodeName, nodeId, kind, newGroupingKeywords, x, y);
                    newNode.AddConnectionPoint(new InputPoint(AssetBundleGraphSettings.DEFAULT_INPUTPOINT_LABEL));
                    newNode.AddConnectionPoint(new OutputPoint(AssetBundleGraphSettings.DEFAULT_OUTPUTPOINT_LABEL));
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.PREFABRICATOR_GUI:{
                    newNode = Node.GUINodeForPrefabricator(nodes.Count, nodeName, nodeId, kind, x, y);
                    newNode.AddConnectionPoint(new InputPoint(AssetBundleGraphSettings.DEFAULT_INPUTPOINT_LABEL));
                    newNode.AddConnectionPoint(new OutputPoint(AssetBundleGraphSettings.DEFAULT_OUTPUTPOINT_LABEL));
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.BUNDLIZER_GUI: {
                    var newBundlizerKeyword = new Dictionary<string, string> {
                        {AssetBundleGraphSettings.PLATFORM_DEFAULT_NAME, AssetBundleGraphSettings.BUNDLIZER_BUNDLENAME_TEMPLATE_DEFAULT}
                    };

                    var newBundleUseOutput = new Dictionary<string, string> {
                        {AssetBundleGraphSettings.PLATFORM_DEFAULT_NAME, AssetBundleGraphSettings.BUNDLIZER_USEOUTPUT_DEFAULT}
                    };

                    newNode = Node.GUINodeForBundlizer(nodes.Count, nodeName, nodeId, kind, newBundlizerKeyword, newBundleUseOutput, x, y);
                    newNode.AddConnectionPoint(new InputPoint(AssetBundleGraphSettings.DEFAULT_INPUTPOINT_LABEL));
                    newNode.AddConnectionPoint(new OutputPoint(AssetBundleGraphSettings.BUNDLIZER_BUNDLE_OUTPUTPOINT_LABEL));
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.BUNDLEBUILDER_GUI: {
                    var bundleOptions = new Dictionary<string, List<string>>{
                        {AssetBundleGraphSettings.PLATFORM_DEFAULT_NAME, new List<string>()}
                    };

                    newNode = Node.GUINodeForBundleBuilder(nodes.Count, nodeName, nodeId, kind, bundleOptions, x, y);
                    newNode.AddConnectionPoint(new InputPoint(AssetBundleGraphSettings.DEFAULT_INPUTPOINT_LABEL));
                    newNode.AddConnectionPoint(new OutputPoint(AssetBundleGraphSettings.DEFAULT_OUTPUTPOINT_LABEL));
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.EXPORTER_GUI: {
                    var default_platform_package_exportPath = new Dictionary<string, string> {
                        {AssetBundleGraphSettings.PLATFORM_DEFAULT_NAME, string.Empty}
                    };

                    newNode = Node.ExporterNode(nodes.Count, nodeName, nodeId, kind, default_platform_package_exportPath, x, y);
                    newNode.AddConnectionPoint(new InputPoint(AssetBundleGraphSettings.DEFAULT_INPUTPOINT_LABEL));
                    break;
                }
                default: {
                    Debug.LogError("no kind match:" + kind);
                    break;
                }
            }

            if (newNode == null) return;
            Undo.RecordObject(this, "Add Node");

            nodes.Add(newNode);
        }
Esempio n. 5
0
 public static Node LoaderNode(int index, string name, string nodeId, AssetBundleGraphSettings.NodeKind kind, Dictionary<string, string> loadPath, float x, float y)
 {
     return new Node(
         index: index,
         name: name,
         nodeId: nodeId,
         kind: kind,
         x: x,
         y: y,
         loadPath: loadPath
     );
 }
Esempio n. 6
0
 public static Node ScriptNode(int index, string name, string nodeId, AssetBundleGraphSettings.NodeKind kind, string scriptType, string scriptPath, float x, float y)
 {
     return new Node(
         index: index,
         name: name,
         nodeId: nodeId,
         kind: kind,
         x: x,
         y: y,
         scriptType: scriptType,
         scriptPath: scriptPath
     );
 }
Esempio n. 7
0
 public static Node GUINodeForModify(int index, string name, string nodeId, AssetBundleGraphSettings.NodeKind kind, Dictionary<string, string> modifierPackages, float x, float y)
 {
     return new Node(
         index: index,
         name: name,
         nodeId: nodeId,
         kind: kind,
         x: x,
         y: y,
         modifierPackages: modifierPackages
     );
 }
Esempio n. 8
0
 public static Node GUINodeForPrefabricator(int index, string name, string nodeId, AssetBundleGraphSettings.NodeKind kind, float x, float y)
 {
     return new Node(
         index: index,
         name: name,
         nodeId: nodeId,
         kind: kind,
         x: x,
         y: y
     );
 }
Esempio n. 9
0
 public static Node GUINodeForGrouping(int index, string name, string nodeId, AssetBundleGraphSettings.NodeKind kind, Dictionary<string, string> groupingKeyword, float x, float y)
 {
     return new Node(
         index: index,
         name: name,
         nodeId: nodeId,
         kind: kind,
         x: x,
         y: y,
         groupingKeyword: groupingKeyword
     );
 }
Esempio n. 10
0
 public static Node GUINodeForFilter(int index, string name, string nodeId, AssetBundleGraphSettings.NodeKind kind, List<string> filterContainsKeywords, List<string> filterContainsKeytypes, float x, float y)
 {
     return new Node(
         index: index,
         name: name,
         nodeId: nodeId,
         kind: kind,
         x: x,
         y: y,
         filterContainsKeywords: filterContainsKeywords,
         filterContainsKeytypes: filterContainsKeytypes
     );
 }
Esempio n. 11
0
 public static Node GUINodeForBundlizer(int index, string name, string nodeId, AssetBundleGraphSettings.NodeKind kind, Dictionary<string, string> bundleNameTemplate, Dictionary<string, string> bundleUseOutput, float x, float y)
 {
     return new Node(
         index: index,
         name: name,
         nodeId: nodeId,
         kind: kind,
         x: x,
         y: y,
         bundleNameTemplate: bundleNameTemplate,
         bundleUseOutput: bundleUseOutput
     );
 }
Esempio n. 12
0
 public static Node GUINodeForBundleBuilder(int index, string name, string nodeId, AssetBundleGraphSettings.NodeKind kind, Dictionary<string, List<string>> enabledBundleOptions, float x, float y)
 {
     return new Node(
         index: index,
         name: name,
         nodeId: nodeId,
         kind: kind,
         x: x,
         y: y,
         enabledBundleOptions: enabledBundleOptions
     );
 }
Esempio n. 13
0
        public static GraphDescription BuildGraphDescriptionFromJson(Dictionary <string, object> deserializedJsonData)
        {
            var nodeIds     = new List <string>();
            var nodesSource = deserializedJsonData[AssetBundleGraphSettings.ASSETBUNDLEGRAPH_DATA_NODES] as List <object>;

            var connectionsSource = deserializedJsonData[AssetBundleGraphSettings.ASSETBUNDLEGRAPH_DATA_CONNECTIONS] as List <object>;
            var allConnections    = new List <ConnectionData>();

            foreach (var connectionSource in connectionsSource)
            {
                var connectionDict = connectionSource as Dictionary <string, object>;

                var connectionId          = connectionDict[AssetBundleGraphSettings.CONNECTION_ID] as string;
                var connectionLabel       = connectionDict[AssetBundleGraphSettings.CONNECTION_LABEL] as string;
                var fromNodeId            = connectionDict[AssetBundleGraphSettings.CONNECTION_FROMNODE] as string;
                var fromNodeOutputPointId = connectionDict[AssetBundleGraphSettings.CONNECTION_FROMNODE_CONPOINT_ID] as string;
                var toNodeId           = connectionDict[AssetBundleGraphSettings.CONNECTION_TONODE] as string;
                var toNodeInputPointId = connectionDict[AssetBundleGraphSettings.CONNECTION_TONODE_CONPOINT_ID] as string;
                allConnections.Add(new ConnectionData(connectionId, connectionLabel, fromNodeId, fromNodeOutputPointId, toNodeId, toNodeInputPointId));
            }

            var allNodes = new List <NodeData>();

            foreach (var nodeSource in nodesSource)
            {
                var nodeDict = nodeSource as Dictionary <string, object>;
                var nodeId   = nodeDict[AssetBundleGraphSettings.NODE_ID] as string;
                nodeIds.Add(nodeId);

                var kindSource = nodeDict[AssetBundleGraphSettings.NODE_KIND] as string;
                var nodeKind   = AssetBundleGraphSettings.NodeKindFromString(kindSource);

                var nodeName = nodeDict[AssetBundleGraphSettings.NODE_NAME] as string;

                var nodeOutputPointIdsSources = nodeDict[AssetBundleGraphSettings.NODE_OUTPUTPOINT_IDS] as List <object>;
                var outputPointIds            = new List <string>();
                foreach (var nodeOutputPointIdsSource in nodeOutputPointIdsSources)
                {
                    outputPointIds.Add(nodeOutputPointIdsSource as string);
                }

                switch (nodeKind)
                {
                case AssetBundleGraphSettings.NodeKind.LOADER_GUI: {
                    var loadPathSource = nodeDict[AssetBundleGraphSettings.NODE_LOADER_LOAD_PATH] as Dictionary <string, object>;
                    var loadPath       = new Dictionary <string, string>();
                    if (loadPathSource == null)
                    {
                        loadPathSource = new Dictionary <string, object>();
                    }
                    foreach (var platform_package_key in loadPathSource.Keys)
                    {
                        loadPath[platform_package_key] = loadPathSource[platform_package_key] as string;
                    }

                    allNodes.Add(
                        new NodeData(
                            nodeId: nodeId,
                            nodeKind: nodeKind,
                            nodeName: nodeName,
                            outputPointIds: outputPointIds,
                            loadPath: loadPath
                            )
                        );
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.EXPORTER_GUI: {
                    var exportPathSource = nodeDict[AssetBundleGraphSettings.NODE_EXPORTER_EXPORT_PATH] as Dictionary <string, object>;
                    var exportTo         = new Dictionary <string, string>();

                    if (exportPathSource == null)
                    {
                        exportPathSource = new Dictionary <string, object>();
                    }
                    foreach (var platform_package_key in exportPathSource.Keys)
                    {
                        exportTo[platform_package_key] = exportPathSource[platform_package_key] as string;
                    }

                    allNodes.Add(
                        new NodeData(
                            nodeId: nodeId,
                            nodeKind: nodeKind,
                            nodeName: nodeName,
                            outputPointIds: outputPointIds,
                            exportTo: exportTo
                            )
                        );
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.MODIFIER_GUI:
                case AssetBundleGraphSettings.NodeKind.PREFABRICATOR_GUI: {
                    var scriptClassName = nodeDict[AssetBundleGraphSettings.NODE_SCRIPT_CLASSNAME] as string;
                    allNodes.Add(
                        new NodeData(
                            nodeId: nodeId,
                            nodeKind: nodeKind,
                            nodeName: nodeName,
                            outputPointIds: outputPointIds,
                            scriptClassName: scriptClassName
                            )
                        );
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.FILTER_GUI: {
                    var containsKeywordsSource = nodeDict[AssetBundleGraphSettings.NODE_FILTER_CONTAINS_KEYWORDS] as List <object>;
                    var filterContainsKeywords = new List <string>();
                    foreach (var containsKeywordSource in containsKeywordsSource)
                    {
                        filterContainsKeywords.Add(containsKeywordSource.ToString());
                    }

                    var containsKeytypesSource = nodeDict[AssetBundleGraphSettings.NODE_FILTER_CONTAINS_KEYTYPES] as List <object>;
                    var filterContainsKeytypes = new List <string>();
                    foreach (var containsKeytypeSource in containsKeytypesSource)
                    {
                        filterContainsKeytypes.Add(containsKeytypeSource.ToString());
                    }

                    allNodes.Add(
                        new NodeData(
                            nodeId: nodeId,
                            nodeKind: nodeKind,
                            nodeName: nodeName,
                            outputPointIds: outputPointIds,
                            filterContainsKeywords: filterContainsKeywords,
                            filterContainsKeytypes: filterContainsKeytypes
                            )
                        );
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.IMPORTSETTING_GUI: {
                    var importerPackagesSource = nodeDict[AssetBundleGraphSettings.NODE_IMPORTER_PACKAGES] as Dictionary <string, object>;
                    var importerPackages       = new Dictionary <string, string>();

                    if (importerPackagesSource == null)
                    {
                        importerPackagesSource = new Dictionary <string, object>();
                    }
                    foreach (var platform_package_key in importerPackagesSource.Keys)
                    {
                        importerPackages[platform_package_key] = string.Empty;
                    }

                    allNodes.Add(
                        new NodeData(
                            nodeId: nodeId,
                            nodeKind: nodeKind,
                            nodeName: nodeName,
                            outputPointIds: outputPointIds,
                            importerPackages: importerPackages
                            )
                        );
                    break;
                }

                    {
                        allNodes.Add(
                            new NodeData(
                                nodeId: nodeId,
                                nodeKind: nodeKind,
                                nodeName: nodeName,
                                outputPointIds: outputPointIds
                                )
                            );
                        break;
                    }

                case AssetBundleGraphSettings.NodeKind.GROUPING_GUI: {
                    var groupingKeywordSource = nodeDict[AssetBundleGraphSettings.NODE_GROUPING_KEYWORD] as Dictionary <string, object>;
                    var groupingKeyword       = new Dictionary <string, string>();

                    if (groupingKeywordSource == null)
                    {
                        groupingKeywordSource = new Dictionary <string, object>();
                    }
                    foreach (var platform_package_key in groupingKeywordSource.Keys)
                    {
                        groupingKeyword[platform_package_key] = groupingKeywordSource[platform_package_key] as string;
                    }

                    allNodes.Add(
                        new NodeData(
                            nodeId: nodeId,
                            nodeKind: nodeKind,
                            nodeName: nodeName,
                            outputPointIds: outputPointIds,
                            groupingKeyword: groupingKeyword
                            )
                        );
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.BUNDLIZER_GUI: {
                    var bundleNameTemplateSource = nodeDict[AssetBundleGraphSettings.NODE_BUNDLIZER_BUNDLENAME_TEMPLATE] as Dictionary <string, object>;
                    var bundleNameTemplate       = new Dictionary <string, string>();
                    if (bundleNameTemplateSource == null)
                    {
                        bundleNameTemplateSource = new Dictionary <string, object>();
                    }
                    foreach (var platform_package_key in bundleNameTemplateSource.Keys)
                    {
                        bundleNameTemplate[platform_package_key] = bundleNameTemplateSource[platform_package_key] as string;
                    }

                    var variantsSource = nodeDict[AssetBundleGraphSettings.NODE_BUNDLIZER_VARIANTS] as Dictionary <string, object>;
                    var variants       = new Dictionary <string, string>();
                    if (variantsSource == null)
                    {
                        variantsSource = new Dictionary <string, object>();
                    }
                    foreach (var inputPointId in variantsSource.Keys)
                    {
                        variants[inputPointId] = variantsSource[inputPointId] as string;
                    }

                    allNodes.Add(
                        new NodeData(
                            nodeId: nodeId,
                            nodeKind: nodeKind,
                            nodeName: nodeName,
                            outputPointIds: outputPointIds,
                            bundleNameTemplate: bundleNameTemplate,
                            variants: variants
                            )
                        );
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.BUNDLEBUILDER_GUI: {
                    var enabledBundleOptionsSource = nodeDict[AssetBundleGraphSettings.NODE_BUNDLEBUILDER_ENABLEDBUNDLEOPTIONS] as Dictionary <string, object>;

                    // default is empty. all settings are disabled.
                    var enabledBundleOptions = new Dictionary <string, List <string> >();

                    if (enabledBundleOptionsSource == null)
                    {
                        enabledBundleOptionsSource = new Dictionary <string, object>();
                    }
                    foreach (var platform_package_key in enabledBundleOptionsSource.Keys)
                    {
                        enabledBundleOptions[platform_package_key] = new List <string>();

                        var enabledBundleOptionsListSource = enabledBundleOptionsSource[platform_package_key] as List <object>;

                        // adopt enabled option.
                        foreach (var enabledBundleOption in enabledBundleOptionsListSource)
                        {
                            enabledBundleOptions[platform_package_key].Add(enabledBundleOption as string);
                        }
                    }

                    allNodes.Add(
                        new NodeData(
                            nodeId: nodeId,
                            nodeKind: nodeKind,
                            nodeName: nodeName,
                            outputPointIds: outputPointIds,
                            enabledBundleOptions: enabledBundleOptions
                            )
                        );
                    break;
                }

                default: {
                    Debug.LogError(nodeName + " is defined as unknown kind of node. value:" + nodeKind);
                    break;
                }
                }
            }

            /*
             *      collect node's child. for detecting endpoint of relationship.
             */
            var nodeIdListWhichHasChild = new List <string>();

            foreach (var connection in allConnections)
            {
                nodeIdListWhichHasChild.Add(connection.fromNodeId);
            }
            var noChildNodeIds = nodeIds.Except(nodeIdListWhichHasChild).ToList();

            /*
             *      adding parentNode id x n into childNode for run up relationship from childNode.
             */
            foreach (var connection in allConnections)
            {
                var targetNodes = allNodes.Where(nodeData => nodeData.nodeId == connection.toNodeId).ToList();
                foreach (var targetNode in targetNodes)
                {
                    targetNode.AddConnectionToParent(connection);
                }
            }

            return(new GraphDescription(noChildNodeIds, allNodes, allConnections));
        }