Beispiel #1
0
    /// <summary>
    /// 部件加载时
    /// </summary>
    protected override void OnViewPartLoaded()
    {
        if (GetTransform().GetComponentInParent <Canvas>() != null)
        {
            m_Camera = GetTransform().GetComponentInParent <Canvas>().worldCamera;
        }
        else
        {
            Debug.Log(GetTransform());
        }

        m_Scroller              = FindComponent <UIScrollRect>("Content/Scroller");
        m_ScrollerAnimator      = FindComponent <Animator>("Content/Scroller");
        m_ScrollerController    = m_Scroller.gameObject.GetComponent <UIStickScrollController>();
        m_ScrollerRectTransform = m_Scroller.GetComponent <RectTransform>();

        if (m_ScrollerController == null)
        {
            m_ScrollerController = m_Scroller.gameObject.AddComponent <UIStickScrollController>();
        }

        m_ScrollerController.SetFocused(OwnerView.Focused);

        LeftLabel   = FindComponent <TMP_Text>("Content/Scroller/Label_Tltle1");
        m_SortLabel = FindComponent <TMP_Text>("Content/Scroller/Label_Tltle2");

        if (m_Scroller)
        {
            m_Scroller.DataSorter                = this;
            m_Scroller.OnHeadRenderer            = OnHeadRenderer;
            m_Scroller.OnCellRenderer            = OnCellRenderer;
            m_Scroller.OnCellPlaceholderRenderer = OnCellPlaceholderRenderer;
            m_Scroller.OnNavigateCallback        = OnCellNavigateCallback;
            m_Scroller.OnClickCallback           = OnCellClickCallback;
            m_Scroller.OnDoubleClickCallback     = OnItemDoubleClick;
            m_Scroller.OnOverCallback            = OnCellOverCallback;
            m_Scroller.OnSelectionChanged        = OnSelectionChanged;
            m_Scroller.SetTemplateFactory(null);

            State.OnPageIndexChanged     -= OnPageChanged;
            State.OnPageIndexChanged     += OnPageChanged;
            State.OnSortIndexChanged     -= OnSortChanged;
            State.OnSortIndexChanged     += OnSortChanged;
            State.OnCategoryIndexChanged -= OnFilterChanged;
            State.OnCategoryIndexChanged += OnFilterChanged;

            State.OnLayoutStyleChanged -= OnLayoutStyleChanged;
            State.OnLayoutStyleChanged += OnLayoutStyleChanged;

            State.OnCompareModeChanged -= OnCompareModeChanged;
            State.OnCompareModeChanged += OnCompareModeChanged;

            State.GetAction(UIAction.Common_Sort).Callback -= OnSortKeyPress;
            State.GetAction(UIAction.Common_Sort).Callback += OnSortKeyPress;

            InitializePage();

            OnInputDeviceChanged(InputManager.Instance.CurrentInputDevice);
        }
    }
