public override bool DrawLayout()
        {
            m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);
            try
            {
                if (Event.current.commandName == "ObjectSelectorUpdated" &&
                    EditorGUIUtility.GetObjectPickerControlID() == s_ObjectPickerId)
                {
                    var @object = EditorGUIUtility.GetObjectPickerObject();

                    if (null != @object)
                    {
                        m_MainModule.Dereference(m_Registry).AddAsset(@object);
                        m_TreeView.SetDirty();
                    }
                }

                var selections = m_TreeView.GetSelection();
                m_AssetPreviewControl.SetAssets(selections.Select(s => m_TreeView.Model.Find(s)).NotNull());

                return(base.DrawLayout());
            }
            finally
            {
                EditorGUILayout.EndScrollView();
            }
        }
        private void CreateSystem()
        {
            var module = m_MainModule.Dereference(m_Registry);
            var system = m_Registry.CreateSystem(UTinyId.New(), UTinyUtility.GetUniqueName(module.EnumerateDependencies().SystemRefs(), "NewSystem"));

            module.AddSystemReference((UTinySystem.Reference)system);
            m_TreeView.Reload();
            m_TreeView.SetSelection(system.Id);
            system.TextAsset = CreateTextAsset(system.Name);
        }
        private void CreateAssetExportInfo <TSettings>(IEnumerable <UTinyAssetInfo> assetInfos)
            where TSettings : UTinyAssetExportSettings, ICopyable <TSettings>, new()
        {
            var project = m_Project.Dereference(m_Registry);
            var module  = m_MainModule.Dereference(m_Registry);

            foreach (var assetInfo in assetInfos)
            {
                CreateAssetExportInfo <TSettings>(project, module, assetInfo);
            }
        }
        private void CreateEntityGroup()
        {
            var module      = m_MainModule.Dereference(m_Registry);
            var entityGroup = m_Registry.CreateEntityGroup(UTinyId.New(), UTinyUtility.GetUniqueName(module.EntityGroups, "NewEntityGroup"));

            module.AddEntityGroupReference((UTinyEntityGroup.Reference)entityGroup);
            m_TreeView.Reload();
            m_TreeView.SetSelection(new List <int> {
                m_TreeView.State.GetInstanceId(entityGroup.Id)
            }, TreeViewSelectionOptions.RevealAndFrame);
        }
示例#5
0
        private void CreateSystem()
        {
            var module = m_MainModule.Dereference(m_Registry);
            var system = m_Registry.CreateSystem(UTinyId.New(), UTinyUtility.GetUniqueName(module.EnumerateDependencies().SystemRefs(), "NewSystem"));

            system.AddExecuteAfterReference((UTinySystem.Reference)module.Registry.FindByName <UTinySystem>("UserCodeStart"));
            system.AddExecuteBeforeReference((UTinySystem.Reference)module.Registry.FindByName <UTinySystem>("UserCodeEnd"));
            system.TextAsset = CreateTextAsset(system.Name);
            module.AddSystemReference((UTinySystem.Reference)system);

            m_TreeView.Reload();
            m_TreeView.SetSelection(system.Id);
        }
示例#6
0
        private void CreateComponent()
        {
            var module = m_MainModule.Dereference(m_Registry);
            var type   = m_Registry.CreateType(
                UTinyId.New(),
                UTinyUtility.GetUniqueName(module.Components, "NewComponent"),
                UTinyTypeCode.Component);

            module.AddComponentReference((UTinyType.Reference)type);

            m_TreeView.Reload();
            m_TreeView.SetSelection(new List <int> {
                m_TreeView.State.GetInstanceId(type.Id)
            }, TreeViewSelectionOptions.RevealAndFrame |
                                    TreeViewSelectionOptions.FireSelectionChanged);
        }
示例#7
0
        public override bool DrawLayout()
        {
            var module = m_Module.Dereference(m_Registry);

            m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);

            try
            {
                GUILayout.Label("Module Settings", UTinyStyles.Header1);

                AssetNameField(module);
                module.Namespace             = NamespaceField("Javascript Namespace", module.Namespace);
                module.Documentation.Summary = DescriptionField("Description", module.Documentation.Summary);

                EditorGUILayout.Space();

                return(false);
            }
            finally
            {
                EditorGUILayout.EndScrollView();
            }
        }
        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());
        }
示例#9
0
 public UTinyModuleTreeViewItem(IRegistry registry, UTinyModule.Reference mainModule, UTinyModule.Reference module) : base(registry, mainModule, module)
 {
     m_Included = mainModule.Dereference(registry).ContainsExplicitModuleDependency(module);
 }