public CodeGeneratorConfig(EntitasPreferencesConfig config, string[] codeGenerators) {
     _config = config;
     _defaultEnabledCodeGenerators = joinCodeGenerators(codeGenerators);
     generatedFolderPath = generatedFolderPath;
     pools = pools;
     enabledCodeGenerators = enabledCodeGenerators;
 }
 public CodeGeneratorConfig(EntitasPreferencesConfig config)
 {
     _config = config;
     generatedFolderPath = generatedFolderPath;
     pools = pools;
     disabledCodeGenerators = disabledCodeGenerators;
 }
예제 #3
0
 public void Initialize(EntitasPreferencesConfig config)
 {
     _visualDebuggingConfig  = new VisualDebuggingConfig(config);
     _scriptingDefineSymbols = new ScriptingDefineSymbols();
     _enableVisualDebugging  = !_scriptingDefineSymbols.buildTargetToDefSymbol.Values
                               .All <string>(defs => defs.Contains(ENTITAS_DISABLE_VISUAL_DEBUGGING));
 }
 public VisualDebuggingConfig(EntitasPreferencesConfig config)
 {
     _config = config;
     systemWarningThreshold           = systemWarningThreshold;
     defaultInstanceCreatorFolderPath = defaultInstanceCreatorFolderPath;
     typeDrawerFolderPath             = typeDrawerFolderPath;
 }
예제 #5
0
        public void Draw(EntitasPreferencesConfig config)
        {
            EntitasEditorLayout.BeginVerticalBox();
            {
                EditorGUILayout.LabelField("VisualDebugging", EditorStyles.boldLabel);

                EditorGUI.BeginChangeCheck();
                {
                    _enableVisualDebugging = EditorGUILayout.Toggle("Enable Visual Debugging", _enableVisualDebugging);
                }
                var changed = EditorGUI.EndChangeCheck();

                if (changed)
                {
                    if (_enableVisualDebugging)
                    {
                        _scriptingDefineSymbols.RemoveDefineSymbol(ENTITAS_DISABLE_VISUAL_DEBUGGING);
                    }
                    else
                    {
                        _scriptingDefineSymbols.AddDefineSymbol(ENTITAS_DISABLE_VISUAL_DEBUGGING);
                    }
                }

                EditorGUILayout.Space();

                _visualDebuggingConfig.defaultInstanceCreatorFolderPath =
                    EditorGUILayout.TextField("DefaultInstanceCreator Folder", _visualDebuggingConfig.defaultInstanceCreatorFolderPath);

                _visualDebuggingConfig.typeDrawerFolderPath =
                    EditorGUILayout.TextField("TypeDrawer Folder", _visualDebuggingConfig.typeDrawerFolderPath);
            }
            EntitasEditorLayout.EndVertical();
        }
예제 #6
0
 public CodeGeneratorConfig(EntitasPreferencesConfig config)
 {
     _config             = config;
     generatedFolderPath = generatedFolderPath;
     pools = pools;
     disabledCodeGenerators = disabledCodeGenerators;
 }
예제 #7
0
 public CodeGeneratorConfig(EntitasPreferencesConfig config, string[] codeGenerators)
 {
     _config = config;
     _defaultEnabledCodeGenerators = joinCodeGenerators(codeGenerators);
     generatedFolderPath           = generatedFolderPath;
     pools = pools;
     enabledCodeGenerators = enabledCodeGenerators;
 }
 public void Initialize(EntitasPreferencesConfig config)
 {
     _scriptingDefineSymbols = new ScriptingDefineSymbols();
     _scriptCallOptimization = _scriptingDefineSymbols.buildTargetToDefSymbol.Values
                                     .All<string>(defs => defs.Contains(ENTITAS_FAST_AND_UNSAFE))
                                         ? ScriptCallOptimization.FastAndUnsafe
                                         : ScriptCallOptimization.Disabled;
 }
