/// <summary> /// 获取控件 /// </summary> protected override void FetchPresenters() { if (GO == null) { return; } if (IsRootView) { return; } var tempPresenters = GO.GetComponentsInChildren <BasePresenter>(true); if (tempPresenters != null) { foreach (var item in tempPresenters) { if (!item.IsSubPresenter) { item.BaseUIView = this; presenters.Add(item); if (item.NeedUpdate) { ActivePresenterUpdate(item); } } } } Scrolls = GetComponentsInChildren <BaseScroll>(); }
// 获取控件 protected sealed override void FetchSubjects() { if (GO == null) { return; } if (IsRootView) { return; } //获得所有的控件 var tempControls = GO.GetComponentsInChildren <UControl>(true); if (tempControls != null) { foreach (var item in tempControls) { if (item is UPanel panel) { AddPanel(panel); item.OnBeFetched(); } else if (item.IsCanBeViewFetch) { AddControl(item); item.OnBeFetched(); } } } }
void Start() { PanelComponents = new List <OnePanel> (); objectMover = gameObject.AddComponent <ObjectManipulation> (); foreach (GameObject GO in PanelsToSwap) { OnePanel temp; temp.baseGameObject = GO; temp.AllColliders = GO.GetComponentsInChildren <Collider2D>(); temp.AllSpriteRenderers = GO.GetComponentsInChildren <SpriteRenderer>(); PanelComponents.Add(temp); // GO.transform.position = (Vector3)(Vector2)GO.transform.position + new Vector3(0,0,OffsetCounter); GO.transform.localPosition = new Vector3(0, 0, DistanceBetweenPanels * (MaxPanelIndex + 1)); OffsetCounter += DistanceBetweenPanels; MaxPanelIndex++; if (MaxPanelIndex != 0) { SetAllColliders(PanelComponents[MaxPanelIndex], false); SetSpriteAlpha(PanelComponents[MaxPanelIndex], 0.5f); } } CurrentActivePanel = 0; // foreach(OnePanel aPanel in PanelComponents) // { // print (string.Format ("{0}. Colliders = {1}. SpriteRenderers = {2}", aPanel.baseGameObject, aPanel.AllColliders.Length, aPanel.AllSpriteRenderers.Length)); // // } }
public virtual void AutoSetup() { if (UIConfig.DefaultNormalFont != null) { Text[] allTexts = GO.GetComponentsInChildren <Text>(); if (allTexts != null) { foreach (var item in allTexts) { item.font = UIConfig.DefaultNormalFont; } } } }
public override void Awake() { base.Awake(); _particleSystems = GO.GetComponentsInChildren <ParticleSystem>(); _animators = GO.GetComponentsInChildren <Animator>(); _animations = GO.GetComponentsInChildren <Animation>(); _colliders = GO.GetComponentsInChildren <Collider>(); _skinnedMeshRenders = GO.GetComponentsInChildren <SkinnedMeshRenderer>(); _meshRenders = GO.GetComponentsInChildren <MeshRenderer>(); _trailRenders = GO.GetComponentsInChildren <TrailRenderer>(); for (int i = 0; i < _colliders.Length; ++i) { _colliders[i].isTrigger = true; } _storeSize(); }
protected override void Awake() { SelfBaseGlobal = BaseGlobal.Ins; base.Awake(); RectTrans = transform as RectTransform; SourceAnchorMax = RectTrans.anchorMax; SourceAnchorMin = RectTrans.anchorMin; SourceLocalScale = RectTrans.localScale; SourceSizeData = RectTrans.sizeDelta; SourceAnchoredPosition = RectTrans.anchoredPosition; SourceAnchoredPosition3D = RectTrans.anchoredPosition3D; Trans = transform; GO = gameObject; if (RectTrans.localScale == Vector3.zero) { CLog.Error("错误:scale 是 0 error presenter:" + name); } GO.layer = (int)BaseConstMgr.Layer_UI; //作为顶级Pressenter可以获取自身层级下面的子对象,子对象随着父对象自动刷新 var childPresenters = GO.GetComponentsInChildren <BasePresenter>(); if (childPresenters != null) { foreach (var item in childPresenters) { AddChild(item); } } Transitions = GO.GetComponentsInChildren <UITransition>(true); ShowTransitions = GO.GetComponentsInChildren <UIShowTransition>(true); Texts = GO.GetComponentsInChildren <Text>(true); if (Texts != null && UIConfig.EnableSharpText && SelfBaseGlobal != null) { foreach (var item in Texts) { if (item != null) { item.material = SelfBaseGlobal.GRMgr.FontRendering; } } } ShowDefault(); }
void FetchTexts() { Texts = GO.GetComponentsInChildren <UnityEngine.UI.Text>(true); Font newFont = UIConfig.GetFont(FontType); if (newFont == null) { return; } if (Texts == null) { return; } if (SelfBaseGlobal == null) { return; } foreach (var item in Texts) { if (item != null) { if (UIConfig.EnableSharpText) { item.material = GRMgr.FontRendering; } item.resizeTextForBestFit = false; } } foreach (var item in Texts) { if (item != null) { GlobalUITextMgr.AddText(item, FontType); } } }
public static void ChangEffectLevel(int level) { if (Selection.transforms.Length > 0) { Transform[] GOs = Selection.transforms; foreach (var GO in GOs) { //需要递归往上做检查 Transform targetNode; int minLv = level; Transform father = GO.transform.parent; while (father != null) { int fatherLv = EffectLevelUtil.GetEffectLevel(father.gameObject); fatherLv = fatherLv == -1 ? 1 : fatherLv; targetNode = father; if (fatherLv <= minLv) { minLv = fatherLv; } else { EditorGUIUtility.PingObject(targetNode); //跳转定位 EditorUtility.DisplayDialog("警告", string.Format("父节点({0})存在级别较小的,所以这里只能大于{1}级别", targetNode.name, fatherLv), "好的"); return; } father = father.parent; } //往下查找-必须让子节点最小的那个大于要设置的 targetNode = null; minLv = level; foreach (var child in GO.GetComponentsInChildren <Transform>(true)) { if (child == GO) { continue; } int childLv = EffectLevelUtil.GetEffectLevel(child.gameObject); childLv = childLv == -1 ? level : childLv; if (childLv <= minLv) { minLv = childLv; targetNode = child; } } if (level > minLv) { EditorGUIUtility.PingObject(targetNode); //跳转定位 EditorUtility.DisplayDialog("警告", string.Format("子节点({0})存在级别较大的,所以这里只能小于或等于{1}级别", targetNode.name, minLv), "好的"); return; } EffectLevelUtil.SetEffectLevel(GO.gameObject, level); EditorUtility.SetDirty(GO); AssetDatabase.SaveAssets(); } } else { Debug.LogWarning("请选择一个节点"); } }
public virtual void OnBeFetched() { if (IsBeFetched) { return; } IsBeFetched = true; if (IsAutoInit) { Init(); } GO.layer = (int)Const.Layer_UI; if (ShowType == DefaultShowType.None) { IsShowDefault = GO.activeSelf; } else if (ShowType == DefaultShowType.Show) { IsShowDefault = true; } else if (ShowType == DefaultShowType.Close) { IsShowDefault = false; } IsShow = IsShowDefault; GO.SetActive(IsShow); AssignSource(); InitShowEffect(); FetchSubControls(); OnCreateControl(); void FetchSubControls() { ClearChilds(); //作为顶级Control可以获取自身层级下面的子对象,子对象随着父对象自动刷新 if (IsAutoFetchSubControls) { var childs = GO.GetComponentsInChildren <UControl>(true); if (childs != null) { foreach (var item in childs) { if (item == this) { continue; } if (item.IsCanBeControlFetch) { AddStaticChild(item); item.OnBeFetched(); } } } } } void AssignSource() { LayoutGroup = GetComponent <LayoutGroup>(); LayoutElement = GetComponent <LayoutElement>(); CanvasGroup = GetComponent <CanvasGroup>(); SourceAnchorMax = RectTrans.anchorMax; SourceAnchorMin = RectTrans.anchorMin; SourceLocalScale = RectTrans.localScale; SourceSizeData = RectTrans.sizeDelta; SourceAnchoredPosition = RectTrans.anchoredPosition; SourceAnchoredPosition3D = RectTrans.anchoredPosition3D; if (RectTrans.localScale == Vector3.zero) { CLog.Error("错误:scale 是 0 error presenter:" + name); } } void InitShowEffect() { EffectShowTrans.Clear(); if (IsSimpleShow) { EffectShowTrans.Add(AlphaSimpleShow); } if (IsAlphaShow) { EffectShowTrans.Add(AlphaShow); } if (IsColorShow) { EffectShowTrans.Add(ColorShow); } if (IsPosShow) { EffectShowTrans.Add(PosShow); } if (IsScaleShow) { EffectShowTrans.Add(ScaleShow); } float fadeInDuration = 0; float fadeOutDuration = 0; UIShow fadeInShow = MainEffectShowTrans; UIShow fadeOutShow = MainEffectShowTrans; foreach (var item in EffectShowTrans) { item.Init(this); var curFadeInDuration = item.GetDuration(true); if (curFadeInDuration > fadeInDuration) { fadeInShow = item; fadeInDuration = curFadeInDuration; } var curFadeOutDuration = item.GetDuration(false); if (curFadeOutDuration > fadeOutDuration) { fadeOutShow = item; fadeOutDuration = curFadeOutDuration; } } if (fadeInShow != null) { fadeInShow.SetFadeInCompleteCallback(OnFadeIn); } if (fadeOutShow != null) { fadeOutShow.SetFadeOutCompleteCallback(OnFadeOut); } } }