MyUnityTest

 2023.10.12 unityC#  
 2023.09.18 unityC#  
 2023.09.18 unityC#  
 2023.09.15 unityC#  
 2023.09.15 unityC#  
 2023.09.15 unityC#  
 2023.09.14 unityC#  
 2023.09.13 unityC#  
 2023.09.13 unityC#  

page.phpテンプレートを利用しています。

SoundOnOff-Slider


using UnityEngine;
using UnityEngine.UI;
public class SoundPlay : MonoBehaviour
{
    AudioSource audioSource;
    private bool toggle;
    public Slider slider;
    void Start()
 {
   audioSource = GetComponent();
   toggle = true;    //初期設定
   slider.onValueChanged.AddListener(value => 
   this.audioSource.volume = value);
 }
//button onClick
    public void PlayStart()
    {
        if (toggle)
        {
            audioSource.Play();
            toggle = false;
        }
        else
        {
            audioSource.Stop();
            toggle = true;
        }
    }
}

月別
固定ページ