// Public Method #region Public Method public void SetActiveCamera(CameraKind kind) { var obj = GetCameraObject(kind); if (obj != null) { if (!obj.activeInHierarchy) { obj.SetActive(true); return; } } var data = GetCameraData(kind); if (data == null) { #if UNITY_EDITOR Debug.LogError(string.Format($"{kind.ToString()} 해당 카메라종류가 발견되지 않았습니다.")); #endif } else { var c = Instantiate <GameObject>(data.cameraObject, transform); c.SetActive(true); if (!dicCameraObjs.ContainsKey(data.kind)) { dicCameraObjs.Add(data.kind, c); } } }
// ------------- Behaviour ------------- private void Awake() { dicPoolers = new EnumDictionary <PoolerKind, IPooler>(); foreach (Poolers pooler in listPoolers) { if (!dicPoolers.ContainsKey(pooler.kind)) { var iPooler = pooler.objPooler.GetComponent(typeof(IPooler)) as IPooler; if (iPooler != null) { dicPoolers.Add(pooler.kind, iPooler); } else { #if UNITY_EDITOR Debug.LogWarning(string.Format($"Can't Find IPooledObject in {pooler.objPooler.name}")); #endif } } else { #if UNITY_EDITOR Debug.LogWarning(string.Format($"{pooler.kind.ToString()} is Exist")); #endif } } }
// ------------- ProtectedMethod ------------- // ------------- Public Method ------------- public UIBase OpenWindow(UI_Kind kind, bool isActive) { // 관리중인 UI가 아닐경우 Load if (!dicUI.ContainsKey(kind)) { var inst = LoadUI(kind); if (inst != null) { dicUI.Add(kind, inst); var component = inst.GetComponent(typeof(UIBase)) as UIBase; component.Init(); } else { return(null); } } // 관리중인 UI var ui = dicUI[kind].GetComponent(typeof(UIBase)) as UIBase; // 켜는게 아니면 해당 UI 최상위 스크립트 반환 if (isActive) { ui.SortingOrder = stackUI.Count; // 최상단에 띄운다. ui.OpenUI(); VerifyOpen(ui); dicUI[kind].SetActive(true); } return(ui); }
private void CreateCamera() { dicCameraObjs = new EnumDictionary <CameraKind, GameObject>(); foreach (var cam in dicCameras) { var c = Instantiate <GameObject>(cam.Value.cameraObject, transform); c.SetActive(false); if (!dicCameraObjs.ContainsKey(cam.Key)) { dicCameraObjs.Add(cam.Key, c); } } }
private void OnEnable() { if (dicFuzzyData == null && fuzzyDatas != null) { dicFuzzyData = new EnumDictionary <Membership, AnimationCurve>(); for (int i = 0; i < this.fuzzyDatas.Length; i++) { var key = (Membership)((int)fuzzyDatas[i].kind + (int)df_Fuzzy); if (!dicFuzzyData.ContainsKey(key)) { dicFuzzyData.Add(key, fuzzyDatas[i].membership); } } } }
// Private Method #region Private Method private void Init() { if (cameraDatas != null) { dicCameras = new EnumDictionary <CameraKind, CameraData>(); for (int i = 0; i < cameraDatas.Length; i++) { if (!dicCameras.ContainsKey(cameraDatas[i].kind)) { dicCameras.Add(cameraDatas[i].kind, cameraDatas[i]); cameraDatas[i].MappingCamera(); } } CreateCamera(); } }
private static Func <Enum, string> GetEnumStringResolver(Type type) { var values = Enum.GetValues(type); var dictionary = new EnumDictionary(values.Length); for (int index = 0; index < values.Length; index++) { var value = values.GetValue(index); #if DOTNETCORE var info = type.GetTypeInfo().GetDeclaredField(value.ToString()); #else var info = type.GetField(value.ToString()); #endif var da = (EnumMemberAttribute[])info.GetCustomAttributes(typeof(EnumMemberAttribute), false); var stringValue = da.Length > 0 ? da[0].Value : Enum.GetName(type, value); dictionary.Add((Enum)value, stringValue); } #if DOTNETCORE var isFlag = type.GetTypeInfo().GetCustomAttributes(typeof(FlagsAttribute), false).Any(); #else var isFlag = type.GetCustomAttributes(typeof(FlagsAttribute), false).Length > 0; #endif return((e) => { if (isFlag) { var list = new List <string>(); foreach (var kv in dictionary) { if (e.HasFlag(kv.Key)) { list.Add(kv.Value); } } return string.Join(",", list); } else { return dictionary[e]; } }); }
// Property #region Property #endregion // MonoBehaviour #region MonoBehaviour private void Awake() { dicFuzzyFunctions = new EnumDictionary <DF_FuzzySet, FuzzySet>(); dicFuzzyRules = new EnumDictionary <DF_FuzzyRule, FuzzyRule>(); for (int i = 0; i < fuzzyFunctions.Length; i++) { if (!dicFuzzyFunctions.ContainsKey(fuzzyFunctions[i].kind)) { dicFuzzyFunctions.Add(fuzzyFunctions[i].kind, fuzzyFunctions[i].fuzzySet); } } for (int i = 0; i < fuzzyRules.Length; i++) { if (!dicFuzzyRules.ContainsKey(fuzzyRules[i].kind)) { dicFuzzyRules.Add(fuzzyRules[i].kind, fuzzyRules[i].fuzzyRule); } } }