예제 #9
0
        public void Draw(EntitasPreferencesConfig config)
        {
            var codeGeneratorConfig = new CodeGeneratorConfig(config);

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUILayout.LabelField("CodeGenerator", EditorStyles.boldLabel);

            // Generated Folder
            codeGeneratorConfig.generatedFolderPath = EditorGUILayout.TextField("Generated Folder", codeGeneratorConfig.generatedFolderPath);

            // Pools
            var pools = new List <string>(codeGeneratorConfig.pools);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Pools");
            if (pools.Count == 0)
            {
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.TextField("DefaultPool");
                EditorGUI.EndDisabledGroup();
            }

            for (int i = 0; i < pools.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                pools[i] = EditorGUILayout.TextField(pools[i]);
                if (GUILayout.Button("-", GUILayout.Width(19), GUILayout.Height(14)))
                {
                    pools[i] = string.Empty;
                }
                EditorGUILayout.EndHorizontal();
            }

            if (GUILayout.Button("Add pool"))
            {
                pools.Add("PoolName");
            }

            if (pools.Count == 0)
            {
                EditorGUILayout.HelpBox("You can optimize the memory footprint of entities by creating multiple pools. " +
                                        "The code generator generates subclasses of PoolAttribute for each pool name. " +
                                        "You can assign components to a specific pool with the generated attribute, e.g. [UI] or [MetaGame], " +
                                        "otherwise they are assigned to the default pool.", MessageType.Info);
            }

            codeGeneratorConfig.pools = pools.ToArray();

            EditorGUILayout.Space();
            if (GUILayout.Button("Generate"))
            {
                CodeGeneratorEditor.Generate();
            }

            EditorGUILayout.EndVertical();
        }
        protected override void drawContent(EntitasPreferencesConfig config) {
            drawTargetFolder();
            drawContexts();

            _codeGeneratorConfig.dataProviders = drawMaskField("Data Providers", _availableDataProviderTypes, _availableDataProviderNames, _codeGeneratorConfig.dataProviders);
            _codeGeneratorConfig.codeGenerators = drawMaskField("Code Generators", _availableGeneratorTypes, _availableGeneratorNames, _codeGeneratorConfig.codeGenerators);
            _codeGeneratorConfig.postProcessors = drawMaskField("Post Processors", _availablePostProcessorTypes, _availablePostProcessorNames, _codeGeneratorConfig.postProcessors);

            drawGenerateButton();
        }
        public void Draw(EntitasPreferencesConfig config)
        {
            EntitasEditorLayout.BeginVerticalBox();
            {
                EditorGUILayout.LabelField("Code Generator", EditorStyles.boldLabel);

                drawGeneratedFolderPath();
                drawPools();
                drawCodeGenerators();
            }
            EntitasEditorLayout.EndVertical();
        }
예제 #12
0
 public void Draw(EntitasPreferencesConfig config)
 {
     _drawContent = EntitasEditorLayout.DrawSectionHeaderToggle(title, _drawContent);
     if (_drawContent)
     {
         EntitasEditorLayout.BeginSectionContent();
         {
             drawContent(config);
         }
         EntitasEditorLayout.EndSectionContent();
     }
 }
        public void Draw(EntitasPreferencesConfig config)
        {
            var visualDebuggingConfig = new VisualDebuggingConfig(config);

            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                EditorGUILayout.LabelField("VisualDebugging", EditorStyles.boldLabel);

                visualDebuggingConfig.defaultInstanceCreatorFolderPath = EditorGUILayout.TextField("DefaultInstanceCreator Folder", visualDebuggingConfig.defaultInstanceCreatorFolderPath);
                visualDebuggingConfig.typeDrawerFolderPath             = EditorGUILayout.TextField("TypeDrawer Folder", visualDebuggingConfig.typeDrawerFolderPath);
            }
            EditorGUILayout.EndVertical();
        }
예제 #14
0
        public CodeGeneratorConfig(EntitasPreferencesConfig config, string[] dataProviders, string[] codeGenerators, string[] postProcessors)
        {
            _config = config;
            _defaultDataProviders  = joinValues(dataProviders);
            _defaultCodeGenerators = joinValues(codeGenerators);
            _defaultPostProcessors = joinValues(postProcessors);

            // Assigning will apply default values to missing keys
            targetDirectory     = targetDirectory;
            contexts            = contexts;
            this.dataProviders  = this.dataProviders;
            this.codeGenerators = this.codeGenerators;
            this.postProcessors = this.postProcessors;
        }
        public void Draw(EntitasPreferencesConfig config)
        {
            var visualDebuggingConfig = new VisualDebuggingConfig(config);

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUILayout.LabelField("VisualDebugging", EditorStyles.boldLabel);

            visualDebuggingConfig.defaultInstanceCreatorFolderPath = EditorGUILayout.TextField("DefaultInstanceCreator Folder", visualDebuggingConfig.defaultInstanceCreatorFolderPath);
            visualDebuggingConfig.typeDrawerFolderPath             = EditorGUILayout.TextField("TypeDrawer Folder", visualDebuggingConfig.typeDrawerFolderPath);

            EditorGUILayout.HelpBox("Specify the folder where to save generated templates.", MessageType.Info);

            EditorGUILayout.EndVertical();
        }
        public void Draw(EntitasPreferencesConfig config)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUILayout.LabelField("CodeGenerator", EditorStyles.boldLabel);

            var codeGeneratorConfig = new CodeGeneratorConfig(config);

            drawGeneratedFolderPath(codeGeneratorConfig);
            drawPools(codeGeneratorConfig);
            drawCodeGenerators(codeGeneratorConfig);
            drawGenerateButton();

            EditorGUILayout.EndVertical();
        }
        void OnEnable()
        {
            _headerTexture = EntitasEditorLayout.LoadTexture("l:EntitasHeader");
            _localVersion = EntitasCheckForUpdates.GetLocalVersion();
            _config = EntitasPreferences.LoadConfig();
            _preferencesDrawers = Assembly.GetAssembly(typeof(IEntitasPreferencesDrawer)).GetTypes()
                .Where(type => type.ImplementsInterface<IEntitasPreferencesDrawer>())
                .Select(type => (IEntitasPreferencesDrawer)Activator.CreateInstance(type))
                .OrderBy(drawer => drawer.priority)
                .ToArray();

            foreach(var drawer in _preferencesDrawers) {
                drawer.Initialize(_config);
            }
        }