Beispiel #2
0
    static int ScrollToTop(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1 && TypeChecker.CheckTypes(L, 1, typeof(UIScrollRect)))
            {
                UIScrollRect obj = (UIScrollRect)ToLua.ToObject(L, 1);
                obj.ScrollToTop();
                return(0);
            }
            else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(UIScrollRect), typeof(int)))
            {
                UIScrollRect obj  = (UIScrollRect)ToLua.ToObject(L, 1);
                int          arg0 = (int)LuaDLL.lua_tonumber(L, 2);
                obj.ScrollToTop(arg0);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UIScrollRect.ScrollToTop"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
        public IEnumerator TestOnClickEvent()
        {
            // Create UIScreenSpaceShape
            UIScreenSpace screenSpaceShape =
                TestHelpers.SharedComponentCreate <UIScreenSpace, UIScreenSpace.Model>(scene,
                                                                                       CLASS_ID.UI_SCREEN_SPACE_SHAPE);

            yield return(screenSpaceShape.routine);

            UIScrollRect scrRect =
                TestHelpers.SharedComponentCreate <UIScrollRect, UIScrollRect.Model>(scene, CLASS_ID.UI_SLIDER_SHAPE);

            yield return(scrRect.routine);

            // Force a new update to pass the first apply
            yield return(TestHelpers.SharedComponentUpdate(scrRect, new UIScrollRect.Model
            {
                name = "newName"
            }));

            // Update UIScrollRect properties
            yield return(TestHelpers.SharedComponentUpdate(scrRect,
                                                           new UIScrollRect.Model
            {
                parentComponent = screenSpaceShape.id,
                isPointerBlocker = false,
                width = new UIValue(275f),
                height = new UIValue(130f),
                positionX = new UIValue(-30f),
                positionY = new UIValue(-15f),
                hAlign = "right",
                vAlign = "bottom",
                onClick = "UUIDFakeEventId"
            }));

            //------------------------------------------------------------------------
            // Test click events
            bool eventResult = false;

            yield return(TestHelpers.TestUIClickEventPropagation(
                             scene.sceneData.id,
                             scrRect.model.onClick,
                             scrRect.referencesContainer.childHookRectTransform,
                             (bool res) =>
            {
                // Check image object clicking triggers the correct event
                eventResult = res;
            }));

            Assert.IsTrue(eventResult);

            screenSpaceShape.Dispose();
        }
Beispiel #4
0
 private void InitVariable()
 {
     tipManager         = UiCommon.TipManager;
     groundScrollRect   = FindComponent <UIScrollRect>("GroundScrollView");
     bagScrollRect      = FindComponent <UIScrollRect>("BagScrollView");
     groundItemDataList = new ReactiveListData <IChickenBagItemUiData>();
     bagItemDataList    = new ReactiveListData <IBaseChickenBagItemData>();
     InitTipEvent();
     InitDragBeginEvent();
     InitDragEndEvent();
     bagScrollRect.RegisterListData <IBaseChickenBagItemData, ChickenBagItem>(bagItemDataList);
     groundScrollRect.RegisterListData <IChickenBagItemUiData, ChickenBagItem>(groundItemDataList);
 }
Beispiel #5
0
 static int ResetScroll(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UIScrollRect obj = (UIScrollRect)ToLua.CheckObject(L, 1, typeof(UIScrollRect));
         obj.ResetScroll();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #6
0
 static int IsShowLoading(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UIScrollRect obj = (UIScrollRect)ToLua.CheckObject(L, 1, typeof(UIScrollRect));
         bool         o   = obj.IsShowLoading();
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #7
0
 static int OnEndDrag(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UIScrollRect obj = (UIScrollRect)ToLua.CheckObject(L, 1, typeof(UIScrollRect));
         UnityEngine.EventSystems.PointerEventData arg0 = (UnityEngine.EventSystems.PointerEventData)ToLua.CheckObject(L, 2, typeof(UnityEngine.EventSystems.PointerEventData));
         obj.OnEndDrag(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #8
0
 static int SetContentPosition(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UIScrollRect        obj  = (UIScrollRect)ToLua.CheckObject(L, 1, typeof(UIScrollRect));
         UnityEngine.Vector2 arg0 = ToLua.ToVector2(L, 2);
         obj.SetContentPosition(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #9
0
 static int ShowLoading(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         UIScrollRect obj  = (UIScrollRect)ToLua.CheckObject(L, 1, typeof(UIScrollRect));
         bool         arg0 = LuaDLL.luaL_checkboolean(L, 2);
         float        arg1 = (float)LuaDLL.luaL_checknumber(L, 3);
         obj.ShowLoading(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #10
0
 static int CenterOnItem(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         UIScrollRect           obj    = (UIScrollRect)ToLua.CheckObject(L, 1, typeof(UIScrollRect));
         int                    arg0   = (int)LuaDLL.lua_tonumber(L, 2);
         UnityEngine.GameObject scroll = (UnityEngine.GameObject)ToLua.CheckUnityObject(L, 3, typeof(UnityEngine.GameObject));
         obj.CenterOnItem(arg0, scroll);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #11
0
    static int set_controlID(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIScrollRect obj  = (UIScrollRect)o;
            int          arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
            obj.controlID = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index controlID on a nil value" : e.Message));
        }
    }
Beispiel #12
0
    public void InitDragEvent(LuaFunction startDrag, LuaFunction endDrag)
    {
        if (mScrollRect == null)
        {
            return;
        }

        UIScrollRect sr = mScrollRect as UIScrollRect;

        if (sr == null)
        {
            return;
        }

        sr.LuaOnBeginDrag = startDrag;
        sr.LuaOnEndDrag   = endDrag;
    }
Beispiel #13
0
    static int set_enableDrag(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIScrollRect obj  = (UIScrollRect)o;
            bool         arg0 = LuaDLL.luaL_checkboolean(L, 2);
            obj.enableDrag = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index enableDrag on a nil value" : e.Message));
        }
    }
Beispiel #14
0
    static int get_uiMod(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIScrollRect obj = (UIScrollRect)o;
            UIMod        ret = obj.uiMod;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index uiMod on a nil value" : e.Message));
        }
    }
Beispiel #15
0
    static int get_enableDrag(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIScrollRect obj = (UIScrollRect)o;
            bool         ret = obj.enableDrag;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index enableDrag on a nil value" : e.Message));
        }
    }
Beispiel #16
0
    static int get_controlID(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIScrollRect obj = (UIScrollRect)o;
            int          ret = obj.controlID;
            LuaDLL.lua_pushinteger(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index controlID on a nil value" : e.Message));
        }
    }
Beispiel #17
0
    static int set_uiMod(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIScrollRect obj  = (UIScrollRect)o;
            UIMod        arg0 = (UIMod)ToLua.CheckUnityObject(L, 2, typeof(UIMod));
            obj.uiMod = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index uiMod on a nil value" : e.Message));
        }
    }
Beispiel #18
0
    /// <summary>
    /// 部件卸载时
    /// </summary>
    protected override void OnViewPartUnload()
    {
        State.OnPageIndexChanged     -= OnPageChanged;
        State.OnSortIndexChanged     -= OnSortChanged;
        State.OnCategoryIndexChanged -= OnFilterChanged;

        State.OnLayoutStyleChanged -= OnLayoutStyleChanged;
        State.OnCompareModeChanged -= OnCompareModeChanged;

        State.GetAction(UIAction.Common_Sort).Callback      -= OnSortKeyPress;
        State.GetAction(UIAction.Common_Grid_List).Callback -= OnToggleGridLayout;

        OwnerView.DeleteHotKey("LayoutMode");
        OwnerView.DeleteHotKey("CompareMode");

        m_Camera = null;

        if (m_Scroller)
        {
            m_Scroller.vertical = true;
            m_Scroller.ClearData();
            m_Scroller.DataSorter                = null;
            m_Scroller.OnHeadRenderer            = null;
            m_Scroller.OnCellRenderer            = null;
            m_Scroller.OnCellPlaceholderRenderer = null;
            m_Scroller.OnNavigateCallback        = null;
            m_Scroller.OnClickCallback           = null;
            m_Scroller.OnDoubleClickCallback     = null;
            m_Scroller.OnSelectionChanged       -= null;
            m_Scroller.SetTemplateFactory(null);
            m_Scroller = null;
        }

        if (m_ScrollerController)
        {
            m_ScrollerController.SetFocused(false);
            m_ScrollerController = null;
        }

        m_ScrollerAnimator      = null;
        m_ScrollerRectTransform = null;

        LeftLabel   = null;
        m_SortLabel = null;
    }
Beispiel #19
0
        private void InitVariable()
        {
            if (UIImageLoader.LoadSpriteAsync == null)
            {
                UIImageLoader.LoadSpriteAsync = Loader.RetriveSpriteAsync;
            }

            tipManager         = UiCommon.TipManager;
            groundScrollRect   = FindComponent <UIScrollRect>("GroundScrollView");
            bagScrollRect      = FindComponent <UIScrollRect>("BagScrollView");
            groundItemDataList = new ReactiveListData <IChickenBagItemUiData>();
            bagItemDataList    = new ReactiveListData <IBaseChickenBagItemData>();
            InitTipEvent();
            InitDragBeginEvent();
            InitDragEndEvent();
            bagScrollRect.RegisterListData <IBaseChickenBagItemData, ChickenBagItem>(bagItemDataList);
            groundScrollRect.RegisterListData <IChickenBagItemUiData, ChickenBagItem>(groundItemDataList);
        }
Beispiel #20
0
    public override void OnInspectorGUI()
    {
        scr = target as UIScrollRect;
        int controlID = EditorGUILayout.IntField("ControlID", scr.controlID);

        if (scr.controlID != controlID)
        {
            scr.controlID = controlID;
        }
        UIMod uis = EditorGUILayout.ObjectField("UIMod", scr.uiMod, typeof(UIMod), true) as UIMod;

        if (scr.uiMod != uis)
        {
            scr.uiMod = uis;
        }
        scr.enableOnDragEvent = EditorGUILayout.Toggle("enableOnDragEvent", scr.enableOnDragEvent);
        base.OnInspectorGUI();
    }
Beispiel #21
0
    private void OnEnable()
    {
        if (scroller == null)
        {
            scroller = GetComponent <UIScrollRect>();
        }

        ClearList();

        Dictionary <string, Save> saves = SaveManager.Instance.Saves;

        foreach (KeyValuePair <string, Save> kvp in saves)
        {
            CreateButton(kvp.Key, kvp.Value);
        }


        selectedSaveHandler.SetSave("");
    }
    protected override void OnViewPartLoaded()
    {
        base.OnViewPartLoaded();
        List <object> list = new List <object> {
            1
        };

        OwnerView.PageBox.gameObject.SetActive(false);
        SetSortEnabled(false);
        ClearData();
        AddDatas(null, list);
        m_TextsScrollRect = FindComponent <UIScrollRect>(OwnerView.ListBox.GetChild(0), "Content/Scroller");
        m_ContentRoot     = FindComponent <Transform>(OwnerView.ListBox.GetChild(0), "Content/Scroller/Viewport/Content");
        m_TextsScrollRect.verticalScrollbar.onValueChanged.AddListener((value) =>
        {
            if (value < 0.02f || value > 1)
            {
                State.GetAction(UIAction.Agreement_Agree).Enabled = true;
            }
        });
    }
    protected override void OnViewPartLoaded()
    {
        base.OnViewPartLoaded();
        ShowCharacter();
        OwnerView.PageBox.gameObject.SetActive(false);

        m_UIScrollRect = FindComponent <UIScrollRect>("Content/Scroller");
        ProduceDialogBasePanel produceDialogBasePanel = OwnerView as ProduceDialogBasePanel;

        if (produceDialogBasePanel.CloseByEsc)
        {
            //State.GetPage(0).ListSelection = new Vector2Int(0, 0);
            m_UIScrollRect.SetSelection(new Vector2Int(0, 0));
            produceDialogBasePanel.CloseByEsc = false;
        }
        switch (produceDialogBasePanel.CurrentProduceType)
        {
        case ProduceType.HeavyWeapon:
        case ProduceType.Reformer:
        case ProduceType.Device:
        case ProduceType.Ship:
            m_UIScrollRect.CellListPadding = new RectOffset(0,
                                                            m_UIScrollRect.CellListPadding.right,
                                                            m_UIScrollRect.CellListPadding.top,
                                                            m_UIScrollRect.CellListPadding.bottom);
            break;

        case ProduceType.Chip:
            m_UIScrollRect.CellListPadding = new RectOffset(170,
                                                            m_UIScrollRect.CellListPadding.right,
                                                            m_UIScrollRect.CellListPadding.top,
                                                            m_UIScrollRect.CellListPadding.bottom);
            break;

        default:
            break;
        }
    }
Beispiel #24
0
        public BaseDisposable SharedComponentCreate(string id, string name, int classId)
        {
            SceneController.i.OnMessageDecodeStart?.Invoke("ComponentCreated");
            sharedComponentCreatedMessage.id      = id;
            sharedComponentCreatedMessage.name    = name;
            sharedComponentCreatedMessage.classId = classId;
            SceneController.i.OnMessageDecodeEnds?.Invoke("ComponentCreated");

            BaseDisposable disposableComponent;

            if (disposableComponents.TryGetValue(sharedComponentCreatedMessage.id, out disposableComponent))
            {
                return(disposableComponent);
            }

            BaseDisposable newComponent = null;

            switch ((CLASS_ID)sharedComponentCreatedMessage.classId)
            {
            case CLASS_ID.BOX_SHAPE:
            {
                newComponent = new BoxShape(this);
                break;
            }

            case CLASS_ID.SPHERE_SHAPE:
            {
                newComponent = new SphereShape(this);
                break;
            }

            case CLASS_ID.CONE_SHAPE:
            {
                newComponent = new ConeShape(this);
                break;
            }

            case CLASS_ID.CYLINDER_SHAPE:
            {
                newComponent = new CylinderShape(this);
                break;
            }

            case CLASS_ID.PLANE_SHAPE:
            {
                newComponent = new PlaneShape(this);
                break;
            }

            case CLASS_ID.GLTF_SHAPE:
            {
                newComponent = new GLTFShape(this);
                break;
            }

            case CLASS_ID.NFT_SHAPE:
            {
                newComponent = new NFTShape(this);
                break;
            }

            case CLASS_ID.OBJ_SHAPE:
            {
                newComponent = new OBJShape(this);
                break;
            }

            case CLASS_ID.BASIC_MATERIAL:
            {
                newComponent = new BasicMaterial(this);
                break;
            }

            case CLASS_ID.PBR_MATERIAL:
            {
                newComponent = new PBRMaterial(this);
                break;
            }

            case CLASS_ID.AUDIO_CLIP:
            {
                newComponent = new DCLAudioClip(this);
                break;
            }

            case CLASS_ID.TEXTURE:
            {
                newComponent = new DCLTexture(this);
                break;
            }

            case CLASS_ID.UI_INPUT_TEXT_SHAPE:
            {
                newComponent = new UIInputText(this);
                break;
            }

            case CLASS_ID.UI_FULLSCREEN_SHAPE:
            case CLASS_ID.UI_SCREEN_SPACE_SHAPE:
            {
                if (uiScreenSpace == null)
                {
                    newComponent = new UIScreenSpace(this);
                }

                break;
            }

            case CLASS_ID.UI_CONTAINER_RECT:
            {
                newComponent = new UIContainerRect(this);
                break;
            }

            case CLASS_ID.UI_SLIDER_SHAPE:
            {
                newComponent = new UIScrollRect(this);
                break;
            }

            case CLASS_ID.UI_CONTAINER_STACK:
            {
                newComponent = new UIContainerStack(this);
                break;
            }

            case CLASS_ID.UI_IMAGE_SHAPE:
            {
                newComponent = new UIImage(this);
                break;
            }

            case CLASS_ID.UI_TEXT_SHAPE:
            {
                newComponent = new UIText(this);
                break;
            }

            case CLASS_ID.VIDEO_CLIP:
            {
                newComponent = new DCLVideoClip(this);
                break;
            }

            case CLASS_ID.VIDEO_TEXTURE:
            {
                newComponent = new DCLVideoTexture(this);
                break;
            }

            case CLASS_ID.FONT:
            {
                newComponent = new DCLFont(this);
                break;
            }

            default:
                Debug.LogError($"Unknown classId");
                break;
            }

            if (newComponent != null)
            {
                newComponent.id = sharedComponentCreatedMessage.id;
                disposableComponents.Add(sharedComponentCreatedMessage.id, newComponent);

                if (state != State.READY)
                {
                    disposableNotReady.Add(id);
                }
            }

            return(newComponent);
        }
Beispiel #25
0
        public BaseDisposable SharedComponentCreate(string id, int classId)
        {
            BaseDisposable disposableComponent;

            if (disposableComponents.TryGetValue(id, out disposableComponent))
            {
                return(disposableComponent);
            }

            BaseDisposable newComponent = null;

            switch ((CLASS_ID)classId)
            {
            case CLASS_ID.BOX_SHAPE:
            {
                newComponent = new BoxShape(this);
                break;
            }

            case CLASS_ID.SPHERE_SHAPE:
            {
                newComponent = new SphereShape(this);
                break;
            }

            case CLASS_ID.CONE_SHAPE:
            {
                newComponent = new ConeShape(this);
                break;
            }

            case CLASS_ID.CYLINDER_SHAPE:
            {
                newComponent = new CylinderShape(this);
                break;
            }

            case CLASS_ID.PLANE_SHAPE:
            {
                newComponent = new PlaneShape(this);
                break;
            }

            case CLASS_ID.GLTF_SHAPE:
            {
                newComponent = new GLTFShape(this);
                break;
            }

            case CLASS_ID.NFT_SHAPE:
            {
                newComponent = new NFTShape(this);
                break;
            }

            case CLASS_ID.OBJ_SHAPE:
            {
                newComponent = new OBJShape(this);
                break;
            }

            case CLASS_ID.BASIC_MATERIAL:
            {
                newComponent = new BasicMaterial(this);
                break;
            }

            case CLASS_ID.PBR_MATERIAL:
            {
                newComponent = new PBRMaterial(this);
                break;
            }

            case CLASS_ID.AUDIO_CLIP:
            {
                newComponent = new DCLAudioClip(this);
                break;
            }

            case CLASS_ID.TEXTURE:
            {
                newComponent = new DCLTexture(this);
                break;
            }

            case CLASS_ID.UI_INPUT_TEXT_SHAPE:
            {
                newComponent = new UIInputText(this);
                break;
            }

            case CLASS_ID.UI_FULLSCREEN_SHAPE:
            case CLASS_ID.UI_SCREEN_SPACE_SHAPE:
            {
                if (GetSharedComponent <UIScreenSpace>() == null)
                {
                    newComponent = new UIScreenSpace(this);
                }

                break;
            }

            case CLASS_ID.UI_CONTAINER_RECT:
            {
                newComponent = new UIContainerRect(this);
                break;
            }

            case CLASS_ID.UI_SLIDER_SHAPE:
            {
                newComponent = new UIScrollRect(this);
                break;
            }

            case CLASS_ID.UI_CONTAINER_STACK:
            {
                newComponent = new UIContainerStack(this);
                break;
            }

            case CLASS_ID.UI_IMAGE_SHAPE:
            {
                newComponent = new UIImage(this);
                break;
            }

            case CLASS_ID.UI_TEXT_SHAPE:
            {
                newComponent = new UIText(this);
                break;
            }

            case CLASS_ID.VIDEO_CLIP:
            {
                newComponent = new DCLVideoClip(this);
                break;
            }

            case CLASS_ID.VIDEO_TEXTURE:
            {
                newComponent = new DCLVideoTexture(this);
                break;
            }

            case CLASS_ID.FONT:
            {
                newComponent = new DCLFont(this);
                break;
            }

            case CLASS_ID.NAME:
            {
                newComponent = new DCLName(this);
                break;
            }

            case CLASS_ID.LOCKED_ON_EDIT:
            {
                newComponent = new DCLLockedOnEdit(this);
                break;
            }

            case CLASS_ID.VISIBLE_ON_EDIT:
            {
                newComponent = new DCLVisibleOnEdit(this);
                break;
            }

            default:
                Debug.LogError($"Unknown classId");
                break;
            }

            if (newComponent != null)
            {
                newComponent.id = id;
                disposableComponents.Add(id, newComponent);
                OnAddSharedComponent?.Invoke(id, newComponent);
            }

            return(newComponent);
        }
Beispiel #26
0
 void Awake()
 {
     srect = GetComponent <UIScrollRect>();
     ListPageValueInit();
 }
        public IEnumerator TestPropertiesAreAppliedCorrectly()
        {
            // Create UIScreenSpaceShape
            UIScreenSpace screenSpaceShape =
                TestHelpers.SharedComponentCreate <UIScreenSpace, UIScreenSpace.Model>(scene,
                                                                                       CLASS_ID.UI_SCREEN_SPACE_SHAPE);

            yield return(screenSpaceShape.routine);

            UIScrollRect scrRect =
                TestHelpers.SharedComponentCreate <UIScrollRect, UIScrollRect.Model>(scene, CLASS_ID.UI_SLIDER_SHAPE);

            yield return(scrRect.routine);

            // Force a new update to pass the first apply
            yield return(TestHelpers.SharedComponentUpdate(scrRect, new UIScrollRect.Model
            {
                name = "newName"
            }));

            var refC = scrRect.referencesContainer;

            Assert.IsTrue(refC.canvasGroup.blocksRaycasts);
            //Canvas group is disabled on first apply
            Assert.AreEqual(1, refC.canvasGroup.alpha);

            // Apply padding
            Assert.AreEqual(0, refC.paddingLayoutGroup.padding.bottom);
            Assert.AreEqual(0, refC.paddingLayoutGroup.padding.top);
            Assert.AreEqual(0, refC.paddingLayoutGroup.padding.left);
            Assert.AreEqual(0, refC.paddingLayoutGroup.padding.right);

            Assert.IsFalse(refC.scrollRect.horizontal);
            Assert.IsTrue(refC.scrollRect.vertical);

            Assert.AreEqual(0, refC.HScrollbar.value);
            Assert.AreEqual(0, refC.VScrollbar.value);

            // Update UIScrollRect properties
            yield return(TestHelpers.SharedComponentUpdate(scrRect,
                                                           new UIScrollRect.Model
            {
                parentComponent = screenSpaceShape.id,
                isPointerBlocker = false,
                width = new UIValue(275f),
                height = new UIValue(130f),
                positionX = new UIValue(-30f),
                positionY = new UIValue(-15f),
                hAlign = "right",
                vAlign = "bottom"
            }));

            // Check updated properties are applied correctly
            Assert.IsTrue(scrRect.referencesContainer.transform.parent == screenSpaceShape.childHookRectTransform);
            Assert.IsFalse(scrRect.referencesContainer.canvasGroup.blocksRaycasts);
            Assert.AreEqual(275f, scrRect.childHookRectTransform.rect.width);
            Assert.AreEqual(130f, scrRect.childHookRectTransform.rect.height);
            Assert.IsTrue(scrRect.referencesContainer.layoutGroup.childAlignment == TextAnchor.LowerRight);

            Vector2 alignedPosition = CalculateAlignedAnchoredPosition(screenSpaceShape.childHookRectTransform.rect,
                                                                       scrRect.childHookRectTransform.rect, "bottom", "right");

            alignedPosition += new Vector2(-30, -15); // apply offset position

            Assert.AreEqual(alignedPosition.ToString(),
                            scrRect.referencesContainer.layoutElementRT.anchoredPosition.ToString());

            screenSpaceShape.Dispose();
        }
Beispiel #28
0
    protected override void OnViewPartLoaded()
    {
        base.OnViewPartLoaded();
        m_UIScrollRect = FindComponent <UIScrollRect>("Content/Scroller");
        m_UIScrollRect.SetSelection(new Vector2Int(0, 0));
        ClearData();
        m_Items = new List <ItemBase>();
        switch (Parent.Data.State)
        {
        case WarshipPanelState.ListWeapon:
            m_Category        = Category.Weapon;
            m_CurrentItemData = Parent.Data.CurrentWeaponData.Data;
            m_ContainerUID    = Parent.Data.CurrentWeaponData.ContainerUID;
            m_ContainerPOS    = Parent.Data.CurrentWeaponData.ContainerPOS;
            break;

        case WarshipPanelState.ListReformer:
            m_Category        = Category.Reformer;
            m_CurrentItemData = Parent.Data.CurrentReformerData.Data;
            m_ContainerUID    = Parent.Data.CurrentReformerData.ContainerUID;
            m_ContainerPOS    = Parent.Data.CurrentReformerData.ContainerPOS;
            break;

        case WarshipPanelState.ListEquip:
            m_Category        = Category.Equipment;
            m_CurrentItemData = Parent.Data.CurrentEquipmentData.Data;
            m_ContainerUID    = Parent.Data.CurrentEquipmentData.ContainerUID;
            m_ContainerPOS    = Parent.Data.CurrentEquipmentData.ContainerPOS;
            break;

        case WarshipPanelState.ListMod:
            m_Category                  = Category.EquipmentMod;
            m_CurrentWeapon             = Parent.Data.CurrentWeaponData.Data;
            m_CurrentWeaponContainerUID = Parent.Data.CurrentWeaponData.ContainerUID;
            m_CurrentWeaponContainerPOS = Parent.Data.CurrentWeaponData.ContainerPOS;
            m_CurrentItemData           = Parent.Data.CurrentModData.Data;
            m_ContainerUID              = Parent.Data.CurrentModData.ContainerUID;
            m_ContainerPOS              = Parent.Data.CurrentModData.ContainerPOS;
            if (Parent.Data.BeforeState == WarshipPanelState.ModMainShip)
            {
                SendViewerChange(Parent.Data.CurrentShip.GetTID(), true);
            }
            else
            {
                SendViewerChange(m_CurrentWeapon.GetTID(), false);
            }
            break;
        }

        m_ItemsDic = PackageProxy.GetPackage(m_Category).Items;
        if (m_ItemsDic != null && m_ItemsDic.Count > 0)
        {
            foreach (var item in m_ItemsDic)
            {
                switch (m_Category)
                {
                case Category.Weapon when m_ContainerPOS == 0 && Parent.Data.CurrentShip.GetWarShipType() == WarshipL1.FightWarship && (item.Value as ItemWeaponVO).WeaponType1 == WeaponL1.Fighting:
                case Category.Weapon when m_ContainerPOS == 0 && Parent.Data.CurrentShip.GetWarShipType() == WarshipL1.MiningShip && (item.Value as ItemWeaponVO).WeaponType1 == WeaponL1.Mining:
                case Category.Weapon when m_ContainerPOS == 0 && Parent.Data.CurrentShip.GetWarShipType() == WarshipL1.SurveillanceShip && (item.Value as ItemWeaponVO).WeaponType1 == WeaponL1.Treasure:
                case Category.Weapon when m_ContainerPOS != 0 && (item.Value as ItemWeaponVO).WeaponType1 == WeaponL1.Fighting:
                case Category.Reformer:
                case Category.Equipment when(item.Value as ItemEquipmentVO).EquipmentType == (EquipmentL1)(m_ContainerPOS + 1):
                case Category.EquipmentMod when(item.Value as ItemModVO).ModType1 == Parent.Data.CurrentModData.ModType1 && (item.Value as ItemModVO).ModType2 == Parent.Data.CurrentModData.ModType2:
                    m_Items.Add(item.Value);

                    break;
                }
            }
        }
        AddDatas(null, m_Items.ToArray());
        ShowCharacter();
    }
Beispiel #29
0
 public void Awake()
 {
     mScrollRect      = GetComponent <UIScrollRect>();
     mScrollRectTrans = mScrollRect.GetComponent <RectTransform>();
     mScrollRect.onValueChanged.AddListener(ValueChanged);
 }