Skip to content

Commit

Permalink
Fixed the position issue when recenter the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Yannick committed Oct 21, 2016
1 parent a1a4e88 commit ecf9005
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 19 deletions.
11 changes: 4 additions & 7 deletions Assets/Scripts/TES/Components/PlayerVRComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,8 @@ void Update()
/// <summary>
/// Recenter the Main UI.
/// </summary>
/// <returns></returns>
private IEnumerator RecenterUI()
private void RecenterUI()
{
yield return new WaitForSeconds(0.1f);

if (_vrVendor != VRVendor.None)
{
var pivotRot = _pivotCanvas.localRotation;
Expand Down Expand Up @@ -179,10 +176,10 @@ public void ResetOrientationAndPosition()
/// Sent by the PlayerComponent when the pause method is called.
/// </summary>
/// <param name="paused">Boolean: Indicates if the player is paused.</param>
void OnPlayerPause(object paused)
void OnPlayerPause(bool paused)
{
if (((bool)paused))
StartCoroutine(RecenterUI());
if (paused)
RecenterUI();
}
}
}
10 changes: 6 additions & 4 deletions Assets/Scripts/TES/UI/UIBook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ void Start()
{
var texture = TESUnity.instance.TextureManager.LoadTexture("tx_menubook", true);
_background.sprite = GUIUtils.CreateSprite(texture);
transform.localPosition = Vector3.zero;
transform.localRotation = Quaternion.identity;
transform.localScale = Vector3.one;


// If the book is already opened, don't change its transform.
if (_bookRecord == null)
Close();
}
Expand Down Expand Up @@ -162,6 +160,10 @@ public static UIBook Create(Transform parent)
{
var uiBookAsset = Resources.Load<GameObject>("UI/Book");
var uiBookGO = (GameObject)GameObject.Instantiate(uiBookAsset, parent);
var uiTransform = uiBookGO.GetComponent<RectTransform>();
uiTransform.localPosition = Vector3.zero;
uiTransform.localRotation = Quaternion.identity;
uiTransform.localScale = Vector3.one;
return uiBookGO.GetComponent<UIBook>();
}
}
Expand Down
3 changes: 3 additions & 0 deletions Assets/Scripts/TES/UI/UIInteractiveText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public void SetParent(Transform transform)
{
var rectTransform = GetComponent<RectTransform>();
rectTransform.SetParent(transform, false);
rectTransform.localPosition = Vector3.zero;
rectTransform.localRotation = Quaternion.identity;
rectTransform.localScale = Vector3.one;
}
}
}
8 changes: 5 additions & 3 deletions Assets/Scripts/TES/UI/UIScroll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ void Start()
{
var texture = TESUnity.instance.TextureManager.LoadTexture("scroll", true);
_background.sprite = GUIUtils.CreateSprite(texture);
transform.localPosition = Vector3.zero;
transform.localRotation = Quaternion.identity;
transform.localScale = Vector3.one;

// If the book is already opened, don't change its transform.
if (_bookRecord == null)
Close();
}
Expand Down Expand Up @@ -74,6 +72,10 @@ public static UIScroll Create(Transform parent)
{
var uiScrollAsset = Resources.Load<GameObject>("UI/Scroll");
var uiScrollGO = (GameObject)GameObject.Instantiate(uiScrollAsset, parent);
var uiTransform = uiScrollGO.GetComponent<RectTransform>();
uiTransform.localPosition = Vector3.zero;
uiTransform.localRotation = Quaternion.identity;
uiTransform.localScale = Vector3.one;
return uiScrollGO.GetComponent<UIScroll>();
}
}
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#TESUnity Changelog

## Version 0.5 - 10/21/2016
### Added
- OSVR Support
- Other VR SDKs Support (not yet enabled)
- Enhanced VR support for UI and HUD

## Version 0.4 - 10/18/2016
### Added
- New flags to enable new features (see readme.md)
Expand Down
10 changes: 10 additions & 0 deletions README-VR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# TESUnity VR

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.

## OSVR Users
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.

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
* Disable your SteamVR driver
* Start the game like that `TESUnity.exe -vrmode None`.
11 changes: 6 additions & 5 deletions config.ini.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

[Rendering]
RenderPath = 1
Expand All @@ -11,18 +11,19 @@ Shader = Bumped
[Lighting]
AnimateLights = False
SunShadows = True
LightShadows = False
LightShadows = True
RenderExteriorCellLights = False

[Effects]
AntiAliasing = False
AmbientOcclusion = False
Bloom = False
Bloom = True
WaterBackSideTransparent = False

[VR]
FollowHeadDirection = False
FollowHeadDirection = True
DirectModePreview = False

[Debug]
CreaturesEnabled = False
CreaturesEnabled = True

0 comments on commit ecf9005

Please sign in to comment.