Compare commits

..

No commits in common. "dfa88f9503ad7cf1ae46edf64eaeca97e4e91d5f" and "9feba7e69ff14bc600fe2c77be241f79aae2acba" have entirely different histories.

3 changed files with 166 additions and 168 deletions

View File

@ -189,13 +189,10 @@ public class UXButton : UIBehaviour, IPointerDownHandler, IPointerUpHandler, IPo
return m_Mode == ButtonModeType.Toggle && m_IsTogSelected; return m_Mode == ButtonModeType.Toggle && m_IsTogSelected;
} }
public void SetSelect(bool state, bool boardEvent = false) public void SetSelect(bool state)
{ {
if (m_Mode != ButtonModeType.Toggle) return; if (m_Mode != ButtonModeType.Toggle) return;
m_IsTogSelected = state; IsSelected = state;
if (boardEvent) onValueChanged?.Invoke(m_IsTogSelected);
m_SelectionState = m_IsTogSelected ? SelectionState.Selected : SelectionState.Normal;
UpdateVisualState(m_SelectionState, false);
} }
private void ProcessClick() private void ProcessClick()

View File

@ -1,55 +1,55 @@
using UnityEngine; // using UnityEngine;
using UnityEngine.EventSystems; // using UnityEngine.EventSystems;
//
namespace AlicizaX.UI.Extension // namespace AlicizaX.UI.Extension
{ // {
public class UI3DDisplayTouch : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IDragHandler // public class UI3DDisplayTouch : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IDragHandler
{ // {
private GameObject m_dragObject; // private GameObject m_dragObject;
private bool m_CanDrag = true; // private bool m_CanDrag = true;
private float m_DragSpeed = 20.0f; // private float m_DragSpeed = 20.0f;
private float m_DragRotation; // private float m_DragRotation;
private Vector3 m_ShowRotation = Vector3.zero; // private Vector3 m_ShowRotation = Vector3.zero;
private Transform view; // private Transform view;
//
public void SetObject(GameObject obj) // public void SetObject(GameObject obj)
{ // {
m_dragObject = obj; // m_dragObject = obj;
m_ShowRotation = obj.transform.eulerAngles; // m_ShowRotation = obj.transform.eulerAngles;
view = obj.GetComponent<Transform>(); // view = obj.GetComponent<Transform>();
} // }
//
public void Disopose() // public void Disopose()
{ // {
m_dragObject = null; // m_dragObject = null;
view = null; // view = null;
} // }
//
//拖拽 // //拖拽
public void OnDrag(PointerEventData eventData) // public void OnDrag(PointerEventData eventData)
{ // {
if (!m_CanDrag) return; // if (!m_CanDrag) return;
if (!view) return; // if (!view) return;
if (!m_dragObject || !(m_DragSpeed > 0.0f)) return; // if (!m_dragObject || !(m_DragSpeed > 0.0f)) return;
//
var delta = eventData.delta.x; // var delta = eventData.delta.x;
var deltaRot = -m_DragSpeed * delta * Time.deltaTime; // var deltaRot = -m_DragSpeed * delta * Time.deltaTime;
//
m_DragRotation += deltaRot; // m_DragRotation += deltaRot;
var showRotation = Quaternion.Euler(m_ShowRotation); // var showRotation = Quaternion.Euler(m_ShowRotation);
var showUp = showRotation * Vector3.up; // var showUp = showRotation * Vector3.up;
showRotation *= Quaternion.AngleAxis(m_DragRotation, showUp); // showRotation *= Quaternion.AngleAxis(m_DragRotation, showUp);
view.rotation = showRotation; // view.rotation = showRotation;
} // }
//
//按下 // //按下
public void OnPointerDown(PointerEventData eventData) // public void OnPointerDown(PointerEventData eventData)
{ // {
} // }
//
//抬起 // //抬起
public void OnPointerUp(PointerEventData eventData) // public void OnPointerUp(PointerEventData eventData)
{ // {
} // }
} // }
} // }

View File