예제 #18
0
        public void Draw(EntitasPreferencesConfig config)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUILayout.LabelField("CodeGenerator", EditorStyles.boldLabel);

            var codeGenerators      = CodeGenerator.GetCodeGenerators();
            var codeGeneratorNames  = codeGenerators.Select(cg => cg.Name).ToArray();
            var codeGeneratorConfig = new CodeGeneratorConfig(config, codeGeneratorNames);

            drawGeneratedFolderPath(codeGeneratorConfig);
            drawPools(codeGeneratorConfig);
            drawCodeGenerators(codeGeneratorConfig, codeGenerators);
            drawGenerateButton();

            EditorGUILayout.EndVertical();
        }
예제 #19
0
        protected override void drawContent(EntitasPreferencesConfig config)
        {
            EditorGUILayout.BeginHorizontal();
            {
                drawVisualDebugging();
                if (GUILayout.Button("Show Stats", EditorStyles.miniButton))
                {
                    EntitasStats.ShowStats();
                }
            }
            EditorGUILayout.EndHorizontal();


            EditorGUILayout.Space();

            drawDefaultInstanceCreator();
            drawTypeDrawerFolder();
        }
        public void Initialize(EntitasPreferencesConfig config)
        {
            _codeGenerators = UnityCodeGenerator.GetCodeGenerators();
            var codeGeneratorNames = _codeGenerators.Select(cg => cg.Name).ToArray();

            _codeGeneratorConfig = new CodeGeneratorConfig(config, codeGeneratorNames);

            _pools = new List <string>(_codeGeneratorConfig.pools);

            _poolList = new UnityEditorInternal.ReorderableList(_pools, typeof(string), true, true, true, true);
            _poolList.drawHeaderCallback  = rect => EditorGUI.LabelField(rect, "Custom Pools");
            _poolList.drawElementCallback = (rect, index, isActive, isFocused) => {
                rect.width   -= 20;
                _pools[index] = EditorGUI.TextField(rect, _pools[index]);
            };
            _poolList.onAddCallback       = list => list.list.Add("New Pool");
            _poolList.onCanRemoveCallback = list => true;
            _poolList.onChangedCallback   = list => GUI.changed = true;
        }
        public override void Initialize(EntitasPreferencesConfig config) {
            var enabledDataProviderNames = initPhase<ICodeGeneratorDataProvider>(out _availableDataProviderTypes, out _availableDataProviderNames);
            var enabledGeneratorNames = initPhase<ICodeGenerator>(out _availableGeneratorTypes, out _availableGeneratorNames);
            var enabledPostProcessorNames = initPhase<ICodeGenFilePostProcessor>(out _availablePostProcessorTypes, out _availablePostProcessorNames);

            _codeGeneratorConfig = new CodeGeneratorConfig(config, enabledDataProviderNames, enabledGeneratorNames, enabledPostProcessorNames);

            _contexts = new List<string>(_codeGeneratorConfig.contexts);

            _contextList = new UnityEditorInternal.ReorderableList(_contexts, typeof(string), true, true, true, true);
            _contextList.drawHeaderCallback = rect => EditorGUI.LabelField(rect, "Contexts");
            _contextList.drawElementCallback = (rect, index, isActive, isFocused) => {
                rect.width -= 20;
                _contexts[index] = EditorGUI.TextField(rect, _contexts[index]);
            };
            _contextList.onAddCallback = list => list.list.Add("New Context");
            _contextList.onCanRemoveCallback = list => list.count > 1;
            _contextList.onChangedCallback = list => GUI.changed = true;
        }
    void when_config()
    {
        EntitasPreferencesConfig config = null;

        before = () => {
            config = new EntitasPreferencesConfig(string.Empty);
        };

        it["gets string from empty config"] = () => config.ToString().should_be(string.Empty);
        it["gets default value from empty config and sets value for trimmed key"] = () => {
            config.GetValueOrDefault(" testKey ", " testValue ").should_be("testValue ");
            config.ToString().should_be("testKey = testValue \n");
        };

        it["sets value for trimmed key"] = () => {
            config[" test key "] = "test value";
            config["test key"].should_be("test value");
            config.ToString().should_be("test key = test value\n");
        };
    }
