현재 룰렛은 8등분이 되어 있고

각각 360 / 8인 45도로 구성되어 있다.

그러므로 이 가운데 값은 22.5도이다.

룰렛을 개발자가 편하게 컨트롤 할 수 있도록 만들었다.

 

360도 * 횟수를 적용하여 여러번 돌아가고 거기에 지정한 extraAngle을 더해주면된다.

 

회전횟수를 선택할 수 있고 스탭을 조절함으로서 속도를 조절할 수 있다.

 

 

아래는 개발자들은 이미 사전에 클릭을 하면 알 수 있게 항목을 출력하도록 변경

나오는 것은 랜덤으로 변경

즉, 랜덤에 따라 특정 각도가 결정되고 그에 따라 개발자들은 출력결과를 미리 알수 있고,

유저들은 원하는 각도를 보게 되는 것이다.

 

using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.UI;

public class RouletteTest : MonoBehaviour
{
    [SerializeField] private Button btnGetIem;
    [SerializeField] private Roulette _roulette;
    //[SerializeField] private float targetAngle = -22.5f; //클로버를 겨냥

    private string[] itemNames = { "폭탄" , "기력회복", "폭탄", "체력회복", "폭탄", "금화획득","폭탄", "네잎클로버"};
    private float[] targetAngles =
    {
        22.5f, 67.5f, 112.5f, 157.5f, 202.5f, 247.5f, 292.5f, 337.5f
    };
    void Start()
    {
        btnGetIem.onClick.AddListener(() =>
        {
            int idx = UnityEngine.Random.Range(0, 8); // 0 ~ 7
            Debug.Log($"<color=yellow>{itemNames[idx]}</color>");
            _roulette.StartRotate(targetAngles[idx]);
        });
    }

}

 

using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.UI;

public class RouletteTest : MonoBehaviour
{
    [SerializeField] private Button btnGetIem;
    [SerializeField] private Roulette _roulette;
    //[SerializeField] private float targetAngle = -22.5f; //클로버를 겨냥

    private string[] itemNames = { "폭탄" , "기력회복", "폭탄", "체력회복", "폭탄", "금화획득","폭탄", "네잎클로버"};
    private float[] targetAngles =
    {
        22.5f, 67.5f, 112.5f, 157.5f, 202.5f, 247.5f, 292.5f, 337.5f
    };
    void Start()
    {
        btnGetIem.onClick.AddListener(() =>
        {
            int idx = UnityEngine.Random.Range(0, 8); // 0 ~ 7
            Debug.Log($"<color=yellow>{itemNames[idx]}</color>");
            _roulette.StartRotate(targetAngles[idx]);
        });
    }

}

'Study > ' 카테고리의 다른 글

[Tip] Mathf.DeltaAngle  (0) 2024.06.29
[Tip] Object.FindObjectOfType  (0) 2024.06.11
[Tip] RenderSettings  (0) 2024.06.05
[팁] Slider.onValueChanged  (0) 2024.06.05

https://docs.unity3d.com/ScriptReference/Mathf.DeltaAngle.html

 

Unity - Scripting API: Mathf.DeltaAngle

Success! Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable. Close

docs.unity3d.com

'Study > ' 카테고리의 다른 글

[Tip]룰렛 원하는 곳에 위치 + 텍스트 출력  (0) 2024.06.29
[Tip] Object.FindObjectOfType  (0) 2024.06.11
[Tip] RenderSettings  (0) 2024.06.05
[팁] Slider.onValueChanged  (0) 2024.06.05

https://docs.unity3d.com/ScriptReference/Object.FindObjectOfType.html

 

Unity - Scripting API: Object.FindObjectOfType

Object.FindObjectOfType will not return Assets (meshes, textures, prefabs, ...) or inactive objects. It will not return an object that has HideFlags.DontSave set. Please note that this function is very slow. It is not recommended to use this function every

docs.unity3d.com

'Study > ' 카테고리의 다른 글

[Tip]룰렛 원하는 곳에 위치 + 텍스트 출력  (0) 2024.06.29
[Tip] Mathf.DeltaAngle  (0) 2024.06.29
[Tip] RenderSettings  (0) 2024.06.05
[팁] Slider.onValueChanged  (0) 2024.06.05

아래의 api document를 활용하여 각각의 프로티에 대한 정보를 얻을 수 있다.

 

 

https://docs.unity3d.com/ScriptReference/RenderSettings.html

 

Unity - Scripting API: RenderSettings

Success! Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable. Close

docs.unity3d.com

 

 

아래의 사진은 ambientLight라는 속성의 예시이다.

'Study > ' 카테고리의 다른 글

[Tip]룰렛 원하는 곳에 위치 + 텍스트 출력  (0) 2024.06.29
[Tip] Mathf.DeltaAngle  (0) 2024.06.29
[Tip] Object.FindObjectOfType  (0) 2024.06.11
[팁] Slider.onValueChanged  (0) 2024.06.05

https://docs.unity3d.com/560/Documentation/ScriptReference/UI.Slider-onValueChanged.html

 

Unity - Scripting API: UI.Slider.onValueChanged

Success! Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable. Close

docs.unity3d.com

 

'Study > ' 카테고리의 다른 글

[Tip]룰렛 원하는 곳에 위치 + 텍스트 출력  (0) 2024.06.29
[Tip] Mathf.DeltaAngle  (0) 2024.06.29
[Tip] Object.FindObjectOfType  (0) 2024.06.11
[Tip] RenderSettings  (0) 2024.06.05

+ Recent posts