Merge branch 'sjm/250326' into sjm/250331
# Conflicts: # Assets/Scenes/0.22.7.unity
This commit is contained in:
1338
Assets/Prefabs/UI/Panel_ObjectDistance.prefab
Normal file
1338
Assets/Prefabs/UI/Panel_ObjectDistance.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Prefabs/UI/Panel_ObjectDistance.prefab.meta
Normal file
7
Assets/Prefabs/UI/Panel_ObjectDistance.prefab.meta
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e34354bad51342e4ca9569fd37c9b8dd
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
88
Assets/Resources/Prefabs/PRF_ObjectDistanceLine.prefab
Normal file
88
Assets/Resources/Prefabs/PRF_ObjectDistanceLine.prefab
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &5879261464688472025
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 5472984000651998200}
|
||||||
|
- component: {fileID: 9157913964040327910}
|
||||||
|
- component: {fileID: 1305656563587261426}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: PRF_ObjectDistanceLine
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &5472984000651998200
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 5879261464688472025}
|
||||||
|
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: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!33 &9157913964040327910
|
||||||
|
MeshFilter:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 5879261464688472025}
|
||||||
|
m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
--- !u!23 &1305656563587261426
|
||||||
|
MeshRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 5879261464688472025}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 0
|
||||||
|
m_ReceiveShadows: 1
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_StaticShadowCaster: 0
|
||||||
|
m_MotionVectors: 1
|
||||||
|
m_LightProbeUsage: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 2
|
||||||
|
m_RayTraceProcedural: 0
|
||||||
|
m_RayTracingAccelStructBuildFlagsOverride: 0
|
||||||
|
m_RayTracingAccelStructBuildFlags: 1
|
||||||
|
m_SmallMeshCulling: 1
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 2100000, guid: 4f1ef37ae953c484bbc5d5e4049147e5, type: 2}
|
||||||
|
m_StaticBatchInfo:
|
||||||
|
firstSubMesh: 0
|
||||||
|
subMeshCount: 0
|
||||||
|
m_StaticBatchRoot: {fileID: 0}
|
||||||
|
m_ProbeAnchor: {fileID: 0}
|
||||||
|
m_LightProbeVolumeOverride: {fileID: 0}
|
||||||
|
m_ScaleInLightmap: 1
|
||||||
|
m_ReceiveGI: 1
|
||||||
|
m_PreserveUVs: 0
|
||||||
|
m_IgnoreNormalsForChartDetection: 0
|
||||||
|
m_ImportantGI: 0
|
||||||
|
m_StitchLightmapSeams: 1
|
||||||
|
m_SelectedEditorRenderState: 3
|
||||||
|
m_MinimumChartSize: 4
|
||||||
|
m_AutoUVMaxDistance: 0.5
|
||||||
|
m_AutoUVMaxAngle: 89
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 0
|
||||||
|
m_AdditionalVertexStreams: {fileID: 0}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 06e21ad3a6d17614a8d74d9cc974d7f9
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using System.Linq;
|
using XED.UI;
|
||||||
|
using static UnityEditor.ShaderGraph.Internal.KeywordDependentCollection;
|
||||||
|
|
||||||
namespace XED.Util
|
namespace XED.Util
|
||||||
{
|
{
|
||||||
@@ -24,6 +26,8 @@ namespace XED.Util
|
|||||||
public bool isCollided = false;
|
public bool isCollided = false;
|
||||||
private float zFightingOffset = 1.0001f;
|
private float zFightingOffset = 1.0001f;
|
||||||
|
|
||||||
|
LayerMask twinObjectMask;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
objectRenderer = GetComponentInChildren<MeshRenderer>();
|
objectRenderer = GetComponentInChildren<MeshRenderer>();
|
||||||
@@ -32,6 +36,9 @@ namespace XED.Util
|
|||||||
matCubeShow = Resources.Load<Material>("Materials/Mat_CubeShow");
|
matCubeShow = Resources.Load<Material>("Materials/Mat_CubeShow");
|
||||||
matCubeSelected = Resources.Load<Material>("Materials/Mat_CubeSelected");
|
matCubeSelected = Resources.Load<Material>("Materials/Mat_CubeSelected");
|
||||||
matCubeCollided = Resources.Load<Material>("Materials/Mat_CubeCollided");
|
matCubeCollided = Resources.Load<Material>("Materials/Mat_CubeCollided");
|
||||||
|
|
||||||
|
boxCollider.gameObject.layer = LayerMask.NameToLayer("TwinObject");
|
||||||
|
twinObjectMask = LayerMask.GetMask("TwinObject");
|
||||||
}
|
}
|
||||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||||
void Start()
|
void Start()
|
||||||
@@ -174,6 +181,7 @@ namespace XED.Util
|
|||||||
public void Select()
|
public void Select()
|
||||||
{
|
{
|
||||||
//ResizeBoundary();
|
//ResizeBoundary();
|
||||||
|
FindSingle<Panel_ObjectDistance>().SelectObjectFromCreate(this);
|
||||||
isSelected = true;
|
isSelected = true;
|
||||||
objectRenderer.material = matCubeSelected;
|
objectRenderer.material = matCubeSelected;
|
||||||
Show();
|
Show();
|
||||||
@@ -230,5 +238,14 @@ namespace XED.Util
|
|||||||
if (renderObject == null) return null;
|
if (renderObject == null) return null;
|
||||||
return new KDTree(renderObject);
|
return new KDTree(renderObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RaycastHit GetObjectHit(Vector3 direction)
|
||||||
|
{
|
||||||
|
RaycastHit hitInfo;
|
||||||
|
Vector3 changedScale = Vector3.Scale(boxCollider.size, transform.lossyScale);
|
||||||
|
Physics.BoxCast(boxCollider.bounds.center, changedScale / 2.0f, direction, out hitInfo, transform.rotation, Mathf.Infinity, twinObjectMask);
|
||||||
|
|
||||||
|
return hitInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,6 +49,7 @@ namespace XED.Manage
|
|||||||
customAssetConnector.onSelectObjects += ((name, objects) => { canvas_Popup.panel_objectinfo.gameObject.SetActive(true); });
|
customAssetConnector.onSelectObjects += ((name, objects) => { canvas_Popup.panel_objectinfo.gameObject.SetActive(true); });
|
||||||
//customAssetConnector.onSelectObjects += ((name, objects) => { canvas_Popup.panel_objectalign.gameObject.SetActive(true); });
|
//customAssetConnector.onSelectObjects += ((name, objects) => { canvas_Popup.panel_objectalign.gameObject.SetActive(true); });
|
||||||
customAssetConnector.onSelectObjects += canvas_Popup.panel_objectinfo.SetObjectInfo;
|
customAssetConnector.onSelectObjects += canvas_Popup.panel_objectinfo.SetObjectInfo;
|
||||||
|
customAssetConnector.onSelectObjects += canvas_Popup.panel_objectdistance.SelectObjectFromClick;
|
||||||
customAssetConnector.onRemoveObjects += canvas_Popup.panel_objectinfo.ResetObjectInfo;
|
customAssetConnector.onRemoveObjects += canvas_Popup.panel_objectinfo.ResetObjectInfo;
|
||||||
customAssetConnector.onDeselectObjects += (() => { canvas_Popup.panel_objectinfo.gameObject.SetActive(false); });
|
customAssetConnector.onDeselectObjects += (() => { canvas_Popup.panel_objectinfo.gameObject.SetActive(false); });
|
||||||
//customAssetConnector.onDeselectObjects += (() => { canvas_Popup.panel_objectalign.gameObject.SetActive(false); });
|
//customAssetConnector.onDeselectObjects += (() => { canvas_Popup.panel_objectalign.gameObject.SetActive(false); });
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using XED.Attributes;
|
using XED.Attributes;
|
||||||
using XED.UI;
|
using XED.UI;
|
||||||
@@ -32,6 +31,7 @@ namespace XED
|
|||||||
|
|
||||||
panel_InterferedObjectList = FindSingle<Panel_InterferedObjectList>();
|
panel_InterferedObjectList = FindSingle<Panel_InterferedObjectList>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Binding(IEntity entity)
|
public void Binding(IEntity entity)
|
||||||
{
|
{
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
@@ -80,6 +80,5 @@ namespace XED
|
|||||||
|
|
||||||
panel_InterferedObjectList.RemoveContentButton(this, contracter);
|
panel_InterferedObjectList.RemoveContentButton(this, contracter);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,6 +26,7 @@ namespace XED
|
|||||||
public Panel_DragHandler panel_draghandler;
|
public Panel_DragHandler panel_draghandler;
|
||||||
public Panel_AssetEdit panel_assetedit;
|
public Panel_AssetEdit panel_assetedit;
|
||||||
public Panel_Thumbnail panel_thumbnail;
|
public Panel_Thumbnail panel_thumbnail;
|
||||||
|
public Panel_ObjectDistance panel_objectdistance;
|
||||||
|
|
||||||
public override void AfterAwake()
|
public override void AfterAwake()
|
||||||
{
|
{
|
||||||
|
|||||||
124
Assets/Scripts/Studio/UI/Panel/Panel_ObjectDistance.cs
Normal file
124
Assets/Scripts/Studio/UI/Panel/Panel_ObjectDistance.cs
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using XED.Util;
|
||||||
|
using XRLib;
|
||||||
|
using XRLib.UI;
|
||||||
|
|
||||||
|
namespace XED.UI
|
||||||
|
{
|
||||||
|
public class Panel_ObjectDistance : PanelBase, ISingle
|
||||||
|
{
|
||||||
|
GameObject linePrefab;
|
||||||
|
|
||||||
|
RectTransform Distance_up;
|
||||||
|
RectTransform Distance_down;
|
||||||
|
RectTransform Distance_left;
|
||||||
|
RectTransform Distance_right;
|
||||||
|
RectTransform Distance_foward;
|
||||||
|
RectTransform Distance_back;
|
||||||
|
|
||||||
|
Dictionary<RectTransform, GameObject> distanceLines = new();
|
||||||
|
[SerializeField]
|
||||||
|
float lineThickness = 1;
|
||||||
|
|
||||||
|
CustomAssetRenderObject selectedObject;
|
||||||
|
|
||||||
|
public override void AfterAwake()
|
||||||
|
{
|
||||||
|
linePrefab = Resources.Load<GameObject>("Prefabs/PRF_ObjectDistanceLine");
|
||||||
|
|
||||||
|
distanceLines.Add(Distance_up, Instantiate(linePrefab));
|
||||||
|
distanceLines.Add(Distance_down, Instantiate(linePrefab));
|
||||||
|
distanceLines.Add(Distance_left, Instantiate(linePrefab));
|
||||||
|
distanceLines.Add(Distance_right, Instantiate(linePrefab));
|
||||||
|
distanceLines.Add(Distance_foward, Instantiate(linePrefab));
|
||||||
|
distanceLines.Add(Distance_back, Instantiate(linePrefab));
|
||||||
|
|
||||||
|
DeactivateAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
if (selectedObject == null || selectedObject.isCollided)
|
||||||
|
{
|
||||||
|
DeactivateAll();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateDistance(Distance_up, Vector3.up);
|
||||||
|
UpdateDistance(Distance_down, Vector3.down);
|
||||||
|
UpdateDistance(Distance_left, Vector3.left);
|
||||||
|
UpdateDistance(Distance_right, Vector3.right);
|
||||||
|
UpdateDistance(Distance_foward, Vector3.forward);
|
||||||
|
UpdateDistance(Distance_back, Vector3.back);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SelectObjectFromCreate(CustomAssetRenderObject obj)
|
||||||
|
{
|
||||||
|
selectedObject = obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SelectObjectFromClick(string name, List<GameObject> objects)
|
||||||
|
{
|
||||||
|
if (objects.Count != 1)
|
||||||
|
{
|
||||||
|
selectedObject = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
selectedObject = objects[0].GetComponent<CustomAssetRenderObject>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeactivateAll()
|
||||||
|
{
|
||||||
|
foreach (var rect in distanceLines.Keys)
|
||||||
|
{
|
||||||
|
rect.gameObject.SetActive(false);
|
||||||
|
distanceLines[rect].gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateDistance(RectTransform rect, Vector3 direction)
|
||||||
|
{
|
||||||
|
RaycastHit hit = selectedObject.GetObjectHit(direction);
|
||||||
|
|
||||||
|
if (hit.collider != null)
|
||||||
|
{
|
||||||
|
float distance = hit.distance;
|
||||||
|
rect.GetComponentInChildren<TextMeshProUGUI>().text = distance.ToString("F2");
|
||||||
|
|
||||||
|
Vector3 hitPoint = hit.point;
|
||||||
|
Vector3 distanceCenterPoint = hitPoint - (direction * distance / 2);
|
||||||
|
Vector3 screenPoint = Camera.main.WorldToScreenPoint(distanceCenterPoint);
|
||||||
|
rect.transform.position = screenPoint;
|
||||||
|
if (screenPoint.z > 0)
|
||||||
|
{
|
||||||
|
rect.gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rect.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
SetLineLength(distanceLines[rect], distanceCenterPoint, direction, distance);
|
||||||
|
distanceLines[rect].SetActive(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rect.gameObject.SetActive(false);
|
||||||
|
distanceLines[rect].SetActive(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetLineLength(GameObject line, Vector3 centerPoint, Vector3 direction, float length)
|
||||||
|
{
|
||||||
|
line.transform.position = centerPoint;
|
||||||
|
line.transform.rotation = Quaternion.LookRotation(direction) * Quaternion.Euler(new Vector3(90, 0, 0));
|
||||||
|
line.transform.localScale = new Vector3(lineThickness, length / 2, lineThickness);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ba071beb1c8293e49a8b25d46f91a7bf
|
||||||
@@ -149,7 +149,6 @@ namespace XED.UI
|
|||||||
{
|
{
|
||||||
if (dir == ResizeDirection.None)
|
if (dir == ResizeDirection.None)
|
||||||
{
|
{
|
||||||
Debug.Log("None");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ TagManager:
|
|||||||
- Voxel
|
- Voxel
|
||||||
- obstacle
|
- obstacle
|
||||||
- objectSnap
|
- objectSnap
|
||||||
-
|
- TwinObject
|
||||||
-
|
-
|
||||||
-
|
-
|
||||||
-
|
-
|
||||||
|
|||||||
Reference in New Issue
Block a user