Beispiel #1
0
	private void BindEvent()
	{
		Button[] buttons = new Button[] { buttonA, buttonB, buttonC, buttonD, buttonE };
		for (int i = 0; i < buttons.Length; i++)
		{
			var curButton = buttons[i];
			var index = i;
			Action readAction = () =>
			{
				curButton.transform.Find("Mark").gameObject.SetActive(prefabSelected[index]);
			};
			curButton.onClick.AddListener(() =>
			{
				prefabSelected[index] = !prefabSelected[index];
				readAction();
			});
			readAction();
		}
		buttonAdd.onClick.AddListener(() =>
		{
			foreach (var aName in GetSelectedPrefabNames())
			{
				for (int i = 0; i < GetInputFieldCount(); i++)
				{
					scrollSystem.Add(aName, GenerateSimpleData());
				}
			}
		});
		buttonCheck.onClick.AddListener(() => { Debug.Log(scrollSystem.GetDataCount(GetSelectedPrefabNames().ToArray())); });
		buttonCheckExcept.onClick.AddListener(() => { Debug.Log(scrollSystem.GetDataCountExcept(GetSelectedPrefabNames().ToArray())); });
		buttonAddChat.onClick.AddListener(() =>
		{
			AddChat(inputField_ChatContent.text);
		});

		buttonAddChatJump.onClick.AddListener(() =>
		{
			AddChat(inputField_ChatContent.text);
			scrollSystem.Jump(1);
		});
		buttonDeleteAll.onClick.AddListener(() =>
		{
			createdDatas.Clear();
			scrollSystem.Clear();
		});
		buttonCreateDeleteAndAdd.onClick.AddListener(() =>
		{
			createdDatas.Clear();
			scrollSystem.Clear();
			foreach (var simpleData in deleteAndAddDatas)
			{
				createdDatas.Add(simpleData);
				scrollSystem.Add("D", simpleData);
			}
		});
		buttonJumpWithoutAnimation.onClick.AddListener(() => { scrollSystem.Jump(1, false); });
		buttonReverse.onClick.AddListener(() => { createdDatas.Reverse(); scrollSystem.Reverse(); });
		buttonRemoveFirst.onClick.AddListener(() =>
			{
				if (createdDatas.Count > 0)
				{
					var removedData = createdDatas[0];
					createdDatas.Remove(removedData);
					scrollSystem.Remove(removedData);
				}
			}
		);
		buttonRemoveLast.onClick.AddListener(() =>
			{
				if (createdDatas.Count > 0)
				{
					var removedData = createdDatas[createdDatas.Count - 1];
					createdDatas.Remove(removedData);
					scrollSystem.Remove(removedData);
				}
			}
		);
		ButtonRefresh.onClick.AddListener(() => { scrollSystem.Refresh(); });
		ButtonChangeData.onClick.AddListener(() => { createdDatas.ForEach(temp => { temp.index++; Debug.Log("added to index:" + temp.index); }); });
		buttonJumpData.onClick.AddListener(() =>
		{
			if (int.TryParse(inputField_JumpDataIndex.text, out int result))
			{
				scrollSystem.Jump(result, true);
			}
		});
		buttonLastOne.onClick.AddListener(() =>
		{
			if (int.TryParse(inputField_JumpDataIndex.text, out int result))
			{
				if (result > 0)
				{
					result--;
					inputField_JumpDataIndex.text = result.ToString();
					scrollSystem.Jump(result, true);
				}
			}
		});
		buttonNextOne.onClick.AddListener(() =>
		{
			if (int.TryParse(inputField_JumpDataIndex.text, out int result))
			{
				if (result + 1 < scrollSystem.GetDataCount())
				{
					result++;
					inputField_JumpDataIndex.text = result.ToString();
					scrollSystem.Jump(result, true);
				}
			}
		});
		sliderJumpProgress.onValueChanged.AddListener(progress =>
		{
			textJumpProgress.text = progress.ToString("0.00");
			scrollSystem.Jump(progress);
		});
		buttonJumpBegin.onClick.AddListener(() =>
		{
			scrollSystem.Jump(0, !Input.GetKey(KeyCode.S));
		});
		buttonJumpEnd.onClick.AddListener(() =>
		{
			scrollSystem.Jump(1, !Input.GetKey(KeyCode.S));
		});
		ButtonIsFirstVisible.onClick.AddListener(() =>
		{
			Debug.Log("IsFirstVIsible:"+ scrollSystem.IsFirstVisible().ToString());
		});
		ButtonIsLastVisible.onClick.AddListener(() =>
		{
			Debug.Log("IsLastVIsible:" + scrollSystem.IsLastVisible().ToString());
		});
		ButtonEnableMovement.onClick.AddListener(()=> {
			scrollSystem.EnableMovement();
		});
		ButtonDisableMovement.onClick.AddListener(() => {
			scrollSystem.DisableMovement();
		});
	}