Skip to content

Commit

Permalink
Merge pull request #1585 from WEKIT-ECS/release_2.4
Browse files Browse the repository at this point in the history
Release 2.4
  • Loading branch information
robhillman97 authored Oct 5, 2023
2 parents 36c7e61 + cee92a3 commit df4afc4
Show file tree
Hide file tree
Showing 11 changed files with 6,517 additions and 4,276 deletions.
1 change: 1 addition & 0 deletions Assets/MirageXR/Common/Scripts/DataModel/Activity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ public class ToggleObject // is an annotation
public string rotation = string.Empty; // Vector3 format 0, 0, 0
public float scale = 0f;
public bool positionLock = false;
public bool billboarded = true;

// NOT IN ARLEM SPEC. For the detect symbol.
public float duration = 0f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void ColourSelected(Image image)
{
_selectedColour = image.color;
_onColourSelected.Invoke();
Close();
//Close();
}

public void Open()
Expand Down
16 changes: 11 additions & 5 deletions Assets/MirageXR/Player/Scripts/Augmentations/Label/Label.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using i5.Toolkit.Core.VerboseLogging;
using Microsoft.MixedReality.Toolkit.UI;
using Microsoft.MixedReality.Toolkit.UI;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

namespace MirageXR
{
Expand Down Expand Up @@ -61,7 +60,6 @@ public override bool Init(ToggleObject obj)
return false;
}
}

else
{
gameObject.AddComponent<Billboard>();
Expand All @@ -77,9 +75,17 @@ public override bool Init(ToggleObject obj)
_labelBackground.color = GetColorFromString(splitArray[2]);
}

GetComponentInChildren<Billboard>().enabled = obj.billboarded;

// Set scaling if defined in action configuration.
var myPoiEditor = transform.parent.gameObject.GetComponent<PoiEditor>();
transform.parent.localScale = GetPoiScale(myPoiEditor, Vector3.one);


if (!_obj.billboarded)
{
myPoiEditor = transform.parent.gameObject.GetComponent<PoiEditor>();
transform.localEulerAngles = GetPoiRotation(myPoiEditor);
}

OnLock(_obj.poi, _obj.positionLock);
EventManager.OnAugmentationLocked += OnLock;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using DG.Tweening;
using DG.Tweening;
using MirageXR;
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
Expand All @@ -19,47 +19,54 @@ public class IntHolder : ObjectHolder<int> { }

[SerializeField] private TMP_InputField _inputField;
[SerializeField] private Toggle _toggleTrigger;
[SerializeField] private Toggle _toggleBillboard;
[SerializeField] private Button _btnIncreaseGazeDuration;
[SerializeField] private Button _btnDecreaseGazeDuration;
[SerializeField] private TMP_Text _txtGazeDurationValue;
[SerializeField] private GameObject _gazeDurationPanel;
[SerializeField] private ClampedScrollRect _clampedScrollJumpToStep;
[SerializeField] private GameObject _clampedScrollObject;
[SerializeField] private GameObject _templatePrefab;
[SerializeField] private GameObject _settingsPannel;
[SerializeField] private GameObject _mainPannel;

[SerializeField] private TMP_Text _exampleLabel;
[SerializeField] private Image _exampleLabelBackground;
[SerializeField] private TMP_InputField _fontSize;

[Space]
[SerializeField] public TMP_Text _exampleLabel;
[SerializeField] public Image _exampleLabelBackground;
[SerializeField] private Button _fontSizeButton;
[SerializeField] private Button _fontColorButton;
[SerializeField] private Button _backgroundColorButton;
[SerializeField] private Image _fontColourButtonImage;
[SerializeField] private Image _backgroundColourButtonImage;

[SerializeField] private ColourSelector _colourPickerScript;
[SerializeField] private TMP_Text _fontSizeText;
[Space]
[SerializeField] private Button _btnArrow;
[SerializeField] private RectTransform _panel;
[SerializeField] private GameObject _arrowDown;
[SerializeField] private GameObject _arrowUp;
[SerializeField] private LabelSettings _labelSettings;

private Trigger _trigger;
private float _gazeDuration;
private int _triggerStepIndex;
private enum ColourPickerOption { NA, Font, Background };
private bool _isBillboarded;

public enum SettingsPanel { Size, Font, Background };
public SettingsPanel _settingsPanelStart = SettingsPanel.Background;

private ColourPickerOption _colourPickerOption = ColourPickerOption.NA;

