This commit is contained in:
李浩 2025-05-13 08:52:09 +08:00
commit 87033ec8df
8 changed files with 87 additions and 29 deletions

View File

@ -700,7 +700,12 @@ public class ScreenShotPainter : MonoBehaviour
RectFactory(); RectFactory();
break; break;
case Status.Circle: case Status.Circle:
var dis = Vector2.Distance(_lastPoint, Input.mousePosition) * 2; Vector2 last;
Vector2 mouse;
RectTransformUtility.ScreenPointToLocalPointInRectangle(circleImg.rectTransform.parent as RectTransform, _lastPoint, null, out last);
RectTransformUtility.ScreenPointToLocalPointInRectangle(circleImg.rectTransform.parent as RectTransform, Input.mousePosition, null, out mouse);
var dis = Vector2.Distance(last, mouse) * 2;
circleImg.rectTransform.sizeDelta = new Vector2(dis, dis); circleImg.rectTransform.sizeDelta = new Vector2(dis, dis);
break; break;
case Status.Arrow: case Status.Arrow:
@ -821,7 +826,7 @@ public class ScreenShotPainter : MonoBehaviour
{ {
if (lineStart != default) if (lineStart != default)
{ {
var points = GenerateArrowPoints(lineStart, Input.mousePosition,0.1f); var points = GenerateArrowPoints(lineStart, Input.mousePosition, 0.1f);
_lastPoint = lineStart; _lastPoint = lineStart;
Paint(_eraserFlag, lineStart); Paint(_eraserFlag, lineStart);
LerpPaint(Input.mousePosition, _eraserFlag); LerpPaint(Input.mousePosition, _eraserFlag);
@ -1038,10 +1043,6 @@ public class ScreenShotPainter : MonoBehaviour
yield return new WaitForEndOfFrame(); yield return new WaitForEndOfFrame();
float width = _rightUpConnerPoint.x - _leftDownConnerPoint.x; float width = _rightUpConnerPoint.x - _leftDownConnerPoint.x;
float height = _rightUpConnerPoint.y - _leftDownConnerPoint.y; float height = _rightUpConnerPoint.y - _leftDownConnerPoint.y;
Debug.Log(_leftDownConnerPoint.x.ToString("0.00"));
Debug.Log(_leftDownConnerPoint.y.ToString("0.00"));
Debug.Log("width:" + width);
Debug.Log("width:" + height);
Rect rect = new Rect(_leftDownConnerPoint.x, _leftDownConnerPoint.y, width, height); //坑爹啊 如果是开携程在WaitForEndOfFrame时候截图那么他的坐标系换了。。rect起始点要设置在左下角 Rect rect = new Rect(_leftDownConnerPoint.x, _leftDownConnerPoint.y, width, height); //坑爹啊 如果是开携程在WaitForEndOfFrame时候截图那么他的坐标系换了。。rect起始点要设置在左下角

View File

@ -213,6 +213,12 @@ public class Body3DController : MonoSingleton<Body3DController>
{ {
Parser(item.Value); Parser(item.Value);
} }
if (body.isLineModeItem)
{
GameObject obj = Utility.FindObj(body.Path);
obj.GetOrAddComponent<LineModeItem>().Init(body);
}
} }
else else
{ {
@ -221,6 +227,7 @@ public class Body3DController : MonoSingleton<Body3DController>
//if (obj != null) { Debug.Log("????" + body.Path + "????"); }; //if (obj != null) { Debug.Log("????" + body.Path + "????"); };
var bodyObjItem = obj.GetOrAddComponent<Body3DObjItem>(); var bodyObjItem = obj.GetOrAddComponent<Body3DObjItem>();
bodyObjItem.Init(body); bodyObjItem.Init(body);
var lineModeItem = obj.GetOrAddComponent<LineModeItem>().Init(body);
objs.Add(obj, bodyObjItem); objs.Add(obj, bodyObjItem);
} }
} }

View File

