public override void LoadCacheUIItem(UICacheMarkOperate operateEnum, string parameter) { base.LoadCacheUIItem(operateEnum, parameter); if (m_UICachePrefabScript == null) { return; } //设置Button的相关属性 Button button = GetAttachComponent <Button>(); if (button == null) { return; } // Debug.Log("UIButtonWithoutTextCacheItemMark"); m_ButtonEffect = m_UICachePrefabScript.transform.GetAddComponent <ButtonEffect>(); m_ButtonEffect.enabled = m_ButtonSetting.m_IsBtnEffectEnable; button.transition = m_ButtonSetting.m_Transition; if (button.transition == Selectable.Transition.SpriteSwap) { SpriteState spriteState = button.spriteState; if (m_ButtonSetting.m_DisabledSpritePath != string.Empty) { //2017/11/27注释掉 // spriteState.disabledSprite = ResourceMgr.instance.LoadSprite(m_ButtonSetting.m_DisabledSpritePath); button.spriteState = spriteState; } } }
public override void LoadCacheUIItem(UICacheMarkOperate operateEnum, string parameter) { base.LoadCacheUIItem(operateEnum, parameter); if (m_UICachePrefabScript == null) { return; } // Debug.Log("UIButtonWithTextMeshCacheItemMark"); //设置TextMesh的相关属性 TMPro.TextMeshProUGUI text = m_UICachePrefabScript.GetAttachComponent <TMPro.TextMeshProUGUI>(); if (text == null) { return; } text.fontSize = m_TextMeshSetting.m_FontSize; text.color = m_TextMeshSetting.m_Color; text.raycastTarget = m_TextMeshSetting.m_RaycastTarget; text.alignment = m_TextMeshSetting.m_Alignment; text.overflowMode = m_TextMeshSetting.m_OverFlowMode; #if UNITY_EDITOR if (Application.isPlaying) { return; } text.text = m_TextMeshSetting.m_Text; #endif }
/// <summary> /// 初始化Buttton /// </summary> /// <param name="operateEnum"></param> /// <param name="paramet"></param> public override void OnGetUIItemInitial(UICacheMarkOperate operateEnum, string paramet) { // Debug.LogInfor("OnGetUIItemInitial searchIndex=" + paramet); // if (operateEnum == UICacheMarkOperate.SelectBtnTextType) { if (m_AllTextChild == null || m_AllTextChild.Count == 0) { Debug.LogError("OnGetUIItemInitial Fail,This UICachePrefab_ButtonWithTextMesh Not Set Right Index ::" + transform.parent.name); return; } if (int.TryParse(paramet, out m_SelectValue) == false) { Debug.LogError("选择的Text 索引不是整数形式 " + transform.parent.name); m_SelectValue = 0; } SelectTextByIndex(m_SelectValue); } }
public override void LoadCacheUIItem(UICacheMarkOperate operateEnum, string parameter) { base.LoadCacheUIItem(operateEnum, parameter); if (m_UICachePrefabScript == null) { return; } //设置TextMesh的相关属性 UnityEngine.UI.Text text = m_UICachePrefabScript.GetAttachComponent <UnityEngine.UI.Text>(); if (text == null) { return; } text.fontSize = m_BuildInTextSetting.m_FontSize; text.color = m_BuildInTextSetting.m_Color; text.raycastTarget = m_BuildInTextSetting.m_RaycastTarget; text.alignment = m_BuildInTextSetting.m_Alignment; text.text = m_BuildInTextSetting.m_Text; }
public virtual void LoadCacheUIItem(UICacheMarkOperate operateEnum, string parameter) { if (m_IsLoaded) UnLoadItem(); m_IsLoaded = true; // Debug.Log("UICachePoolManager.Instance " + (UICachePoolManager.Instance == null)); m_LoadUIItem = UICachePoolManager.Instance.GetUIItemByPath(m_LoadPrefabPath); m_UICachePrefabScript = m_LoadUIItem.GetComponent<UICachePrefabBase>(); //设置自动对其到父节点下 m_LoadUIItem.SetParent(transform, false); m_LoadUIItem.SetAsFirstSibling(); m_LoadUIItem.localScale = Vector3.one; if (m_LoadUIItem.gameObject.activeSelf == false) m_LoadUIItem.gameObject.SetActive(true); // Debug.Log("UICacheItemMark"); m_UICachePrefabScript.OnGetUIItemInitial(operateEnum, parameter); //对获取的UI缓存的额额哎处理 m_LoadUIItem.localScale = Vector3.one; m_LoadUIItem.anchoredPosition = Vector2.zero; m_LoadUIItem.anchorMax = Vector2.one; m_LoadUIItem.anchorMin = Vector2.zero; m_LoadUIItem.sizeDelta = Vector2.zero; //设置位于父节点下的最前面,防止挡住其他节点 m_LoadUIItem.SetAsFirstSibling(); //在编辑模式下设置不可被保存,也就是apply后不会再被保存在prefab上 #if UNITY_EDITOR foreach (Transform t in m_LoadUIItem.GetComponentsInChildren<Transform>()) { t.gameObject.hideFlags = HideFlags.NotEditable | HideFlags.DontSave; } #endif if (onLoad != null) onLoad(); }
public override void LoadCacheUIItem(UICacheMarkOperate operateEnum, string parameter) { base.LoadCacheUIItem(operateEnum, parameter); if (m_UICachePrefabScript == null) { return; } // Debug.Log("UIImageCacheItemMark"); //设置Image的相关属性 Image image = m_UICachePrefabScript.GetAttachComponent <Image>(); if (image == null) { return; } if (m_ImageSetting.m_SpritePath != string.Empty) { //2017/11/27注释掉 // image.sprite = ResourceMgr.instance.LoadSprite(m_ImageSetting.m_SpritePath); } image.raycastTarget = m_ImageSetting.m_RaycastTarget; image.color = m_ImageSetting.m_Color; image.type = m_ImageSetting.m_ImageType; if (image.type == Image.Type.Filled) { image.fillMethod = m_ImageSetting.m_ImageFillMethod; image.fillOrigin = m_ImageSetting.m_ImageFillOrigin; } if (image.type == Image.Type.Simple) { image.preserveAspect = m_ImageSetting.m_IsPreserverAspec; } }
/// <summary> /// 加载一个缓存UI后的操作 /// </summary> /// <param name="operateEnum">操作类型</param> /// <param name="paramet">参数</param> public virtual void OnGetUIItemInitial(UICacheMarkOperate operateEnum, string paramet) { }