Skip to content

Commit ecf9005

Browse files
author
Yannick
committed
Fixed the position issue when recenter the UI
1 parent a1a4e88 commit ecf9005

File tree

7 files changed

+40
-19
lines changed

7 files changed

+40
-19
lines changed

Assets/Scripts/TES/Components/PlayerVRComponent.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,8 @@ void Update()
125125
/// <summary>
126126
/// Recenter the Main UI.
127127
/// </summary>
128-
/// <returns></returns>
129-
private IEnumerator RecenterUI()
128+
private void RecenterUI()
130129
{
131-
yield return new WaitForSeconds(0.1f);
132-
133130
if (_vrVendor != VRVendor.None)
134131
{
135132
var pivotRot = _pivotCanvas.localRotation;
@@ -179,10 +176,10 @@ public void ResetOrientationAndPosition()
179176
/// Sent by the PlayerComponent when the pause method is called.
180177
/// </summary>
181178
/// <param name="paused">Boolean: Indicates if the player is paused.</param>
182-
void OnPlayerPause(object paused)
179+
void OnPlayerPause(bool paused)
183180
{
184-
if (((bool)paused))
185-
StartCoroutine(RecenterUI());
181+
if (paused)
182+
RecenterUI();
186183
}
187184
}
188185
}

Assets/Scripts/TES/UI/UIBook.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ void Start()
3939
{
4040
var texture = TESUnity.instance.TextureManager.LoadTexture("tx_menubook", true);
4141
_background.sprite = GUIUtils.CreateSprite(texture);
42-
transform.localPosition = Vector3.zero;
43-
transform.localRotation = Quaternion.identity;
44-
transform.localScale = Vector3.one;
45-
42+
43+
// If the book is already opened, don't change its transform.
4644
if (_bookRecord == null)
4745
Close();
4846
}
@@ -162,6 +160,10 @@ public static UIBook Create(Transform parent)
162160
{
163161
var uiBookAsset = Resources.Load<GameObject>("UI/Book");
164162
var uiBookGO = (GameObject)GameObject.Instantiate(uiBookAsset, parent);
163+
var uiTransform = uiBookGO.GetComponent<RectTransform>();
164+
uiTransform.localPosition = Vector3.zero;
165+
uiTransform.localRotation = Quaternion.identity;
166+
uiTransform.localScale = Vector3.one;
165167
return uiBookGO.GetComponent<UIBook>();
166168
}
167169
}

Assets/Scripts/TES/UI/UIInteractiveText.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public void SetParent(Transform transform)
7676
{
7777
var rectTransform = GetComponent<RectTransform>();
7878
rectTransform.SetParent(transform, false);
79+
rectTransform.localPosition = Vector3.zero;
80+
rectTransform.localRotation = Quaternion.identity;
81+
rectTransform.localScale = Vector3.one;
7982
}
8083
}
8184
}

Assets/Scripts/TES/UI/UIScroll.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ void Start()
2323
{
2424
var texture = TESUnity.instance.TextureManager.LoadTexture("scroll", true);
2525
_background.sprite = GUIUtils.CreateSprite(texture);
26-
transform.localPosition = Vector3.zero;
27-
transform.localRotation = Quaternion.identity;
28-
transform.localScale = Vector3.one;
2926

27+
// If the book is already opened, don't change its transform.
3028
if (_bookRecord == null)
3129
Close();
3230
}
@@ -74,6 +72,10 @@ public static UIScroll Create(Transform parent)
7472
{
7573
var uiScrollAsset = Resources.Load<GameObject>("UI/Scroll");
7674
var uiScrollGO = (GameObject)GameObject.Instantiate(uiScrollAsset, parent);
75+
var uiTransform = uiScrollGO.GetComponent<RectTransform>();
76+
uiTransform.localPosition = Vector3.zero;
77+
uiTransform.localRotation = Quaternion.identity;
78+
uiTransform.localScale = Vector3.one;
7779
return uiScrollGO.GetComponent<UIScroll>();
7880
}
7981
}

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#TESUnity Changelog
22

3+
## Version 0.5 - 10/21/2016
4+
### Added
5+
- OSVR Support
6+
- Other VR SDKs Support (not yet enabled)
7+
- Enhanced VR support for UI and HUD
8+
39
## Version 0.4 - 10/18/2016
410
### Added
511
- New flags to enable new features (see readme.md)

README-VR.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# TESUnity VR
2+
3+
TESUnity supports the Oculus Rift, OSVR and the OpenVR API. The world of Morrowind is generated at runtime, so some optimizations can't be done, especially lights and culling optimizations. Because of that, the game can slow down when a new group of cells are loaded.
4+
5+
## OSVR Users
6+
The [OSVR Unity plugin](https://github.com/OSVR/OSVR-Unity) is not as optimized as other VR vendors. It is recommanded to switch to OpenVR (using SteamVR-OSVR) for best performance. However if you want to use the native OSVR integration, it is recommanded to turn off all effects and use the Unlit shader. We'll work with the OSVR Unity Team to find how to solve this problem.
7+
8+
If the [SteamVR-OSVR plugin](https://github.com/OSVR/SteamVR-OSVR) is enabled, it will load the OpenVR integration automatically, preventing you to start the game with the native OSVR integration. To solve that, you can
9+
* Disable your SteamVR driver
10+
* Start the game like that `TESUnity.exe -vrmode None`.

config.ini.dist

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[Global]
44
PlayMusic = True
5-
MorrowindPath = C:/Program Files (x86)/Steam/steamapps/common/Morrowind/Data Files
5+
MorrowindPath = C:\Users\demon\Documents\Unity\Demonixis\TESUnity\Data Files
66

77
[Rendering]
88
RenderPath = 1
@@ -11,18 +11,19 @@ Shader = Bumped
1111
[Lighting]
1212
AnimateLights = False
1313
SunShadows = True
14-
LightShadows = False
14+
LightShadows = True
1515
RenderExteriorCellLights = False
1616

1717
[Effects]
1818
AntiAliasing = False
1919
AmbientOcclusion = False
20-
Bloom = False
20+
Bloom = True
2121
WaterBackSideTransparent = False
2222

2323
[VR]
24-
FollowHeadDirection = False
24+
FollowHeadDirection = True
25+
DirectModePreview = False
2526

2627
[Debug]
27-
CreaturesEnabled = False
28+
CreaturesEnabled = True
2829

0 commit comments

Comments
 (0)