Unity 설정팝업 구현

#1.버튼 구조=>SettingMain->UISettingDirector->UIsettingButtons

#2. 버튼 구현

*onclick 이벤트 발생시 디버그 타입 (타입은 열거형으로 정의)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class UISettingButtons : MonoBehaviour
{
    public enum eSettingButtonType
    {
        Languge,
        ID,
        Like,
        Rate,
        About,
        OtherGame,
        DeleteAcoount,
        ConnectFacebook,
        ConnectGameCneter,
        Logout
    }
    public Button() arrBtns;
    public System.Action<eSettingButtonType> onClick;
    void Start()
    {
        for(int i=0; i<arrBtns.Length; i++) //enum으로 정의해논 type 할당
        {
            int idx = i; //변수캡쳐 사용(event)
            this.arrBtns(idx).onClick.AddListener(() => {
                Debug.Log("Click");
                this.onClick((eSettingButtonType)idx);
            });
            

        }
    }

}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UISettingDirector : MonoBehaviour
{
    public UISettingButtons UISettingButtons;
    void Start()
    {
        this.UISettingButtons.onClick = (x) =>
        {
            Debug.Log(x);
        };
    }

}

#2.슬라이드 구조=>SettingMain->UISettingDirector->UIList

#슬라이드 구현(onValueChanged를 사용하여 값 출력, 최대=10)

#text type value,maxValue는 현재 값과 최대값 maxValue를 표시합니다.

# 게임이 시작되면 Init 메소드를 통해 값을 0으로 초기화합니다.

using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using TMPro;
using UnityEngine;
using UnityEngine.UI;


public class UISettingList : MonoBehaviour
{
    //slider
    //soundFx
    public Slider soundFxSlider;
    public TMP_Text soundFxTxtValue;
    public Image iconSoundFx;
    //music
    public Slider musicSlider;
    public TMP_Text musicTxtValue;
    public Image iconMusic;
    public System.Action<float> onValueChanged;

    public void Init(int val)
    {
        this.soundFxSlider.value = val;
        this.musicSlider.value = val;
    }
    void Start()
    {
        //Slider(soundFx,Music)
        //color
        string onColor = "#FAB037";
        string offColor = "#76617D";
        //Color color1;
        //Color color1;
        //if (ColorUtility.TryParseHtmlString(onColor, out color1))
        //{
        //    this.iconSoundFx.color = color1;
        //}


        this.soundFxSlider.onValueChanged.AddListener((val) => {
            Debug.Log(val);
            this.soundFxTxtValue.text = string.Format("{0}",(int)val);
            if(val>0)
            {
                this.iconSoundFx.gameObject.SetActive(true);
                //this.iconSoundFx.color=Color.red;
            }
            else
            {
                this.iconSoundFx.gameObject.SetActive(false);
                
                
            }
        });
        this.musicSlider.onValueChanged.AddListener((val) => { 
            Debug.Log(val);
            this.musicTxtValue.text=string.Format("{0}",(int)val);
            if(val>0)
            {
                this.iconMusic.gameObject.SetActive(true);  
            }
            else
            {
                this.iconMusic.gameObject.SetActive(false);
            }
        });


        //switch(Alram,Vibration)
    }

}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UISettingDirector : MonoBehaviour
{
    public UISettingButtons uiSettingButtons;
    public UISettingList uiSettingList;
    void Start()
    {
        this.uiSettingButtons.onClick = (x) =>
        {
            Debug.Log(x);
        };
        this.uiSettingList.Init(0); //vale=0
    }

}

#아이콘 활성화/비활성화는 되었지만 색상으로 표현하고 싶습니다.

#활성 색상은 string onColor = “#FAB037″입니다./ 비활성 this.musicSlider.value = val;

#Color is an ambiguous reference 오류로 구현 실패, API를 더 참조해야 합니다.

