针对vr一体机进行修改逻辑

This commit is contained in:
shenjianxing 2025-03-19 16:31:17 +08:00
parent 26e73c995e
commit 76462dadbd
5 changed files with 168 additions and 167 deletions

View File

@ -123,7 +123,7 @@ Transform:
m_GameObject: {fileID: 598348144801550191}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 2.1975, z: -2.25}
m_LocalPosition: {x: 0, y: 2.1975, z: 0}
m_LocalScale: {x: 15, y: 15, z: 15}
m_ConstrainProportionsScale: 0
m_Children:
@ -172,7 +172,7 @@ Transform:
m_GameObject: {fileID: 765259898297824089}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -2.25}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 15, y: 15, z: 15}
m_ConstrainProportionsScale: 0
m_Children:
@ -428,7 +428,6 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4206005111461178323}
- {fileID: 1943472158707926008}
- {fileID: 4955625632054724442}
- {fileID: 2220253086530989832}
@ -570,7 +569,7 @@ Transform:
m_GameObject: {fileID: 3400309332038407868}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -0.000000059604645}
m_LocalPosition: {x: 0.030000001, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@ -1064,7 +1063,7 @@ Transform:
m_GameObject: {fileID: 4951725383111470759}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -0.000000059604645}
m_LocalPosition: {x: -0.030000001, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@ -1165,53 +1164,6 @@ MonoBehaviour:
mipBias: 0
varianceClampScale: 0.9
contrastAdaptiveSharpening: 0
--- !u!1 &5295768088636320424
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4206005111461178323}
- component: {fileID: 7751590708231362653}
m_Layer: 0
m_Name: ZProvider
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4206005111461178323
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5295768088636320424}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6541928711621635503}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &7751590708231362653
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5295768088636320424}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ae9977e6c48cd7040b272527034d9de1, type: 3}
m_Name:
m_EditorClassIdentifier:
_displayReferenceProfile: 2
_displayReferenceSize: {x: 0.521, y: 0.293}
_displayReferenceResolution: {x: 1920, y: 1080}
--- !u!1 &5647687646066518589
GameObject:
m_ObjectHideFlags: 0
@ -1440,6 +1392,8 @@ GameObject:
- component: {fileID: 6835854032803285639}
- component: {fileID: 263436429275714491}
- component: {fileID: 6027451431851870885}
- component: {fileID: 5140476435316401990}
- component: {fileID: 1546245213169538227}
m_Layer: 0
m_Name: ZCamera
m_TagString: MainCamera
@ -1456,7 +1410,7 @@ Transform:
m_GameObject: {fileID: 8487585372649695129}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -0.59773743}
m_LocalPosition: {x: 0, y: 0, z: -0.41000003}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
@ -1584,6 +1538,30 @@ MonoBehaviour:
mipBias: 0
varianceClampScale: 0.9
contrastAdaptiveSharpening: 0
--- !u!114 &5140476435316401990
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8487585372649695129}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 0}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1546245213169538227
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8487585372649695129}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 0}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &8683029409827073046
GameObject:
m_ObjectHideFlags: 0

View File

@ -11,124 +11,132 @@
namespace QFramework
{
using UnityEngine;
using UnityEngine;
/// <summary>
/// 每个 UIPanel 对应的Data
/// </summary>
public interface IUIData
{
}
/// <summary>
/// 每个 UIPanel 对应的Data
/// </summary>
public interface IUIData
{
}
public class UIPanelData : IUIData
{
}
public abstract partial class UIPanel : QMonoBehaviour, IPanel
{
public Transform Transform => transform;
public class UIPanelData : IUIData
{
}
IPanelLoader IPanel.Loader { get; set; }
public abstract partial class UIPanel : QMonoBehaviour, IPanel
{
public Transform Transform => transform;
public PanelInfo Info { get; set; }
IPanelLoader IPanel.Loader { get; set; }
public PanelState State { get; set; }
public PanelInfo Info { get; set; }
protected IUIData mUIData;
public PanelState State { get; set; }
public override IManager Manager => UIManager.Instance;
protected IUIData mUIData;
protected override void OnBeforeDestroy()
{
ClearUIComponents();
}
public override IManager Manager => UIManager.Instance;
protected virtual void ClearUIComponents()
{
}
protected override void OnBeforeDestroy()
{
ClearUIComponents();
}
public void Init(IUIData uiData = null)
{
mUIData = uiData;
OnInit(uiData);
}
protected virtual void ClearUIComponents()
{
}
public void Open(IUIData uiData = null)
{
State = PanelState.Opening;
OnOpen(uiData);
}
public void Init(IUIData uiData = null)
{
mUIData = uiData;
OnInit(uiData);
}
public override void Hide()
{
State = PanelState.Hide;
base.Hide();
}
public void Open(IUIData uiData = null)
{
State = PanelState.Opening;
OnOpen(uiData);
}
public override void Hide()
{
State = PanelState.Hide;
base.Hide();
}
protected virtual void OnInit(IUIData uiData = null)
{
protected virtual void OnInit(IUIData uiData = null)
{
}
}
protected virtual void OnOpen(IUIData uiData = null)
{
protected virtual void OnOpen(IUIData uiData = null)
{
}
}
/// <summary>
/// avoid override in child class
/// </summary>
protected sealed override void OnDestroy()
{
base.OnDestroy();
}
/// <summary>
/// avoid override in child class
/// </summary>
protected sealed override void OnDestroy()
{
base.OnDestroy();
}
/// <summary>
/// 关闭,不允许子类调用
/// </summary>
void IPanel.Close(bool destroyed)
{
Info.UIData = mUIData;
mOnClosed?.Invoke();
mOnClosed = null;
Hide();
State = PanelState.Closed;
OnClose();
/// <summary>
/// 关闭,不允许子类调用
/// </summary>
void IPanel.Close(bool destroyed)
{
Info.UIData = mUIData;
mOnClosed?.Invoke();
mOnClosed = null;
Hide();
State = PanelState.Closed;
OnClose();
if (destroyed)
{
Destroy(gameObject);
}
if (destroyed)
{
Destroy(gameObject);
}
var panelInterface = this as IPanel;
panelInterface.Loader.Unload();
UIKit.Config.PanelLoaderPool.RecycleLoader(panelInterface.Loader);
panelInterface.Loader = null;
var panelInterface = this as IPanel;
panelInterface.Loader.Unload();
UIKit.Config.PanelLoaderPool.RecycleLoader(panelInterface.Loader);
panelInterface.Loader = null;
mUIData = null;
}
mUIData = null;
}
protected void CloseSelf()
{
UIKit.ClosePanel(this);
}
protected void CloseSelf()
{
UIKit.ClosePanel(this);
}
protected void Back()
{
UIKit.Back(name);
}
protected void Back()
{
UIKit.Back(name);
}
/// <summary>
/// 必须使用这个
/// </summary>
protected abstract void OnClose();
/// <summary>
/// 必须使用这个
/// </summary>
protected abstract void OnClose();
private System.Action mOnClosed;
private System.Action mOnClosed;
public void OnClosed(System.Action onPanelClosed)
{
mOnClosed = onPanelClosed;
}
}
public void OnClosed(System.Action onPanelClosed)
{
mOnClosed = onPanelClosed;
}
#if VR
private void Update()
{
transform.localEulerAngles = Vector3.zero;
}
#endif
}
}

