/* ----------------------------------------------------------------- */ /// /// Convert /// /// <summary> /// Convert メソッドを実行します。 /// </summary> /// /* ----------------------------------------------------------------- */ private string Convert(RssItem src, LockSettings settings) => new TitleConverter().Convert( new object[] { src, settings }, typeof(string), null, CultureInfo.CurrentCulture ) as string;
// Use this for initialization void Start() { // 最常見,缺點是在多執行緒中會有問題,確認不會在多執行緒中使用的話,用這個就好 Debug.LogFormat("Settings volume is {0}", Settings.getInstance().volume); // 在多執行緒中不會有問題,但沒有延遲實例化的好處了,不過Singleton物件一般來說也都很早就實例化,沒啥差 Debug.LogFormat("EagerlySettings volume is {0}", EagerlySettings.getInstance().volume); // 在多執行緒中不會有問題,但效能較差,每次試圖同時呼叫getInstance()都會造成等待 Debug.LogFormat("SynchronizedSettings volume is {0}", SynchronizedSettings.getInstance().volume); // 在多執行緒中不會有問題,且只有第一次呼叫getInstance()時可能會造成等待,之後就沒有效能問題 Debug.LogFormat("LockSettings volume is {0}", LockSettings.getInstance().volume); }
public static LockSettings getInstance() { if (instance == null) { lock (_lock) { if (instance == null) { instance = new LockSettings(); } } } return(instance); }
static Container() { var assetGuids = AssetDatabase.FindAssets("t:" + nameof(LockSettings)); for (var i = 0; i < assetGuids.Length; i++) { var asset = AssetDatabase.LoadAssetAtPath <LockSettings>(AssetDatabase.GUIDToAssetPath(assetGuids[i])); if (asset != null) { sm_lockSettings = asset; break; } } if (sm_lockSettings == null) { sm_lockSettings = ScriptableObject.CreateInstance <LockSettings>(); if (!AssetDatabase.IsValidFolder("Assets/Plugins")) { AssetDatabase.CreateFolder("Assets", "Plugins"); } if (!AssetDatabase.IsValidFolder("Assets/Plugins/UnityLocker")) { AssetDatabase.CreateFolder("Assets/Plugins", "UnityLocker"); } if (!AssetDatabase.IsValidFolder("Assets/Plugins/UnityLocker/Assets")) { AssetDatabase.CreateFolder("Assets/Plugins/UnityLocker", "Assets"); } AssetDatabase.CreateAsset(sm_lockSettings, "Assets/Plugins/UnityLocker/Assets/LockSettings.asset"); } var assemblies = AppDomain.CurrentDomain.GetAssemblies(); if (sm_lockSettings.IsSetUp) { sm_versionControlHandlers = new Dictionary <string, IVersionControlHandler>(4); for (var i = 0; i < assemblies.Length; i++) { var types = assemblies[i].GetTypes(); for (var j = 0; j < types.Length; j++) { var vcAttribute = types[j].GetCustomAttribute <VersionControlHandlerAttribute>(); if (vcAttribute != null) { sm_versionControlHandlers.Add(vcAttribute.Name, (IVersionControlHandler)Activator.CreateInstance(types[j])); } } } } else { Debug.LogError("Lock Settings has not been correctly configured"); } sm_assetTypeValidators = new AssetTypeValidatorCollection(); for (var i = 0; i < assemblies.Length; i++) { var types = assemblies[i].GetTypes(); for (var j = 0; j < types.Length; j++) { var atvAttribute = types[j].GetCustomAttribute <AssetTypeValidatorAttribute>(); if (atvAttribute != null) { sm_assetTypeValidators.Add((IAssetTypeValidator)Activator.CreateInstance(types[j]), atvAttribute.Flag); } } } #if !UNITY_2018_4_OR_NEWER sm_wWWManager = new WWWManager(); #endif #if UNITY_2018_4_OR_NEWER sm_webRequestManager = new WebRequestManager(); #endif }
private void ShowPicture(LockSettings setting) { if (String.IsNullOrEmpty(setting.PhotoPath)) ShowDefaultImage(); else ShowSelectedImage(setting.PhotoPath, setting.Photo); }