@ -19,12 +19,10 @@ public class Body3DObjItem : MonoBehaviour
private float lastClickTime; private float lastClickTime;
// 双击的时间间隔阈值 // 双击的时间间隔阈值
private const float doubleClickTimeThreshold = 0.3f; private const float doubleClickTimeThreshold = 0.3f;
Shader shader;
private void Awake() private void Awake()
{ {
shader = GetComponent<Renderer>()?.material.shader;
TypeEventSystem.Global.Register<OnChangeMat>(OnChangeMatEvent).UnRegisterWhenGameObjectDestroyed(this);
#if VR #if VR
#if Turing #if Turing
@ -75,25 +73,11 @@ public class Body3DObjItem : MonoBehaviour
} }
} }
#endif #endif
private void OnChangeMatEvent(OnChangeMat t)
{
if (t.shader != null)
{
GetComponent<Renderer>().material.shader = t.shader;
}
else
{
GetComponent<Renderer>().material.shader = this.shader;
}
}
public void Init(Body3D.Body body) public void Init(Body3D.Body body)
{ {
this.body = body; this.body = body;
if (body.subBody == null || body.subBody.Count == 0) if (body.subBody == null || body.subBody.Count == 0)
{ {
if (body.toggle != null) if (body.toggle != null)

View File

@ -0,0 +1,38 @@
using QFramework;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XMLTool;
public class LineModeItem : MonoBehaviour
{
Shader shader;
public Body3D.Body body;
public LineModeItem Init(Body3D.Body body)
{
this.body = body;
shader = GetComponent<Renderer>()?.material.shader;
TypeEventSystem.Global.Register<OnChangeMat>(OnChangeMatEvent).UnRegisterWhenGameObjectDestroyed(this);
return this;
}
private void OnChangeMatEvent(OnChangeMat t)
{
if (t.shader != null)
{
GetComponent<Renderer>().material.shader = t.shader;
if (body.lineModeWidth != 0)
{
GetComponent<Renderer>().material.SetFloat("_OutlineWidth", body.lineModeWidth);
}
}
else
{
GetComponent<Renderer>().material.shader = this.shader;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c29f8a68d4de741499c43ccf8a9d6bf0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -18,7 +18,8 @@ public class ObjectColorToggle : MonoBehaviour
private void Awake() private void Awake()
{ {
mesh = gameObject.GetComponent<MeshRenderer>(); mesh = gameObject.GetComponent<MeshRenderer>();
isOffColor = mesh.material.color; isOffColor = mesh.material.color;
savedTexture = mesh.material.mainTexture as Texture2D;
} }
public void SetColor(State state) public void SetColor(State state)
@ -28,7 +29,6 @@ public class ObjectColorToggle : MonoBehaviour
{ {
case State.On: case State.On:
isOnColor.a = alpha; isOnColor.a = alpha;
savedTexture = mesh.material.mainTexture as Texture2D;
mesh.material.mainTexture = null; mesh.material.mainTexture = null;
mesh.material.color = isOnColor; mesh.material.color = isOnColor;
break; break;
@ -39,7 +39,6 @@ public class ObjectColorToggle : MonoBehaviour
break; break;
case State.Hover: case State.Hover:
isHoverColor.a = alpha; isHoverColor.a = alpha;
savedTexture = mesh.material.mainTexture as Texture2D;
mesh.material.mainTexture = null; mesh.material.mainTexture = null;
mesh.material.color = isHoverColor; mesh.material.color = isHoverColor;
break; break;

View File

@ -186,6 +186,8 @@ namespace XMLTool
public Dictionary<string, Body> subBody { get; set; } = new Dictionary<string, Body>(); public Dictionary<string, Body> subBody { get; set; } = new Dictionary<string, Body>();
public Body parent; public Body parent;
public float lineModeWidth = 0;
public bool isLineModeItem = false;
//public Dictionary<string, Body> bodyList { get; set; } = new Dictionary<string, Body>(); //public Dictionary<string, Body> bodyList { get; set; } = new Dictionary<string, Body>();
} }
@ -440,6 +442,20 @@ namespace XMLTool
body.subBody.Add(subBody.Name, subBody); body.subBody.Add(subBody.Name, subBody);
} }
body.parent = parent; body.parent = parent;
var lineModeWidth = bodyElement.Attribute("lineModeWidth");
if (lineModeWidth != null)
{
float.TryParse(lineModeWidth.Value, out body.lineModeWidth);
}
var isLineModeItem = bodyElement.Attribute("isLineModeItem");
if (isLineModeItem != null)
{
bool.TryParse(isLineModeItem.Value, out body.isLineModeItem);
}
return body; return body;
} }

View File

@ -11432,7 +11432,7 @@
<Body name="下呼吸道" tip="" path="Ren_NEW/SM_QiGuan/Respiratory_system/Lower_respiratory_tract"> <Body name="下呼吸道" tip="" path="Ren_NEW/SM_QiGuan/Respiratory_system/Lower_respiratory_tract">
<Body name="气管" tip="" path="Ren_NEW/SM_QiGuan/Respiratory_system/Lower_respiratory_tract/Trachea"> <Body name="气管" tip="" path="Ren_NEW/SM_QiGuan/Respiratory_system/Lower_respiratory_tract/Trachea" isLineModeItem="true">
<Body name="气管软骨环" englishName="Cartilaginous rings of trachea" tip="范围:喉以下部分,包括气管、支气管及肺内分支。 <Body name="气管软骨环" englishName="Cartilaginous rings of trachea" tip="范围:喉以下部分,包括气管、支气管及肺内分支。
功能:气体交换通道,纤毛清除异物。 功能:气体交换通道,纤毛清除异物。
@ -12198,7 +12198,9 @@
</Body> </Body>
<Body name="胸内侧神经" englishName="Medial pectoral (C08,T01)" tip="胸内侧神经:发自臂丛内侧束,常与胸外侧神经分支联合,分布于胸小肌和部分胸大肌的神经。" path="Ren_NEW/SM_ShenJing/SM_nerve/SM_brachial_plexus/SM_left_brachial_plexus_and_its_branches/SM_branches_of_left_subclavian/SM_branches_of_left_medial_cord/XiongNeiCeShenJing"> <Body name="胸内侧神经" englishName="Medial pectoral (C08,T01)" tip="胸内侧神经:发自臂丛内侧束,常与胸外侧神经分支联合,分布于胸小肌和部分胸大肌的神经。" path="Ren_NEW/SM_ShenJing/SM_nerve/SM_brachial_plexus/SM_left_brachial_plexus_and_its_branches/SM_branches_of_left_subclavian/SM_branches_of_left_medial_cord/XiongNeiCeShenJing"
lineModeWidth="0.000003"
>