Developing a multidisplay application on Unity3D 2018.3.
The application is calculated to run on a machine with 3 displays. It is necessary that some elements of the user interface are duplicated. Those. for each of the monitors there is a Canvas with its own elements. But on each of them there is a button opening a panel with a certain set of elements, let it be sliders. So, changing the value of the slider on one Canvas-e duplicate sliders should be changed on other Canvas-ah.
In the simplest way, I see the creation of a script in which I place a link to the duplicating slider and there I subscribe to the event of changing the value. This is easy to implement, but too inconvenient to use. And if I only need to duplicate the slider, but also an InputField or something else will come up with a custom one? For each write a similar script? This is not convenient!
Is there any other solution? Please suggest ideas!
UPD: Code that I imagine:
[RequireComponent(typeof(Slider))] public class DublicateSlider : MonoBehaviour { [SerializeField] private Slider[] _sliders; private Slider _thisSlider; private void Awake() { _thisSlider = GetComponent<Slider>(); foreach (var slider in _sliders) { slider.onValueChanged.AddListener(value => _thisSlider.value = value); } } }