예제 #23
0
        protected override void drawContent(EntitasPreferencesConfig config)
        {
            EditorGUILayout.BeginHorizontal();
            {
                drawVisualDebugging();
                if (GUILayout.Button("Show Stats", EditorStyles.miniButton))
                {
                    EntitasStats.ShowStats();
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            _visualDebuggingConfig.systemWarningThreshold = EditorGUILayout.IntField("System Warning Threshold", int.Parse(_visualDebuggingConfig.systemWarningThreshold)).ToString();

            EditorGUILayout.Space();

            drawDefaultInstanceCreator();
            drawTypeDrawerFolder();
        }
예제 #24
0
        public void Draw(EntitasPreferencesConfig config)
        {
            EntitasEditorLayout.BeginVerticalBox();
            {
                EditorGUILayout.LabelField("Code Generator", EditorStyles.boldLabel);

                drawGeneratedFolderPath();
                drawContexts();

                _codeGeneratorConfig.dataProviders  = drawMaskField("Data Providers", _availableDataProviderTypes, _availableDataProviderNames, _codeGeneratorConfig.dataProviders);
                _codeGeneratorConfig.codeGenerators = drawMaskField("Code Generators", _availableGeneratorTypes, _availableGeneratorNames, _codeGeneratorConfig.codeGenerators);
                _codeGeneratorConfig.postProcessors = drawMaskField("Post Processors", _availablePostProcessorTypes, _availablePostProcessorNames, _codeGeneratorConfig.postProcessors);

                var bgColor = GUI.backgroundColor;
                GUI.backgroundColor = Color.green;
                if (GUILayout.Button("Generate", GUILayout.Height(32)))
                {
                    UnityCodeGenerator.Generate();
                }
                GUI.backgroundColor = bgColor;
            }
            EntitasEditorLayout.EndVertical();
        }
        public void Draw(EntitasPreferencesConfig config)
        {
            EditorGUI.BeginChangeCheck();
            {
                EntitasEditorLayout.BeginVerticalBox();
                {
                    EditorGUILayout.LabelField("Entitas", EditorStyles.boldLabel);

                    _scriptCallOptimization = (ScriptCallOptimization)EditorGUILayout
                        .EnumPopup("Optimizations", _scriptCallOptimization);
                }
                EntitasEditorLayout.EndVertical();
            }
            var changed = EditorGUI.EndChangeCheck();

            if(changed) {
                if(_scriptCallOptimization == ScriptCallOptimization.Disabled) {
                    _scriptingDefineSymbols.RemoveDefineSymbol(ENTITAS_FAST_AND_UNSAFE);
                } else {
                    _scriptingDefineSymbols.AddDefineSymbol(ENTITAS_FAST_AND_UNSAFE);
                }
            }
        }
예제 #26
0
 public abstract void Initialize(EntitasPreferencesConfig config);
 public VisualDebuggingConfig(EntitasPreferencesConfig config) {
     _config = config;
     defaultInstanceCreatorFolderPath = defaultInstanceCreatorFolderPath;
     typeDrawerFolderPath = typeDrawerFolderPath;
 }
예제 #28
0
 public CodeGeneratorConfig(EntitasPreferencesConfig config) : this(config, new string[0], new string[0], new string[0])
 {
 }
 public void Initialize(EntitasPreferencesConfig config)
 {
     _visualDebuggingConfig = new VisualDebuggingConfig(config);
 }
예제 #30
0
 protected abstract void drawContent(EntitasPreferencesConfig config);
예제 #31
0
 public void Draw(EntitasPreferencesConfig config)
 {
     EditorGUILayout.LabelField("Test");
 }