Exemple #1
0
        public bool DrawLayout()
        {
            var script = Script.Dereference(m_Registry);

            if (null == script || script.IsRuntimeIncluded)
            {
                return(false);
            }

            using (var scroll = new GUILayout.ScrollViewScope(m_Scroll, GUILayout.ExpandWidth(true)))
            {
                m_Scroll = scroll.scrollPosition;

                EditorGUI.BeginChangeCheck();
                script.Name = EditorGUILayout.DelayedTextField("Name", script.Name);
                if (EditorGUI.EndChangeCheck())
                {
                    OnRenameEnded?.Invoke(script);
                }

                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.PrefixLabel("Description");
                    script.Documentation.Summary = EditorGUILayout.TextArea(script.Documentation.Summary, GUILayout.Height(50));
                }

                EditorGUILayout.Space();

                script.TextAsset = (TextAsset)EditorGUILayout.ObjectField("Source", script.TextAsset, typeof(TextAsset), false);

                EditorGUILayout.Space();

                if (null != script.TextAsset)
                {
                    using (new GUIEnabledScope(false))
                    {
                        var text = script.TextAsset.text;
                        if (text.Length > kMaxChars)
                        {
                            text = text.Substring(0, kMaxChars) + "...\n\n<...etc...>";
                        }
                        GUILayout.TextArea(text);
                    }
                }

                EditorGUILayout.Space();
            }

            return(false);
        }
        public bool DrawLayout()
        {
            var module = m_MainModule.Dereference(m_Registry);
            var system = System.Dereference(m_Registry);

            if (null == system || system.IsRuntimeIncluded)
            {
                return(false);
            }

            m_AvailableSystems.Clear();
            m_AvailableSystems.AddRange(module.EnumerateDependencies().SystemRefs());

            m_AvailableComponentTypes.Clear();
            m_AvailableComponentTypes.AddRange(module.EnumerateDependencies().ComponentTypeRefs().Select(r => (UTinyType.Reference)r.Dereference(m_Registry)));

            EditorGUI.BeginChangeCheck();

            using (var scroll = new GUILayout.ScrollViewScope(m_Scroll, GUILayout.ExpandWidth(true)))
            {
                m_Scroll = scroll.scrollPosition;

                EditorGUI.BeginChangeCheck();
                system.Name = EditorGUILayout.DelayedTextField("Name", system.Name);
                if (EditorGUI.EndChangeCheck())
                {
                    OnRenameEnded?.Invoke(system);
                }

                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.PrefixLabel("Description");
                    system.Documentation.Summary = EditorGUILayout.TextArea(system.Documentation.Summary, GUILayout.Height(50));
                }

                m_ExecuteAfterList.list = new List <UTinySystem.Reference>(system.ExecuteAfter);
                m_ExecuteAfterList.DoLayoutList();

                m_ExecuteBeforeList.list = new List <UTinySystem.Reference>(system.ExecuteBefore);
                m_ExecuteBeforeList.DoLayoutList();

                m_ComponentList.list = new List <UTinyType.Reference>(system.Components);
                m_ComponentList.DoLayoutList();

                system.External = EditorGUILayout.Toggle(new GUIContent("External", "Use this to define systems externally"), system.External);

                if (system.External)
                {
                    EditorGUILayout.HelpBox($"This system is assumed to be defined in any included script with the following signature", MessageType.Info);
                    var name = UTinyBuildPipeline.GetJsTypeName(system);
                    EditorGUILayout.SelectableLabel($"{name}.update = function(s,w) {{ /* ... */ }}", "TextArea");
                }
                else
                {
                    system.IncludeIterator = EditorGUILayout.Toggle("Include Iterator", system.IncludeIterator);

                    EditorGUILayout.Space();

                    using (new GUIEnabledScope(false))
                    {
                        var systemPrefix = UTinyBuildPipeline.GenerateSystemPrefix(system);
                        if (system.IncludeIterator)
                        {
                            systemPrefix += UTinyBuildPipeline.GenerateSystemIteratorPrefix(system);
                        }

                        EditorGUILayout.TextArea(systemPrefix);
                    }

                    EditorGUILayout.Space();

                    system.TextAsset = (TextAsset)EditorGUILayout.ObjectField("Source", system.TextAsset, typeof(TextAsset), false);

                    EditorGUILayout.Space();

                    if (null != system.TextAsset)
                    {
                        using (new GUIEnabledScope(false))
                        {
                            var text = system.TextAsset.text;
                            if (text.Length > kMaxChars)
                            {
                                text = text.Substring(0, kMaxChars) + "...\n\n<...etc...>";
                            }
                            GUILayout.TextArea(text);
                        }
                    }

                    EditorGUILayout.Space();

                    using (new GUIEnabledScope(false))
                    {
                        var systemSuffix = UTinyBuildPipeline.GenerateSystemSuffix(system);
                        if (system.IncludeIterator)
                        {
                            systemSuffix = UTinyBuildPipeline.GenerateSystemIteratorSuffix(system) + systemSuffix;
                        }
                        EditorGUILayout.TextArea(systemSuffix);
                    }
                }
            }

            return(EditorGUI.EndChangeCheck());
        }