Similar Posts

  • 폐렴 관리 방법 저는 이렇게 했어요.

    #폐렴 관리 방법 호흡기 질환 중 악성 종양 다음으로 사망률이 높은 질병이 폐에 생기는 염증이라고 합니다.감기와 초기 증상이 비슷하기 때문에 방치하거나 엉뚱한 조치를 취한 뒤 뒤늦게 발견했다가 합병증에 걸린 분들도 많거든요. 원체 기관지가 약하기 때문에 저도 위험군에 속하는 유형이고, 한 번 경험한 적이 있기 때문에 폐렴 관리 방법으로 저를 돌보기로 했습니다. 해당 질환의 경우 미생물에…

  • 최고의 베개 추천: 편안한 잠의 시작

    좋은 수면은 건강한 삶의 필수 요소입니다. 그중에서도 베개는 수면의 질을 결정짓는 중요한 요소 중 하나로, 적절한 베개 선택이 매우 중요합니다. 이번 글에서는 다양한 종류의 베개와 그 특징을 통해 어떤 베개가 가장 적합한지를 살펴보겠습니다. 베개의 종류: 나에게 맞는 베개 찾기 베개는 크게 메모리폼 베개, 라텍스 베개, 솜 베개, 자연 소재 베개로 나눌 수 있습니다. 각 베개는…

  • 불타는 트롯맨 공훈&에녹, 비밀스런 사랑 가사 듣기, 김지애 원곡

    Secret Love 가사 노래 듣기 불타는 트롯맨 공훈&에녹, 비밀스런 사랑 가사 듣기, 김지애 원곡 내가 짝사랑하는 여자/그리고/내가 짝사랑하는 남자/지금 어느 하늘 아래에서/누구를 사랑합니까/누구를? https://youtu.be/Pa4WxiDMdZU 여보, 그런 바람 슬픈 날에 꿀 무화과 성숙한 날에도 너 나와 함께 무화과 그늘에 숨어 과거에 대해 생각 나는 이야기하고 싶어 내가 짝사랑하는 여자와 다시 몰래 사랑했던 그 남자 지금 지금…

  • JavaScript(9) – API 사용(1)

    오픈소스를 활용한 카카오 우편번호 API를 사용해 보세요 기본 디자인이 마음에 들어서 부트스트랩을 이용해서 디자인을 좀 적용해봤습니다. (결과) (암호) <!DOCTYPE html> <html lang=”ko”> <head> <meta charset=”UTF-8″> <meta name=”viewport” content=”width=device-width, initial-scale=1.0″> <title>02_kakao우편번호.html</title> <link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css”> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js”></script> <script src=”https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js”></script> <style> h3 { margin : 10px; } </style> </head> <body> <!– (참조) http://postcode.map.daum.net/guide –> <!– ※ 카카오 우편번호…

  • 신생아 기저귀, 어떤 제품을 선택해야 할까?

    신생아를 돌보는 일은 행복한 순간들이 가득하지만 동시에 신생아의 건강과 안전을 최우선으로 고려해야 하는 도전적인 과제이기도 합니다. 특히, 신생아 기저귀는 아기의 편안함과 건강에 직결되는 매우 중요한 요소죠. 오늘은 다양한 신생아 기저귀를 비교 분석하며, 추천 제품 및 선택 시 유의사항에 대해 알아보겠습니다. 신생아 기저귀 선택 시 고려해야 할 요소 1. 소재와 흡수력 기저귀의 소재는 아기의 피부와 밀접한…

  • 추천 자격증명: 스쵸프 밸런스 리더

    추천 자격증명: 스쵸프 밸런스 리더 – 자격증 관련 정보에 대해 요약 확인 부탁드립니다~ 자격증 관련 취업 관련 전문 상담을 받는 것이 좋습니다. 어렵지 않은 상담의 신청도 할 수 있으므로, 방문해 주세요. 자격 취득에 대한 자세한 정보를 확인하세요. 관련 자격 증명을 보실 때 목차 목록을 이용하시면 보실 수 있습니다. 추천 자격 증명 취득을 지원하는 지원 기관은…