public override void Initialization(Action<PopupBase> onClose, params object[] args)
{
_colourPickerScript.onColourSelected.AddListener(OnColourPickerChange);
_showBackground = false;
base.Initialization(onClose, args);
_toggleTrigger.onValueChanged.AddListener(OnTriggerValueChanged);
_toggleBillboard.onValueChanged.AddListener(OnBillboardValueChanged);
_btnIncreaseGazeDuration.onClick.AddListener(OnIncreaseGazeDuration);
_btnDecreaseGazeDuration.onClick.AddListener(OnDecreaseGazeDuration);
_btnArrow.onClick.AddListener(OnArrowButtonPressed);
_clampedScrollJumpToStep.onItemChanged.AddListener(OnItemJumpToStepChanged);

_fontSizeButton.onClick.AddListener(ShowFontSizePanel);
_fontColorButton.onClick.AddListener(ShowFontColorPanel);
_backgroundColorButton.onClick.AddListener(ShowBackgroundColorPanel);

var steps = activityManager.ActionsOfTypeAction;
var stepsCount = steps.Count;
InitClampedScrollRect(_clampedScrollJumpToStep, _templatePrefab, stepsCount, stepsCount.ToString());
Expand Down Expand Up @@ -90,6 +97,8 @@ private void UpdateView()
{
_inputField.text = _content.text;
_trigger = _step.triggers.Find(tr => tr.id == _content.poi);
_isBillboarded = _content.billboarded;
_toggleBillboard.isOn = _content.billboarded;

if (_trigger != null)
{
Expand Down Expand Up @@ -161,6 +170,12 @@ private void OnDecreaseGazeDuration()
private void OnTriggerValueChanged(bool value)
{
_gazeDurationPanel.SetActive(value);
_clampedScrollObject.SetActive(value);
}

private void OnBillboardValueChanged(bool value)
{
_isBillboarded = value;
}

protected override void OnAccept()
Expand All @@ -182,6 +197,7 @@ protected override void OnAccept()
}
_content.text = _inputField.text;
_content.option = _exampleLabel.fontSize.ToString() + "-" + _exampleLabel.color.ToString() + "-" + _exampleLabelBackground.color.ToString();
_content.billboarded = _isBillboarded;

if (_toggleTrigger.isOn)
{
Expand Down Expand Up @@ -219,74 +235,55 @@ private void OnDestroy()
RootView_v2.Instance.ShowBaseView();
}

public void OpenSettings(bool open)
private Color GetColorFromString(string rgb)
{
_settingsPannel.SetActive(open);
_mainPannel.SetActive(!open);
string[] rgba = rgb.Substring(5, rgb.Length - 6).Split(", ");
Color color = new Color(float.Parse(rgba[0]), float.Parse(rgba[1]), float.Parse(rgba[2]), float.Parse(rgba[3]));

return color;
}

public void OnFontSizeChanged()
public void onInputChanged()
{
var size = 36;

int.TryParse(_fontSize.text, out size);

_exampleLabel.fontSize = size;
_exampleLabel.text = _inputField.text;
}


public void OnFontColourChange()
private void UpdateButtonColours()
{
// _colourPickerObject.SetActive(true);
_settingsPannel.SetActive(false);
_colourPickerScript.Open();
_colourPickerOption = ColourPickerOption.Font;
_fontColourButtonImage.color = _exampleLabel.color;
_backgroundColourButtonImage.color = _exampleLabelBackground.color;
_fontSizeText.text = _exampleLabel.fontSize.ToString();
}

public void OnBackgroundColourChanged()
private void ShowFontSizePanel()
{
//_colourPickerObject.SetActive(true);
_settingsPannel.SetActive(false);
_colourPickerScript.Open();
_colourPickerOption = ColourPickerOption.Background;
_settingsPanelStart = SettingsPanel.Size;
ShowSettings();
}

public void OnColourPickerChange()
private void ShowFontColorPanel()
{
switch (_colourPickerOption)
{
case ColourPickerOption.Font:
_exampleLabel.color = _colourPickerScript._selectedColour;
break;
case ColourPickerOption.Background:
_exampleLabelBackground.color = _colourPickerScript._selectedColour;
break;
default:
break;
}

UpdateButtonColours();
_settingsPannel.SetActive(true);

_colourPickerOption = ColourPickerOption.NA;
_settingsPanelStart = SettingsPanel.Font;
ShowSettings();
}

private Color GetColorFromString(string rgb)
private void ShowBackgroundColorPanel()
{
string[] rgba = rgb.Substring(5, rgb.Length - 6).Split(", ");
Color color = new Color(float.Parse(rgba[0]), float.Parse(rgba[1]), float.Parse(rgba[2]), float.Parse(rgba[3]));

return color;
_settingsPanelStart = SettingsPanel.Background;
ShowSettings();
}

public void onInputChanged()
private void ShowSettings()
{
_exampleLabel.text = _inputField.text;
PopupsViewer.Instance.Show(_labelSettings, this);
}

private void UpdateButtonColours()
public void LabelSettingsChanged(Color font, Color background, float size)
{
_fontColourButtonImage.color = _exampleLabel.color;
_backgroundColourButtonImage.color = _exampleLabelBackground.color;
_exampleLabelBackground.color = background;
_exampleLabel.color = font;
_exampleLabel.fontSize = size;

UpdateButtonColours();
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit df4afc4

Please sign in to comment.