Last active
April 15, 2020 06:59
-
-
Save mtytheone/ee751b3e60ca4794ed84a4ed5270e6b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UdonSharp; | |
using UnityEngine; | |
using UnityEngine.UI; | |
using VRC.SDKBase; | |
using VRC.Udon; | |
public class SyncSlider : UdonSharpBehaviour | |
{ | |
[SerializeField] Slider _slider; | |
[SerializeField] Text _text; | |
[SerializeField] Text _ownerText; | |
[UdonSynced(UdonSyncMode.None)] | |
float _sliderValue; | |
void LateUpdate() | |
{ | |
_slider.value = _sliderValue; | |
_text.text = _sliderValue.ToString("F2"); | |
_ownerText.text = Networking.GetOwner(this.gameObject).displayName; | |
} | |
public void SetValue() //OnValueChangedで呼ぶ | |
{ | |
_sliderValue = _slider.value; | |
} | |
public void ChangerOwner() //EventTriggerで呼ぶ | |
{ | |
if (!Networking.IsOwner(Networking.LocalPlayer, this.gameObject)) Networking.SetOwner(Networking.LocalPlayer, this.gameObject); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment