コード例 #1
0
        public string GenerateFrom(string workingDirectory, string assetName, DOMDocument document)
        {
            m_Properties.Clear();
            m_Usings.Clear();
            m_Commands.Clear();
            m_FileDependencies.Clear();

            m_WorkingDirectory = workingDirectory;
            m_File             = new CSFile(document.@namespace)
                                 .AddWarningDisable(414)
                                 .AddInclude("UnityEditor.Experimental.VisualElements");

            m_Class = new CSClass(Scope.Internal, assetName, CSClass.Modifier.Partial)
                      .AddParent("IMGUIVisualContainer");
            m_File.AddClass(m_Class);

            if (document.nodes != null)
            {
                for (int i = 0; i < document.nodes.Length; i++)
                {
                    Visit(document.nodes[i]);
                }
            }

            VisitIn(document.stylesheet);
            VisitIn(document.root);

            Build();

            var builder = new StringBuilder();

            m_File.GenerateIn(builder);
            return(builder.ToString());
        }
コード例 #2
0
        public string GenerateFrom(string workingdir, string assetName, DOMDocument document)
        {
            m_File = new CSFile(document.@namespace);

            m_Class = new CSClass(Scope.Internal, assetName, CSClass.Modifier.Partial);
            m_File
            .AddClass(m_Class)
            .AddInclude("UnityEditor.Experimental.ViewModel")
            .AddWarningDisable(414);
            m_Class.AddParent("SerializedViewModelBase");

            m_PropertyClass = new CSClass(Scope.Internal, "Properties", CSClass.Modifier.Static);
            m_Class.AddClass(m_PropertyClass);

            if (document.members != null)
            {
                for (int i = 0; i < document.members.Length; i++)
                {
                    if (document.members[i] is DOMProperty)
                    {
                        RegisterPropertyGetterDependencies((DOMProperty)document.members[i]);
                    }
                }

                for (int i = 0; i < document.members.Length; i++)
                {
                    Visit(document.members[i]);
                }
            }

            var builder = new StringBuilder();

            m_File.GenerateIn(builder);
            return(builder.ToString());
        }
コード例 #3
0
        public string GenerateFrom(string workingDirectory, string assetName, DOMDocument document)
        {
            m_File = new CSFile(document.@namespace)
                     .AddWarningDisable(414)
                     .AddInclude("System.ComponentModel")
                     .AddInclude("UnityEngine")
                     .AddInclude("UnityEditor.Experimental.VisualElements")
                     .AddInclude("UnityEditor");

            m_Class = new CSClass(Scope.Internal, assetName, CSClass.Modifier.Partial)
                      .AddParent("EditorWindow");
            m_File.AddClass(m_Class);

            m_AwakeMethod = new CSMethod(Scope.Private, "void", "Awake");
            m_Class.AddMethod(m_AwakeMethod);
            m_OnDestroyMethod = new CSMethod(Scope.Private, "void", "OnDestroy");
            m_Class.AddMethod(m_OnDestroyMethod);
            m_OnVMPropertyChanged = new CSMethod(Scope.Private, "void", "VmOnPropertyChanged")
                                    .AddArgument("object", "sender")
                                    .AddArgument("PropertyChangedEventArgs", "propertyChangedEventArgs")
                                    .AddBodyLine("Repaint();");
            m_Class.AddMethod(m_OnVMPropertyChanged);

            VisitIn(document);
            VisitIn(document.usings);
            VisitIn(document.editorPrefsProperties);

            var builder = new StringBuilder();

            m_File.GenerateIn(builder);
            return(builder.ToString());
        }
コード例 #4
0
        public string GenerateFrom(string workingDirectory, string assetName, DOMDocument document)
        {
            m_File = new CSFile(document.@namespace)
                     .AddWarningDisable(414)
                     .AddInclude("UnityEngine")
                     .AddInclude("UnityEditor")
                     .AddInclude("UnityEngine.Experimental")
                     .AddInclude("UnityEditor.Experimental");

            m_Class = new CSClass(Scope.Internal, assetName, CSClass.Modifier.Partial)
                      .AddParent("StyleSheet");
            m_File.AddClass(m_Class);

            Visit(document.styles);

            var builder = new StringBuilder();

            m_File.GenerateIn(builder);
            return(builder.ToString());
        }