protected override void InitDrawer() { _Drawer.Init(_Adapters, false, false, false, false, false, false); _Drawer.galleryEffectSetting.slider.value = 0f; _Drawer.galleryEffectSetting.gameObject.SetActive(false); //_Drawer.scrollToPanel.gameObject.SetActive(false); // scrollTo is not accurate for this kind of layout yet, because only scrolling to a group index is possible var bigChildrenFirstTogglePanel = _Drawer.AddLabelWithTogglePanel("Big children first"); bigChildrenFirstTogglePanel.transform.SetAsFirstSibling(); bigChildrenFirstTogglePanel.toggle.isOn = _Adapters[0].Parameters.biggerChildrenFirst; bigChildrenFirstTogglePanel.toggle.onValueChanged.AddListener(isOn => { if (_Adapters != null && _Adapters.Length > 0 && _Adapters[0] != null && _Adapters[0].IsInitialized) { var adapter = _Adapters[0]; if (adapter.Parameters.biggerChildrenFirst != isOn) { // Just a hack to force an entire refresh of the adapter, as if it was first initialized. // This is needed because the "biggerChildrenFirst" property is read only at initialization, but we want to force // its value to be read & the entire view updated at each press of this toggle adapter.Parameters.biggerChildrenFirst = isOn; ForceReinitializeKeepingModels(adapter); } } }); var cellGroupAutoSizePanel = _Drawer.AddLabelWithTogglePanel("Auto cell group size"); var cellGroupSizePanel = _Drawer.AddLabelWithSliderPanel(""); cellGroupSizePanel.slider.wholeNumbers = true; cellGroupAutoSizePanel.toggle.onValueChanged.AddListener(isOn => { if (isOn) { cellGroupSizePanel.Set(1, OSAConst.MAX_CELLS_PER_GROUP_FACTOR_WHEN_INFERRING, -1); cellGroupSizePanel.Init("Group size (multiplier)", "1", OSAConst.MAX_CELLS_PER_GROUP_FACTOR_WHEN_INFERRING + ""); } else { cellGroupSizePanel.Init("Group size (exact)", "1", "60"); cellGroupSizePanel.Set(1, 60, 60); } cellGroupSizePanel.slider.onValueChanged.Invoke(cellGroupSizePanel.slider.value); }); cellGroupSizePanel.slider.onValueChanged.AddListener(value => { if (_Adapters != null && _Adapters.Length > 0 && _Adapters[0] != null && _Adapters[0].IsInitialized) { var adapter = _Adapters[0]; if (adapter.Parameters.Grid.MaxCellsPerGroup != value) { if (cellGroupAutoSizePanel.toggle.isOn) { value = -value; } adapter.Parameters.Grid.MaxCellsPerGroup = UnityEngine.Mathf.RoundToInt(value); ForceReinitializeKeepingModels(adapter); } } }); cellGroupAutoSizePanel.toggle.isOn = _Adapters[0].Parameters.Grid.MaxCellsPerGroup < 0; cellGroupAutoSizePanel.toggle.onValueChanged.Invoke(cellGroupAutoSizePanel.toggle.isOn); _CellTypesPanel = _Drawer.AddLabelWithSliderPanel("Cell types", "1", "5"); _CellTypesPanel.slider.wholeNumbers = true; _CellTypesPanel.Set(1, 5, 3); _RandomAspectRatiosTogglePanel = _Drawer.AddLabelWithTogglePanel("Random aspect ratios"); _RandomAspectRatiosTogglePanel.toggle.isOn = false; cellGroupAutoSizePanel.transform.SetSiblingIndex(1); cellGroupSizePanel.transform.SetSiblingIndex(2); _CellTypesPanel.transform.SetSiblingIndex(3); _RandomAspectRatiosTogglePanel.transform.SetSiblingIndex(4); }
public void Init( IOSA[] adapters, bool addGravityCommand = true, bool addItemEdgeFreezeCommand = true, bool addContentEdgeFreezeCommand = true, bool addServerDelaySetting = true, bool addOneItemAddRemovePanel = true, bool addInsertRemoveAtIndexPanel = true ) { _Adapters = adapters; scrollToPanel.mainSubPanel.button.onClick.AddListener(RequestSmoothScrollToSpecified); setCountPanel.button.onClick.AddListener(RequestChangeItemCountToSpecifiedIgnoringServerDelay); if (addGravityCommand) { contentGravityPanel = AddLabelWithTogglesPanel("Gravity when content smaller than viewport", "Start", "Center", "End"); contentGravityPanel.ToggleChanged += (toggleIdx, isOn) => { if (!isOn) { return; } DoForAllAdapters((adapter) => { if (adapter.IsInitialized) { adapter.BaseParameters.Gravity = (BaseParams.ContentGravity)(toggleIdx + 1); adapter.BaseParameters.UpdateContentPivotFromGravityType(); //adapter.SetVirtualAbstractNormalizedScrollPosition(1d, true); // scrollto start } }); }; } if (addItemEdgeFreezeCommand) { freezeItemEndEdgeToggle = AddLabelWithTogglePanel("Freeze item end edge when expanding/collapsing").toggle; } if (addContentEdgeFreezeCommand) { freezeContentEndEdgeToggle = AddLabelWithTogglePanel("Freeze content end edge on add/remove/resize").toggle; } if (addServerDelaySetting) { serverDelaySetting = AddLabelWithInputPanel("Server simulated delay:"); serverDelaySetting.inputField.text = 1 + ""; // 1 second, initially serverDelaySetting.inputField.keyboardType = TouchScreenKeyboardType.NumberPad; serverDelaySetting.inputField.characterLimit = 1; } if (addOneItemAddRemovePanel) { addRemoveOnePanel = AddButtonsWithOptionalInputPanel("+1 tail", "+1 head", "-1 tail", "-1 head"); addRemoveOnePanel.transform.SetSiblingIndex(1); addRemoveOnePanel.button1.onClick.AddListener(() => { AddItemWithChecks(true); }); addRemoveOnePanel.button2.onClick.AddListener(() => { AddItemWithChecks(false); }); addRemoveOnePanel.button3.onClick.AddListener(() => { RemoveItemWithChecks(true); }); addRemoveOnePanel.button4.onClick.AddListener(() => { RemoveItemWithChecks(false); }); } if (addInsertRemoveAtIndexPanel) { addRemoveOneAtIndexPanel = AddButtonsWithOptionalInputPanel("+1 at", "-1 at", "", "", "index"); addRemoveOneAtIndexPanel.transform.SetSiblingIndex(1); addRemoveOneAtIndexPanel.button1.onClick.AddListener(() => AddItemWithChecks(addRemoveOneAtIndexPanel.InputFieldValueAsInt)); addRemoveOneAtIndexPanel.button2.onClick.AddListener(() => RemoveItemWithChecks(addRemoveOneAtIndexPanel.InputFieldValueAsInt)); } galleryEffectSetting = AddLabelWithSliderPanel("Gallery effect", "None", "Max"); galleryEffectSetting.slider.onValueChanged.AddListener((v) => DoForAllAdapters((adapter) => { var gal = adapter.BaseParameters.effects.Gallery; //gal.OverallAmount = gal.Scale.Amount = gal.Rotation.Amount = v; gal.OverallAmount = v; }) ); galleryEffectSetting.Set(0f, 1f, .1f); // Simulate low end device toggle int vSyncCountBefore = QualitySettings.vSyncCount; int targetFrameRateBefore = Application.targetFrameRate; forceLowFPSSetting = AddLabelWithTogglePanel("Force low FPS"); forceLowFPSSetting.transform.SetAsLastSibling(); forceLowFPSSetting.toggle.onValueChanged.AddListener(isOn => { if (isOn) { vSyncCountBefore = QualitySettings.vSyncCount; targetFrameRateBefore = Application.targetFrameRate; QualitySettings.vSyncCount = 0; // VSync must be disabled for Application.targetFrameRate to work Application.targetFrameRate = TARGET_FRAMERATE_FOR_SIMULATING_SLOW_DEVICES; } else { if (QualitySettings.vSyncCount == 0) // if it wasn't modified since the last time we modified it (i.e. if it was modified externally, don't override that value) { QualitySettings.vSyncCount = vSyncCountBefore; } if (Application.targetFrameRate == TARGET_FRAMERATE_FOR_SIMULATING_SLOW_DEVICES) // item comment as above { Application.targetFrameRate = targetFrameRateBefore; } } }); }