回调,父物体null

This commit is contained in:
陈向学 2024-08-26 09:31:31 +08:00
parent 20c3de29d0
commit 51bdb22652
5 changed files with 27 additions and 1 deletions

View File

@ -1,3 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@ -8,6 +9,10 @@ public class Device_Base : PermanentTriggerBase
/// 设备类型
/// </summary>
public DeviceType deviceType;
/// <summary>
/// trigger触发事件
/// </summary>
private Action<string> triggerAction;
protected override void OnStart()
{
@ -33,4 +38,9 @@ public class Device_Base : PermanentTriggerBase
_highlight.SetHighlighted(false);
}
}
public void AddTriggerAction(Action<string> action)
{
this.triggerAction = action;
}
}

View File

@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
/// <summary>
/// 묏야꼼죕샘잚
@ -12,6 +13,11 @@ public class Tool_Base : PermanentTriggerBase
/// </summary>
public ToolType toolType;
/// <summary>
/// trigger触发事件
/// </summary>
private Action<string> triggerAction;
protected override void OnStart()
{
if ( GameManager.RunModelMgr.SceneType == E_SceneType.Site)
@ -36,4 +42,9 @@ public class Tool_Base : PermanentTriggerBase
_highlight.SetHighlighted(false);
}
}
public void AddTriggerAction(Action<string> action)
{
this.triggerAction = action;
}
}

View File

@ -66,6 +66,7 @@ public class Tool_Screw : Tool_Base
isMoving = true;
Debug.Log("开始拧紧螺丝");
//设置螺丝刀初始位置
screwdriver.transform.parent = null;
screwdriver.transform.position = installPos.position;
screwdriver.transform.localEulerAngles = installPos.localEulerAngles;
//动画
@ -97,6 +98,7 @@ public class Tool_Screw : Tool_Base
isMoving = true;
Debug.Log("开始卸螺丝");
//设置螺丝刀初始位置
screwdriver.transform.parent = null;
screwdriver.transform.position = installPos.position;
screwdriver.transform.localEulerAngles = installPos.localEulerAngles;
//动画

View File

@ -1,7 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static Unity.Burst.Intrinsics.X86.Avx;
/// <summary>
/// 验电笔
@ -75,6 +74,7 @@ public class Tool_TestPen : Tool_Base
{
var tmp = ((Device_Socket)device_base);
//位置移动
transform.parent = null;
transform.position = tmp.testPosAndRot.position;
transform.eulerAngles = tmp.testPosAndRot.eulerAngles;
Debug.Log("计量柜_插座 已验电");
@ -86,6 +86,7 @@ public class Tool_TestPen : Tool_Base
var tmp = ((Device_CabinetDoor)device_base);
//位置移动
transform.parent = null;
transform.position = tmp.testPosAndRot.position;
transform.localEulerAngles = tmp.testPosAndRot.localEulerAngles;
Debug.Log("计量柜_柜门 已验电");
@ -106,6 +107,7 @@ public class Tool_TestPen : Tool_Base
{
var tmp = ((Tool_Screw)tool_base);
//位置移动
transform.parent = null;
transform.position = tmp.installPos.position;
transform.localEulerAngles = tmp.installPos.localEulerAngles;
Debug.Log("螺丝 已验电");

View File

@ -14,6 +14,7 @@ public class Tool_WireStripper : Tool_Base
/// <param name="device_Seal"></param>
public void CutOpen(Device_Seal device_Seal)
{
transform.parent = null;
transform.position = device_Seal.testPosAndRot.position;
transform.eulerAngles = device_Seal.testPosAndRot.eulerAngles;
//播放动画