Esempio n. 1
0
        private void DrawAssetSelection()
        {
            CurrentPackage = (ProjectImport)EditorGUILayout.ObjectField(CurrentPackage, typeof(ProjectImport), true);
            if (CurrentPackage != null)
            {
                var explorer = CurrentPackage.Explorer;

                foreach (var resource in explorer.Resources)
                {
                    if (!resource.Name.EndsWith(".bhvr"))
                    {
                        continue;
                    }

                    if (GUILayout.Button(resource.ToString()))
                    {
                        CurrentResource = resource;
                        JObject editorTarget;
                        using (var editorTargetData = CurrentResource.LoadStream())
                            using (var sr = new StreamReader(editorTargetData))
                                using (var reader = new JsonTextReader(sr))
                                {
                                    editorTarget = JObject.Load(reader);
                                }

                        var nodes = NodeManifest.Construct(new Type[] { typeof(AddNode), typeof(RollNode), typeof(OutputValueNode) });
                        var types = TypeManifest.ConstructBaseTypes();

                        var manifest = new BehaviourManifest()
                        {
                            Nodes = nodes,
                            Types = types,
                        };
                        Debug.Log(editorTarget);
                        var graphEditor = new EditorSession(manifest, editorTarget, "SerializedGraph", Serializer);

                        View.BeginSession(graphEditor);
                    }
                }
            }
        }
Esempio n. 2
0
        private void DrawAssetSelection()
        {
            CurrentPackage = (ProjectImport)EditorGUILayout.ObjectField(CurrentPackage, typeof(ProjectImport), true,
                                                                        GUILayout.Width(180));
            if (CurrentPackage == null)
            {
                return;
            }

            var explorer = CurrentPackage.Explorer;

            foreach (var resource in explorer.Resources)
            {
                if (!resource.Name.EndsWith(".bhvr"))
                {
                    continue;
                }

                if (GUILayout.Button(resource.ToString()))
                {
                    CurrentResource = resource;
                    JObject editorTarget;
                    using (var editorTargetData = CurrentResource.LoadStream())
                        using (var sr = new StreamReader(editorTargetData))
                            using (var reader = new JsonTextReader(sr))
                            {
                                editorTarget = JObject.Load(reader);
                            }

                    var nodes = NodeManifest.Construct(new Type[] {
                        typeof(AddNode),
                        typeof(RollNode),
                        typeof(OutputValueNode),
                        typeof(ItemInputNode),
                        typeof(ActivatableItemNode),
                        typeof(IterateNode),
                        typeof(GetStatNode),
                    });
                    var types = TypeManifest.Construct(
                        new Type[]
                    {
                        typeof(bool),
                        typeof(string),
                        typeof(int),
                        typeof(byte),
                        typeof(long),
                        typeof(short),
                        typeof(uint),
                        typeof(ulong),
                        typeof(ushort),
                        typeof(sbyte),
                        typeof(char),
                        typeof(float),
                        typeof(double),
                        typeof(decimal),
                        typeof(InputSocket),
                        typeof(LocalId),
                    },
                        new Type[]
                    {
                        typeof(SerializedGraph),
                        typeof(SerializedNode),
                        typeof(PackageNodeEditor),
                        typeof(PackageNodePosition),
                        typeof(ExtraData)
                    }
                        );

                    var manifest = new BehaviourManifest()
                    {
                        Nodes = nodes,
                        Types = types,
                    };
                    Debug.Log(editorTarget);
                    var graphEditor = new EditorSession(manifest, editorTarget, "SerializedGraph", Serializer);

                    View.BeginSession(graphEditor, graphEditor.Root);
                }
            }
        }