Ejemplo n.º 1
0
        private void BuildTab()
        {
            if (!_buildingMod && !_builtMod)
            {
                _buildingMod = true;
                ModLab.ClearDebug();
                var mod = new Mod(_modName, _modVersion, _modAuthor, _modDescription);
                foreach (var s in _givenFiles)
                {
                    ModLab.AddDebug("Adding asset: " + s.name);
                    var type = s.GetType();
                    if (type == typeof(MonoScript))
                    {
                        mod.AddScript(s);
                    }
                    else
                    {
                        ModLab.AddDebug("Unable to add asset: " + s.name + " (" + s.GetType() + ")");
                    }
                }
                ModLab.SerializeMod(mod);
                _builtMod    = true;
                _buildingMod = false;
            }

            var logRect = new Rect(8f, 24f, position.size.x - 16f, position.size.y - 24f - 8f);

            GUI.enabled = false;
            EditorGUI.TextArea(logRect, ModLab.DebugText);
            GUI.enabled = true;
        }
Ejemplo n.º 2
0
        public void RecompileScript(string modName, string scriptName, string newCode)
        {
            // save script change
            var loadedMod = _loadedMods.FirstOrDefault(mod => mod.Name == modName);
            var t         = loadedMod?.EditClass(scriptName, newCode);

            ModLab.SerializeMod(loadedMod);
            #if UNITY_EDITOR
            var logEntries  = Type.GetType("UnityEditor.LogEntries,UnityEditor.dll");
            var clearMethod = logEntries.GetMethod("Clear", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
            clearMethod.Invoke(null, null);
            #endif
            SceneManager.LoadScene(0);
        }