private void Start() { _player = FindObjectOfType <Player>(); _playerCamera = _player.GetComponentInChildren <Camera>(); gameObject.tag = "RenderCamera"; _layer = 1 << LayerMask.NameToLayer("FakeWorld"); if (CenterAnchor == null) { CenterAnchor = ConfigureAnchor(null, CenterAnchorName); } if (PortalCamera == null) { PortalCamera = CenterAnchor.GetComponent <Camera>(); if (PortalCamera == null) { PortalCamera = CenterAnchor.gameObject.AddComponent <Camera>(); PortalCamera.name = "portalCamera"; SetupCameraProperties(PortalCamera); } } else { Debug.Log("PortalCamera found"); } }
public override void Load() { // Create the UI controller. _uiController = new Controller(); // Create the corner anchor. _anchor = new CenterAnchor(); _uiController.Add(_anchor); // Create a component to center. BasicButton test = new BasicButton(new Vector3(10, 10, 0), new Vector2(100, 100)); _anchor.AddChild(test, new Rectangle(0, 100, 0, 0)); }
public override void Load() { _sounds = Directory.GetFiles("Assets/SoundPlayer").Where(x => x.Contains(".wav")).Select(x => x.Replace("Assets/", "")).ToArray(); _uiController = new Controller(); CenterAnchor centerAnchor = new CenterAnchor(); _uiController.Add(centerAnchor); _controlButton = new BasicButton(Vector3.Zero, new Vector2(36, 36)) { Texture = Context.AssetLoader.Get <Texture>(_playButton), OnClick = () => { SoundLayer layer = Context.SoundManager.GetLayer("main"); if (layer == null) { return; } if (layer.Status == SoundStatus.Playing) { layer.Pause(); } else { layer.Resume(); } } }; centerAnchor.AddChild(_controlButton, new Rectangle(0, Context.Settings.RenderHeight / 2 - 36, 0, 0)); BasicButton loopButton = new BasicButton(Vector3.Zero, new Vector2(36, 36)) { Texture = Context.AssetLoader.Get <Texture>(_loopButton) }; loopButton.OnClick = () => { SoundLayer layer = Context.SoundManager.GetLayer("main"); if (layer == null) { return; } layer.Looping = !layer.Looping; loopButton.Tint = layer.Looping ? Color.Green : Color.White; }; centerAnchor.AddChild(loopButton, new Rectangle(-40, Context.Settings.RenderHeight / 2 - 36, 0, 0)); _soundBar = new ScrollInput(Vector3.Zero, new Vector2(Context.Settings.RenderWidth - 40, 10)) { KeepSelectorInside = true, SelectorRatio = 3 }; centerAnchor.AddChild(_soundBar, new Rectangle(0, Context.Settings.RenderHeight / 2 - 10, 0, 0)); _soundBarInfo = new BasicText(Context.AssetLoader.Get <Font>(_defaultFont), 13, "N/A", Color.White, Vector3.Zero); centerAnchor.AddChild(_soundBarInfo, new Rectangle(100, Context.Settings.RenderHeight / 2 - 30, 0, 0)); CornerAnchor cornerAnchor = new CornerAnchor(); _uiController.Add(cornerAnchor); for (int i = 0; i < _sounds.Length; i++) { int iCopy = i; ClickableLabel addSoundText = new ClickableLabel(Context.AssetLoader.Get <Font>(_defaultFont), 15, _sounds[i], Color.White, Vector3.Zero) { OnClick = () => { if (_append) { Context.SoundManager.PlayQueue(Context.AssetLoader.Get <SoundFile>(_sounds[iCopy]), "main"); } else { Context.SoundManager.Play(Context.AssetLoader.Get <SoundFile>(_sounds[iCopy]), "main"); } } }; cornerAnchor.AddChild(addSoundText, AnchorLocation.TopLeft, new Rectangle(0, 0, Context.Settings.RenderWidth, 0)); } BasicButton appendButton = new BasicButton(Vector3.Zero, new Vector2(36, 36)) { Texture = Context.AssetLoader.Get <Texture>(_addButton) }; appendButton.OnClick = () => { _append = !_append; appendButton.Tint = _append ? Color.Green : Color.White; }; cornerAnchor.AddChild(appendButton, AnchorLocation.TopLeft, new Rectangle(0, 0, Context.Settings.RenderWidth, 0)); PlayerVolumeControl volumeControl = new PlayerVolumeControl(Vector3.Zero, new Vector2(100, 20)); cornerAnchor.AddChild(volumeControl, AnchorLocation.TopRight, new Rectangle(0, 20, 20, 0)); }