View File

@ -5,7 +5,6 @@ using QFramework;
using System;
using QFramework.Example;
using System.Linq;
using TreeEditor;
public class TextWindowAction : IAction
{
public ulong ActionID { get; set; }

View File

@ -27,27 +27,27 @@ public class FreeCameraController : MonoBehaviour
{
instance = this;
DontDestroyOnLoad(this);
// Cm = GameObject.Find("Mcam");
// Cm = GameObject.Find("Mcam");
ctrlor = GetComponent<CharacterController>();
Global.appSetting.MouseMoveSpeed.RegisterWithInitValue(v => rotateSpeed = v);
}
/// <summary>
/// 添加相机QE上下移动功能
/// </summary>
/// <returns></returns>
/// <summary>
/// 添加相机QE上下移动功能
/// </summary>
/// <returns></returns>
Vector3 GetInputTranslationDirection()
{
Vector3 direction = new Vector3();
if ( Input.GetKey(KeyCode.Q))
if (Input.GetKey(KeyCode.Q))
{
direction += Vector3.up;
}
if ( Input.GetKey(KeyCode.E))
if (Input.GetKey(KeyCode.E))
{
direction += Vector3.down;
}
@ -58,14 +58,15 @@ public class FreeCameraController : MonoBehaviour
{
if (isMov)
{
//// 相机移动
//float horizontal = Input.GetAxis("Horizontal") * moveSpeed * Time.deltaTime;
//float vertical = Input.GetAxis("Vertical") * moveSpeed * Time.deltaTime;
#if VR
// 相机移动
float horizontal = Input.GetAxis("Horizontal") * moveSpeed * Time.deltaTime;
float vertical = Input.GetAxis("Vertical") * moveSpeed * Time.deltaTime;
//Vector3 move = transform.right * horizontal + transform.forward * vertical;
//transform.position += move;
Vector3 move = transform.right * horizontal + transform.forward * vertical;
transform.position += move;
#else
//W键前进
if (Input.GetKey(KeyCode.W))
@ -107,7 +108,7 @@ public class FreeCameraController : MonoBehaviour
}
////添加相机QE上下移动功能
//transform.position+= GetInputTranslationDirection()*0.01f;
#endif
}
if (isRot)
{

View File

@ -47,15 +47,30 @@ namespace QFramework.Example
public void SetNear()
{
Camera.main.transform.DOMove(mData.nearPos, mData.nearTime);
Camera.main.transform.DORotate(mData.nearRot, mData.nearTime);
Transform trans = null;
#if VR
trans = UIRoot.Instance.transform.Find("ZFrame");
#else
trans = Camera.main.transform;
#endif
trans.DOMove(mData.nearPos, mData.nearTime);
trans.DORotate(mData.nearRot, mData.nearTime);
}
public void SetNormal()
{
Camera.main.transform.DOMove(mData.normalPos, mData.normalTime);
Camera.main.transform.DORotate(mData.normalRot, mData.normalTime);
Transform trans = null;
#if VR
trans = UIRoot.Instance.transform.Find("ZFrame");
#else
trans = Camera.main.transform;
#endif
trans.DOMove(mData.normalPos, mData.normalTime);
trans.DORotate(mData.normalRot, mData.normalTime);
}
protected override void OnOpen(IUIData uiData = null)
{