private void OnEnable() { _scrollView = (SScrollView)target; _rectTransform = _scrollView.gameObject.GetComponent <RectTransform>(); InitProperty(); }
public override void init(GameObject obj) { base.init(obj); _scrollView = obj.GetComponent <SScrollView>(); _scrollView.init(); _gridList = new T[_scrollView.gridList.Length]; _gridIndexMap = new SMap <UIObject, int>(); for (int i = 0; i < _gridList.Length; ++i) { UIObject uObj = _gridList[i] = createOne(); uObj.init(_scrollView.gridList[i].gameObject); uObj.name = "g" + i; uObj.setParent(this); uObj.setIsGrid(true); _gridIndexMap[uObj] = i; } _scrollView.setTouchDownAction(onTouchDown); _scrollView.setTouchUpAction(onTouchUp); _scrollView.setTouchCancelAction(onTouchCanceled); _scrollView.setDataAction(onSetDataAction); }
private static void makeOneNode(UIObjectData data, Transform tf) { //先prefab if (PrefabUtility.IsAnyPrefabInstanceRoot(tf.gameObject)) { string prefabPath = PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(tf.gameObject); // Ctrl.print("element",prefabPath); if (_elementDic.contains(prefabPath)) { data.type = UIElementType.Element; data.style = _elementDic.get(prefabPath); if (data.style == null) { data.style = ""; } } else { makeContainer(data, tf); } } else { //控件 if (tf.GetComponent <CanvasRenderer>() != null) { if (tf.GetComponent <SContainer>() != null) { makeContainer(data, tf); } else if (tf.GetComponent <Button>() != null) { data.type = UIElementType.Button; } else if (tf.GetComponent <ImageFrameContainer>() != null) { data.type = UIElementType.ImageFrameContainer; } else if (tf.GetComponent <SScrollViewFake3D>() != null) { data.type = UIElementType.SScrollViewFake3D; SScrollViewFake3D sScrollView = tf.GetComponent <SScrollViewFake3D>(); data.strArgs = new string[1]; data.strArgs[0] = sScrollView.gridElement; } else if (tf.GetComponent <SScrollView>() != null) { data.type = UIElementType.SScrollView; SScrollView sScrollView = tf.GetComponent <SScrollView>(); data.strArgs = new string[1]; data.strArgs[0] = sScrollView.gridElement; } else if (tf.GetComponent <SPageView>() != null) { data.type = UIElementType.SPageView; SPageView sPageView = tf.GetComponent <SPageView>(); data.strArgs = new string[1]; data.strArgs[0] = sPageView.gridElement; } else if (tf.GetComponent <RawImageLoader>() != null) { data.type = UIElementType.RawImageLoader; } else if (tf.GetComponent <RawImage>() != null) { data.type = UIElementType.RawImage; } else if (tf.GetComponent <AdvancedText>() != null) { data.type = UIElementType.TextField; } else if (tf.GetComponent <InputField>() != null) { data.type = UIElementType.InputField; } else if (tf.GetComponent <BloodBar>() != null) { data.type = UIElementType.BloodBar; } else if (tf.GetComponent <Scrollbar>() != null) { data.type = UIElementType.ScrollBar; } else if (tf.GetComponent <Dropdown>() != null) { data.type = UIElementType.Dropdown; } else if (tf.GetComponent <Toggle>() != null) { data.type = UIElementType.Toggle; } else if (tf.GetComponent <Slider>() != null) { data.type = UIElementType.Slider; } else if (tf.GetComponent <ImageLoader>() != null) { data.type = UIElementType.ImageLoader; } else if (tf.GetComponent <Image>() != null) { data.type = UIElementType.Image; } else if (tf.GetComponent <I18NText>() != null) { data.type = UIElementType.I18NText; } else if (tf.GetComponent <Text>() != null) { data.type = UIElementType.Text; } else if (tf.GetComponent <SkeletonGraphicLoader>() != null) { data.type = UIElementType.SkeletonGraphicLoader; } else if (tf.GetComponent <SkeletonGraphic>() != null) { data.type = UIElementType.SkeletonGraphic; } else if (tf.GetComponent <GuideMask>() != null) { data.type = UIElementType.GuideMask; } else //其他脚本 { makeContainer(data, tf); } } else { if (tf.GetComponent <Toggle>() != null) { data.type = UIElementType.Toggle; } else if (tf.GetComponent <Slider>() != null) { data.type = UIElementType.Slider; } else //什么都没有 { makeContainer(data, tf); } } } }