@ -1,108 +1,109 @@
using System; // using System;
using Sirenix.OdinInspector; // using Sirenix.OdinInspector;
using UnityEngine; // using UnityEngine;
using UnityEngine.UI; // using UnityEngine.UI;
//
namespace AlicizaX.UI.Extension // namespace AlicizaX.UI.Extension
{ // {
[RequireComponent(typeof(RawImage))] // [RequireComponent(typeof(RawImage))]
public class UI3DDisplay : MonoBehaviour // public class UI3DDisplay : MonoBehaviour
{ // {
private Camera m_Camera; // private Camera m_Camera;
private GameObject m_ShowObject; // private GameObject m_ShowObject;
private RenderTexture m_ShowTexure; // private RenderTexture m_ShowTexure;
private UI3DDisplayTouch m_UI3DDisplayTouch; // private UI3DDisplayTouch m_UI3DDisplayTouch;
//
private RawImage m_ShowImage; // private RawImage m_ShowImage;
//
[ReadOnly] // [ReadOnly]
[SerializeField] // [SerializeField]
private int m_ResolutionX = 512; // private int m_ResolutionX = 512;
//
[SerializeField] // [SerializeField]
[ReadOnly] // [ReadOnly]
private int m_ResolutionY = 512; // private int m_ResolutionY = 512;
//
private readonly int m_RenderTextureDepthBuffer = 16; // private readonly int m_RenderTextureDepthBuffer = 16;
//
void Awake() // void Awake()
{ // {
m_ShowImage = GetComponent<RawImage>(); // UI3DDisplayHelper.UI3DDisplayHandler = this;
m_UI3DDisplayTouch = GetComponentInChildren<UI3DDisplayTouch>(); // m_ShowImage = GetComponent<RawImage>();
} // m_UI3DDisplayTouch = GetComponentInChildren<UI3DDisplayTouch>();
// }
//
#if UNITY_EDITOR //
// #if UNITY_EDITOR
//
[SerializeField] [Header("分辨率")] [OnValueChanged("OnEditResolutionChanged")] //
private int EditResolution = 512; // [SerializeField] [Header("分辨率")] [OnValueChanged("OnEditResolutionChanged")]
// private int EditResolution = 512;
private void OnEditResolutionChanged() //
{ // private void OnEditResolutionChanged()
if (!getPlayingState) return; // {
m_ResolutionX = EditResolution; // if (!getPlayingState) return;
m_ResolutionY = EditResolution; // m_ResolutionX = EditResolution;
var rect = transform.GetComponent<RectTransform>(); // m_ResolutionY = EditResolution;
if (Math.Abs(rect.sizeDelta.x - m_ResolutionX) > 0.01f || // var rect = transform.GetComponent<RectTransform>();
Math.Abs(rect.sizeDelta.y - m_ResolutionY) > 0.01f) // if (Math.Abs(rect.sizeDelta.x - m_ResolutionX) > 0.01f ||
rect.sizeDelta = new Vector2(m_ResolutionX, m_ResolutionY); // Math.Abs(rect.sizeDelta.y - m_ResolutionY) > 0.01f)
} // rect.sizeDelta = new Vector2(m_ResolutionX, m_ResolutionY);
// }
//
[ShowIf("getPlayingState")] [SerializeField] //
GameObject previewPrefab; // [ShowIf("getPlayingState")] [SerializeField]
// GameObject previewPrefab;
[ShowIf("getPlayingState")] [SerializeField] //
Camera previewCamera; // [ShowIf("getPlayingState")] [SerializeField]
// Camera previewCamera;
bool getPlayingState => !Application.isPlaying; //
// bool getPlayingState => !Application.isPlaying;
[Sirenix.OdinInspector.Button("预览")] //
private void Preview() // [Sirenix.OdinInspector.Button("预览")]
{ // private void Preview()
if (m_ShowObject != null) // {
{ // if (m_ShowObject != null)
UnityEngine.Object.DestroyImmediate(m_ShowObject); // {
} // UnityEngine.Object.DestroyImmediate(m_ShowObject);
// }
m_ShowObject = UnityEngine.Object.Instantiate(previewPrefab); //
m_Camera = previewCamera; // m_ShowObject = UnityEngine.Object.Instantiate(previewPrefab);
if (m_ShowTexure != null) // m_Camera = previewCamera;
{ // if (m_ShowTexure != null)
RenderTexture.ReleaseTemporary(m_ShowTexure); // {
} // RenderTexture.ReleaseTemporary(m_ShowTexure);
// }
m_ShowTexure = RenderTexture.GetTemporary(m_ResolutionX, m_ResolutionY, m_RenderTextureDepthBuffer); //
// m_ShowTexure = RenderTexture.GetTemporary(m_ResolutionX, m_ResolutionY, m_RenderTextureDepthBuffer);
// m_ShowObject.SetLayerRecursively(LayerDefine.UI3DObject); // m_ShowObject.SetLayerRecursively(LayerDefine.UI3DObject);
m_Camera.targetTexture = m_ShowTexure; // m_Camera.targetTexture = m_ShowTexure;
GetComponent<RawImage>().texture = m_ShowTexure; // GetComponent<RawImage>().texture = m_ShowTexure;
} // }
#endif // #endif
//
public void SetUp(GameObject obj) // public void SetUp(GameObject obj)
{ // {
m_ShowObject = obj; // m_ShowObject = obj;
// m_Camera = CameraManaer.Instance.UI3DRenderCamera; // m_Camera = CameraManaer.Instance.UI3DRenderCamera;
if (m_ShowTexure != null) // if (m_ShowTexure != null)
{ // {
RenderTexture.ReleaseTemporary(m_ShowTexure); // RenderTexture.ReleaseTemporary(m_ShowTexure);
} // }
//
m_ShowTexure = RenderTexture.GetTemporary(m_ResolutionX, m_ResolutionY, m_RenderTextureDepthBuffer); // m_ShowTexure = RenderTexture.GetTemporary(m_ResolutionX, m_ResolutionY, m_RenderTextureDepthBuffer);
// m_ShowObject.SetLayerRecursively(LayerDefine.UI3DObject); // m_ShowObject.SetLayerRecursively(LayerDefine.UI3DObject);
m_Camera.targetTexture = m_ShowTexure; // m_Camera.targetTexture = m_ShowTexure;
m_ShowImage.texture = m_ShowTexure; // m_ShowImage.texture = m_ShowTexure;
m_UI3DDisplayTouch.SetObject(m_ShowObject); // m_UI3DDisplayTouch.SetObject(m_ShowObject);
} // }
//
void OnDestroy() // void OnDestroy()
{ // {
m_UI3DDisplayTouch.Disopose(); // m_UI3DDisplayTouch.Disopose();
if (m_ShowTexure != null) // if (m_ShowTexure != null)
{ // {
RenderTexture.ReleaseTemporary(m_ShowTexure); // RenderTexture.ReleaseTemporary(m_ShowTexure);
} // }
} // }
} // }
} // }