-
카테고리
-
세부 분야
게임 프로그래밍
-
해결 여부
미해결
저도 마지막 점수 올리기 부분에서 막혀서 질문 드립니다
21.07.25 19:19 작성 조회수 186
0
Button을 눌러도 아무런 일이 일어나지 않네요.
PointButton에 On Click()에 UI_Button을 넣었다 없앴다가 했는데 On Click()시에 할 수 있는 Function도 없네요.
뭐가 문제일까요?
다른 분이 질문하신 것 읽어봤는데 -=, += 순서는 올바르게 했더라구요
아래는 제 UI_Button.cs 입니다.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI; public class UI_Button : UI_Base
{
enum Buttons { PointButton }
enum Texts { PointText, ScoreText }
enum GameObjects { TestObject, }
enum Images { Itemicon, }
private void Start()
{ Bind<Button>
(typeof(Buttons));
Bind<Text>(typeof(Texts));
Bind<GameObject>(typeof(GameObjects));
Bind<Image>(typeof(Images));
GetButton((int)Buttons.PointButton).gameObject.AddUIEvent(OnButtonClicked);
GameObject go =Getimage((int)Images.Itemicon).gameObject; AddUIEvent(go, (PointerEventData data) => { go.transform.position = data.position; }, Define.UIEvent.Drag); }
int _score = 0;
public void OnButtonClicked(PointerEventData data) { _score ++; Debug.Log($"{_score}"); GetText((int)Texts.ScoreText).text = $"점수 : {_score}"; } }
답변을 작성해보세요.
2
0
Rookiss
지식공유자2021.07.25
크래시는 나지 않고 단순히 반응이 없는 문제일까요?
UI를 만들 때 버튼 앞에 있던 다른 애가 클릭 이벤트를 먹어버린 경우도 있고,
코드 문제일 수도 있고 굉장히 다양한 가능성이 있어서
사실 위 내용만으로는 알 수 없습니다.
그리고 유니티 툴 상에서 OnClick에 드래그 드롭으로 연결할게 없는건 정상적인 상황입니다.
(PointerEventData 가 추가된 버전으로 고쳤기 때문)
코드나 UI_Button 프리팹을 다시 확인해보시고
문제 해결이 안되거든 rookiss@naver.com 로 전체 프로젝트 압축해서 보내주시기 바랍니다.
답변 2