Ejemplo n.º 1
0
 /// <summary>
 /// 注销一个插件
 /// </summary>
 /// <param name="plugin">要注销的插件</param>
 public static void Unregister(VisualNovelPlugin plugin)
 {
     if (Plugins.ContainsKey(plugin.Name))
     {
         if (plugin.OnUnregister(false))
         {
             Plugins.Remove(plugin.Name);
         }
         else if (Application.isEditor)
         {
             Debug.LogWarning($"Plugin {plugin.Name} unregisteration failed: target plugin denied to unregister");
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 注册一个插件
 /// <para>相同名称的插件会覆盖之前注册的插件</para>
 /// </summary>
 /// <param name="plugin">要注册的插件</param>
 public static void Register([NotNull] VisualNovelPlugin plugin)
 {
     if (Plugins.ContainsKey(plugin.Name))
     {
         if (!plugin.OnUnregister(true))
         {
             throw new NotSupportedException($"Plugin {plugin.Name} registration failed: conflict plugin denied to unregister");
         }
         Plugins.Remove(plugin.Name);
     }
     if (plugin.OnRegister())
     {
         Plugins.Add(plugin.Name, plugin);
     }
     else if (Application.isEditor)
     {
         Debug.LogWarning($"Plugin {plugin.Name} registration failed: target plugin denied to register");
     }
 }