public virtual Script AddScript(Script script, bool removeScriptWithSamePath = false)
        {
            if (script == null)
            {
                return(null);
            }

            // If script was already loaded, reload it to last saved state
            var oldScript = m_LoadedScripts.FirstOrDefault(s => s.Path.Equals(script.Path));

            if (oldScript != default(Script) && removeScriptWithSamePath)
            {
                // Reload Script
                var index = m_LoadedScripts.IndexOf(oldScript);
                UnsubscribeToScriptEvents(oldScript);

                ScriptGuidMap.RemoveGuidFromMap(m_LoadedScripts[index]);
                ScriptGuidMap.AddGuidToMapAndGenerateUniqueIfNeeded(script);

                m_LoadedScripts[index] = script;
                ScriptModified?.Invoke(script);
            }
            else
            {
                // Load New Script
                ScriptGuidMap.AddGuidToMapAndGenerateUniqueIfNeeded(script);
                m_LoadedScripts.Add(script);
                ScriptAdded?.Invoke(script);
            }

            SubscribeToScriptEvents(script);
            return(script);
        }
示例#2
0
 private void tbScriptOutput_TextChanged(object sender, FastColoredTextBoxNS.TextChangedEventArgs e)
 {
     _manualEdits = true;
     ScriptModified?.Invoke(sender, e);
 }