/// <summary> /// 初始化PluginTool /// </summary> /// <returns></returns> public bool Init() { Singleton <PlatformConfig> .singleton.Init(); IPluginToolImplManager pluginToolImplManager = UnityGameEntry.Instance.GetComponent("PluginToolImplManager") as IPluginToolImplManager; bool result; if (null == pluginToolImplManager) { this.m_log.Fatal("null == pluginToolManager"); result = false; } else { IPluginTool pluginTool = pluginToolImplManager.GetPluginTool(Singleton <PlatformConfig> .singleton.EPlatformType); if (null == pluginTool) { this.m_log.Fatal("null == pluginTool"); result = false; } else { PluginTool.Singleton.PayUrl = Singleton <PlatformConfig> .singleton.PayUrl; PluginTool.Singleton.RegisterUrl = Singleton <PlatformConfig> .singleton.RegisterUrl; PluginTool.Singleton.ForgetUrl = Singleton <PlatformConfig> .singleton.ForgetUrl; result = PluginTool.Singleton.Init(pluginTool); } } return(result); }
public bool Init(IPluginTool pluginTool) { if (pluginTool == null) { return(false); } this.m_pluginToolImpl = pluginTool; return(this.m_pluginToolImpl.Init()); }
private void InitializeActivePlugin() { foreach (IPluginTool plugin in m_iPlugins) { if ("PenTool" == plugin.Name) { m_iActivePlugin = plugin; m_iActivePlugin.Pen = m_pPen; break; } } }
public static ICollection <IPluginTool> LoadPlugins(string szPath) { string[] dllFileNames = null; if (Directory.Exists(szPath)) { dllFileNames = Directory.GetFiles(szPath, "*.dll"); } ICollection <Assembly> assemblies = new List <Assembly>(dllFileNames.Length); foreach (string dllFile in dllFileNames) { AssemblyName an = AssemblyName.GetAssemblyName(dllFile); Assembly assembly = Assembly.Load(an); assemblies.Add(assembly); } Type pluginType = typeof(IPluginTool); ICollection <Type> pluginTypes = new List <Type>(); foreach (Assembly assembly in assemblies) { if (assembly != null) { Type[] types = assembly.GetTypes(); foreach (Type type in types) { if (type.IsInterface || type.IsAbstract) { continue; } else { if (type.GetInterface(pluginType.FullName) != null) { pluginTypes.Add(type); } } } } } ICollection <IPluginTool> plugins = new List <IPluginTool>(pluginTypes.Count); foreach (Type type in pluginTypes) { IPluginTool plugin = (IPluginTool)Activator.CreateInstance(type); plugins.Add(plugin); } return(plugins); }
/// <summary> /// 根据不同的平台得到不同的平台插件工具 /// </summary> /// <param name="ePlatformType"></param> /// <returns></returns> public IPluginTool GetPluginTool(EnumPlatformType ePlatformType) { IPluginTool result = null; if (Application.platform == RuntimePlatform.Android) { result = null; } else if (Application.platform == RuntimePlatform.IPhonePlayer) { result = null; } else if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer) { Type type = Type.GetType("WindowsPluginToolImpl"); if (ePlatformType == EnumPlatformType.ePlatformType_Baidu) { type = Type.GetType("WindowsBaiduPluginToolImpl"); } result = (IPluginTool)Activator.CreateInstance(type); } return(result); }
private void Plugin_Change(IPluginTool plugin) { m_iActivePlugin = plugin; m_iActivePlugin.Pen = m_pPen; }