Przeglądaj źródła

【自由模式螺丝拆除】

CHIVA\bj 5 miesięcy temu
rodzic
commit
d8a564e50e
12 zmienionych plików z 851 dodań i 22 usunięć
  1. 1 0
      Framework/SimulationToolDev/AnimationDriver/AnimationDriver-Example/ToolAnimationItem/ToolAnimationGroup/ToolAni_BanShou.cs
  2. 1 1
      Framework/SimulationToolDev/CVR_Interactable/Example/Scripts/OperationData-Example/OPTrigger_SelectToolElemet.cs
  3. 18 0
      Framework/SimulationToolDev/OperationDriver/OperationData-Example/TriggerMode/OpTrigger_Toolbackpack/IndependentAniBase.cs
  4. 11 0
      Framework/SimulationToolDev/OperationDriver/OperationData-Example/TriggerMode/OpTrigger_Toolbackpack/IndependentAniBase.cs.meta
  5. 8 0
      Framework/SimulationToolDev/OperationDriver/OperationData-Example/TriggerMode/OpTrigger_Toolbackpack/IndependentAniGroup.meta
  6. 369 0
      Framework/SimulationToolDev/OperationDriver/OperationData-Example/TriggerMode/OpTrigger_Toolbackpack/IndependentAniGroup/IndependentAni_BanShou.cs
  7. 11 0
      Framework/SimulationToolDev/OperationDriver/OperationData-Example/TriggerMode/OpTrigger_Toolbackpack/IndependentAniGroup/IndependentAni_BanShou.cs.meta
  8. 27 3
      Framework/SimulationToolDev/OperationDriver/OperationData-Example/TriggerMode/OpTrigger_Toolbackpack/OpTrigger_ToolPack.cs
  9. 392 14
      Framework/SimulationToolDev/OperationDriver/OperationData-Example/TriggerMode/OpTrigger_Toolbackpack/ToolPackInteractive_IndependentAni.cs
  10. 1 1
      OperationUIFrame/OperationUIFrameV2/Scripts/UI/PC_OperatePanel.cs
  11. 1 2
      OperationUIFrame/OperationUIFrameV2/Scripts/UI/ToolLibraryForm.cs
  12. 11 1
      OperationUIFrame/OperationUIFrameV2/Scripts/UI/ToolLibraryForm/ToolLibrarySelectElement.cs

+ 1 - 0
Framework/SimulationToolDev/AnimationDriver/AnimationDriver-Example/ToolAnimationItem/ToolAnimationGroup/ToolAni_BanShou.cs

@@ -69,6 +69,7 @@ public class ToolAni_BanShou : ToolAnimationBase
 
     public void PlayBanShouAnimationByFrame(Transform tmpModel, Transform tmpModelAnchor, Transform tmpToolAnchor, Action finishedCallBack)
     {
+        if (tmpModel == null || tmpModelAnchor == null) return;
         if (isLuoSiRot)
         {
             if (toolAnchorAngle < maxAngle)

+ 1 - 1
Framework/SimulationToolDev/CVR_Interactable/Example/Scripts/OperationData-Example/OPTrigger_SelectToolElemet.cs

@@ -41,7 +41,7 @@ public class OPTrigger_SelectToolElemet : OperationData_TriggerMode
                         selectAction = Check
                     });
                 }
-
+                OperateSetting.Instance.m_CurrentStepRightToolNames = choseToolNames;
                 break;
         }
 

+ 18 - 0
Framework/SimulationToolDev/OperationDriver/OperationData-Example/TriggerMode/OpTrigger_Toolbackpack/IndependentAniBase.cs

@@ -0,0 +1,18 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public abstract class IndependentAniBase
+{
+    public abstract void InitState(ToolPackInteractive_IndependentAni toolAnimationItem, bool reverse);
+    public abstract void FinishedState(ToolPackInteractive_IndependentAni toolAnimationItem, bool reverse);
+    public virtual void OnDrawGizmos(ToolPackInteractive_IndependentAni toolAnimationItem) { }
+    public abstract void PlayTrigger(ToolPackInteractive_IndependentAni toolAnimationItem, bool reverse);
+    public abstract void StopPlay(ToolPackInteractive_IndependentAni toolAnimationItem, bool reverse);
+    public virtual void EditorPlayUpdate(ToolPackInteractive_IndependentAni toolAnimationItem, bool reverse) { }
+    public virtual void PlayUpdate(ToolPackInteractive_IndependentAni toolAnimationItem, bool reverse) { }
+
+    public virtual void PlayByValue(ToolPackInteractive_IndependentAni toolAnimationItem, float value, bool reverse) { }
+
+    public virtual float StopPlayBack(ToolPackInteractive_IndependentAni toolAnimationItem, bool reverse) {  return 0f; }
+}

+ 11 - 0
Framework/SimulationToolDev/OperationDriver/OperationData-Example/TriggerMode/OpTrigger_Toolbackpack/IndependentAniBase.cs.meta

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

+ 8 - 0
Framework/SimulationToolDev/OperationDriver/OperationData-Example/TriggerMode/OpTrigger_Toolbackpack/IndependentAniGroup.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: a0aaf4ede7c1ede40baa22a0f607dd5e
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 369 - 0
Framework/SimulationToolDev/OperationDriver/OperationData-Example/TriggerMode/OpTrigger_Toolbackpack/IndependentAniGroup/IndependentAni_BanShou.cs

@@ -0,0 +1,369 @@
+using ChivaXR;
+using Sirenix.OdinInspector;
+using Sirenix.Utilities;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEditor;
+using UnityEngine;
+
+public class IndependentAni_BanShou : IndependentAniBase
+{
+    #region 扳手交互参数
+
+    [LabelText("相对移动位置")]
+    public Vector3 localMovePos = new Vector3(0, 0, 0);
+    [LabelText("相对旋转角度")]
+    public float rotAngle = 0;
+    [LabelText("扳手单轮角度")]
+    public float maxAngle = 40;
+    [LabelText("运行时长(不包含工具动画)")]
+    public float duration = 1;
+    [LabelText("螺丝抬起高度")]
+    public float moveHigh = 0.02f;
+    [LabelText("共享锚点")]
+    public SimpleMoveItem m_SimpleMoveItem;
+    [InfoBox("开启后,工具会随所有锚点的中心点进行朝向校准,关闭则使用默认朝向")]
+    [LabelText("是否开启工具校准")]
+    public bool m_UseCenterReset = true;
+
+    //工具锚点旋转角度
+    private float toolAnchorAngle = 0;
+    private float timer = 0;
+    private bool isLuoSiRot = true;
+    private float toolHighLerp = 0;
+
+    [HideInInspector]
+    public Transform currentModel;
+    [HideInInspector]
+    public Transform currentModelAnchor;
+    public Transform currentToolAnchor;
+    #endregion
+
+    public override void PlayUpdate(ToolPackInteractive_IndependentAni toolAnimationItem, bool reverse)
+    {
+        if (currentToolAnchor != toolAnimationItem.toolAnchor)
+        {
+            PlayBanShouAnimationByFrame(currentModel, currentModelAnchor, currentToolAnchor, () =>
+            {
+                toolAnimationItem.isPlaying = false;
+                if (currentToolAnchor != null)
+                {
+                    toolAnimationItem.Destroy(currentToolAnchor.gameObject);
+                }
+                toolAnimationItem.CurrentFinished();
+                currentModel.gameObject.SetActive(false);
+            });
+        }
+        else
+        {
+            PlayBanShouAnimationByFrame(toolAnimationItem.model.transform, toolAnimationItem.modelAnchor, toolAnimationItem.toolAnchor,
+            () =>
+            {
+                toolAnimationItem.isPlaying = false;
+                toolAnimationItem.CurrentFinished();
+                currentToolAnchor.gameObject.SetActive(false);
+                currentModel.gameObject.SetActive(false);
+            });
+        }
+    }
+
+    public void PlayBanShouAnimationByFrame(Transform tmpModel, Transform tmpModelAnchor, Transform tmpToolAnchor, Action finishedCallBack)
+    {
+        if (isLuoSiRot)
+        {
+            if (toolAnchorAngle < maxAngle)
+            {
+                timer += Time.deltaTime;
+                toolAnchorAngle += Mathf.Abs(rotAngle) * Time.deltaTime / duration;
+
+                tmpModel.position = Vector3.Lerp(tmpModelAnchor.position, tmpModelAnchor.position + tmpModelAnchor.TransformDirection(localMovePos), timer / duration);
+                tmpModel.rotation = tmpModelAnchor.rotation;
+                tmpModel.RotateAround(tmpModelAnchor.position, tmpModelAnchor.TransformDirection(localMovePos), rotAngle * timer / duration);
+
+                tmpToolAnchor.position = tmpModel.position;
+                tmpToolAnchor.rotation = tmpModelAnchor.rotation;
+                tmpToolAnchor.RotateAround(tmpModelAnchor.position, tmpModelAnchor.TransformDirection(localMovePos), toolAnchorAngle * (rotAngle > 0 ? 1 : -1));
+            }
+            else
+            {
+                toolHighLerp += Time.deltaTime * 5;
+                if (toolHighLerp > 1)
+                {
+                    toolHighLerp = 1;
+                    isLuoSiRot = false;
+                }
+                tmpToolAnchor.position = Vector3.Lerp(tmpModel.position, tmpModel.position + tmpModelAnchor.TransformDirection(localMovePos).normalized * moveHigh, toolHighLerp);
+            }
+        }
+        else //扳手回转
+        {
+            if (toolAnchorAngle >= 0)
+            {
+                toolAnchorAngle -= Mathf.Abs(rotAngle) * Time.deltaTime / duration;
+                tmpToolAnchor.rotation = tmpModelAnchor.transform.rotation;
+                tmpToolAnchor.RotateAround(tmpModelAnchor.position, tmpModelAnchor.TransformDirection(localMovePos), toolAnchorAngle * (rotAngle > 0 ? 1 : -1));
+            }
+            else
+            {
+                toolHighLerp -= Time.deltaTime * 5;
+                if (toolHighLerp < 0)
+                {
+                    toolHighLerp = 0;
+                    isLuoSiRot = true;
+                }
+                tmpToolAnchor.transform.position = Vector3.Lerp(tmpModel.position, tmpModel.position + tmpModelAnchor.TransformDirection(localMovePos).normalized * moveHigh, toolHighLerp);
+            }
+        }
+
+        if (timer > duration)
+        {
+            timer = 0;
+            tmpModel.position = tmpModelAnchor.position;
+            tmpModel.rotation = tmpModelAnchor.rotation;
+            tmpToolAnchor.position = tmpModelAnchor.position;
+            tmpToolAnchor.rotation = tmpModelAnchor.rotation;
+
+            finishedCallBack?.Invoke();
+        }
+    }
+
+    public override void FinishedState(ToolPackInteractive_IndependentAni toolAnimationItem, bool reverse)
+    {
+        toolAnimationItem.toolAnchor.gameObject.SetActive(false);
+        timer = 0;
+        StopPlay(toolAnimationItem, reverse);
+    }
+
+    public override void InitState(ToolPackInteractive_IndependentAni toolAnimationItem, bool reverse)
+    {
+        toolAnimationItem.model.SetActive(true);
+        if (currentModel != null)
+        {
+            currentModel.gameObject.SetActive(true);
+        }
+        if (currentToolAnchor != null)
+        {
+            if (currentToolAnchor == toolAnimationItem.toolAnchor)
+            {
+                currentToolAnchor.gameObject.SetActive(false);
+            }
+            else
+            {
+                toolAnimationItem.Destroy(currentToolAnchor.gameObject);
+            }
+        }
+    }
+
+    public override void PlayTrigger(ToolPackInteractive_IndependentAni toolAnimationItem, bool reverse)
+    {
+        timer = 0;
+        isLuoSiRot = true;
+        toolAnchorAngle = 0;
+
+        if (Application.isPlaying)
+        {
+            if (AnimationManager.Instance.AnimationActiveObj != null)
+            {
+                InitTargetToolAnchor(AnimationManager.Instance.AnimationActiveObj.transform.position, toolAnimationItem);
+            }
+        }
+        else
+        {
+#if UNITY_EDITOR
+            if (Selection.activeGameObject != null)
+            {
+                InitTargetToolAnchor(Selection.activeGameObject.transform.position, toolAnimationItem);
+            }
+            else
+            {
+                InitTargetToolAnchor(toolAnimationItem.modelAnchor.position, toolAnimationItem);
+            }
+#endif
+        }
+    }
+    public override void StopPlay(ToolPackInteractive_IndependentAni toolAnimationItem, bool reverse)
+    {
+        timer = 0;
+        if (currentModel != null)
+        {
+            currentModel.position = currentModelAnchor.position;
+            currentModel.rotation = currentModelAnchor.rotation;
+        }
+        if (currentToolAnchor != null)
+        {
+            currentToolAnchor.position = currentModelAnchor.position;
+            currentToolAnchor.rotation = currentModelAnchor.rotation;
+        }
+
+        if (currentToolAnchor != toolAnimationItem.toolAnchor)
+        {
+            toolAnimationItem.isPlaying = false;
+            if (currentToolAnchor != null)
+            {
+                toolAnimationItem.Destroy(currentToolAnchor.gameObject);
+            }
+            if (Application.isPlaying && currentModel != null)
+            {
+                currentModel.gameObject.SetActive(false);
+            }
+        }
+        else
+        {
+            toolAnimationItem.isPlaying = false;
+            currentToolAnchor.gameObject.SetActive(false);
+            if (Application.isPlaying && currentModel != null)
+            {
+                currentModel.gameObject.SetActive(false);
+            }
+        }
+    }
+
+    public override void PlayByValue(ToolPackInteractive_IndependentAni toolAnimationItem, float value, bool reverse)
+    {
+        base.PlayByValue(toolAnimationItem, value, reverse);
+        timer = value * duration;
+        isLuoSiRot = true;
+        toolAnchorAngle = 0;
+
+        if (Application.isPlaying)
+        {
+            InitTargetToolAnchor(toolAnimationItem.m_CurrentRayCastItem.transform.position, toolAnimationItem);
+        }
+        else
+        {
+#if UNITY_EDITOR
+            if (Selection.activeGameObject != null)
+            {
+                InitTargetToolAnchor(Selection.activeGameObject.transform.position, toolAnimationItem);
+            }
+            else
+            {
+                InitTargetToolAnchor(toolAnimationItem.modelAnchor.position, toolAnimationItem);
+            }
+#endif
+        }
+    }
+
+    public override float StopPlayBack(ToolPackInteractive_IndependentAni toolAnimationItem, bool reverse)
+    {
+        //if (currentModel != null)
+        //{
+        //    currentModel.position = currentModelAnchor.position;
+        //    currentModel.rotation = currentModelAnchor.rotation;
+        //}
+        //if (currentToolAnchor != null)
+        //{
+        //    currentToolAnchor.position = currentModelAnchor.position;
+        //    currentToolAnchor.rotation = currentModelAnchor.rotation;
+        //}
+
+        if (currentToolAnchor != toolAnimationItem.toolAnchor)
+        {
+            toolAnimationItem.isPlaying = false;
+            if (currentToolAnchor != null)
+            {
+                toolAnimationItem.Destroy(currentToolAnchor.gameObject);
+            }
+            if (Application.isPlaying && currentModel != null&& (timer / duration >= 1))
+            {
+                currentModel.gameObject.SetActive(false);
+            }
+        }
+        else
+        {
+            toolAnimationItem.isPlaying = false;
+            currentToolAnchor.gameObject.SetActive(false);
+            if (Application.isPlaying && currentModel != null && (timer / duration >= 1))
+            {
+                currentModel.gameObject.SetActive(false);
+            }
+        }
+
+        return Mathf.Clamp(timer / duration, 0, 1);
+    }
+
+    /// <summary>
+    /// 根据当前CheckPos选择的物体最近的锚点执行动画
+    /// </summary>
+    /// <param name="toolAnimationItem"></param>
+    public void InitTargetToolAnchor(Vector3 CheckPos, ToolPackInteractive_IndependentAni toolAnimationItem)
+    {
+        currentModel = toolAnimationItem.model.transform;
+        currentModelAnchor = toolAnimationItem.modelAnchor;
+        Vector3 centerPoint = Vector3.zero;
+
+        if (m_SimpleMoveItem != null)
+        {
+            foreach (var item in m_SimpleMoveItem.moveObjs)
+            {
+                centerPoint += item.Value.position;
+                if (Vector3.Distance(item.Key.transform.position, currentModel.position) < 0.001f) continue;
+
+                if (Vector3.Distance(CheckPos, currentModelAnchor.position) > Vector3.Distance(CheckPos, item.Value.position))
+                {
+                    currentModelAnchor = item.Value;
+                    currentModel = item.Key.transform;
+                }
+            }
+            centerPoint = centerPoint / m_SimpleMoveItem.moveObjs.Count;
+        }
+
+        if (currentModelAnchor != toolAnimationItem.modelAnchor)
+        {
+            currentToolAnchor = GameObject.Instantiate(toolAnimationItem.toolAnchor);
+            currentToolAnchor.transform.parent = currentModelAnchor;
+            currentToolAnchor.transform.localPosition = Vector3.zero;
+            currentToolAnchor.transform.localRotation = Quaternion.identity;
+            currentToolAnchor.transform.localScale = Vector3.one;
+
+            if (m_UseCenterReset)
+            {
+                float angle = Vector3.Angle(toolAnimationItem.modelAnchor.position - centerPoint, currentModelAnchor.position - centerPoint);
+                Vector3 oldDir = currentModelAnchor.InverseTransformDirection(toolAnimationItem.modelAnchor.position - centerPoint);
+                Vector3 newDir = currentModelAnchor.InverseTransformDirection(currentModelAnchor.position - centerPoint);
+                float a = Vector3.Dot(Vector3.Cross(oldDir, newDir), localMovePos);
+
+                for (int i = 0; i < currentToolAnchor.childCount; i++)
+                {
+                    currentToolAnchor.GetChild(i).RotateAround(currentModelAnchor.position, currentModelAnchor.TransformDirection(localMovePos), angle * (a > 0 ? 1 : -1));
+                    //currentToolAnchor.GetChild(i).Rotate( angle * (a < 0 ? 1 : -1),Space.Self);
+                }
+            }
+        }
+        else
+        {
+            currentToolAnchor = toolAnimationItem.toolAnchor;
+            toolAnimationItem.toolAnchor.gameObject.SetActive(true);
+        }
+        currentToolAnchor.gameObject.SetActive(true);
+    }
+
+#if UNITY_EDITOR
+    public override void EditorPlayUpdate(ToolPackInteractive_IndependentAni toolAnimationItem, bool reverse)
+    {
+        if (currentToolAnchor != toolAnimationItem.toolAnchor)
+        {
+            PlayBanShouAnimationByFrame(currentModel, currentModelAnchor, currentToolAnchor, () =>
+            {
+                toolAnimationItem.isPlaying = false;
+                if (currentToolAnchor != null)
+                {
+                    toolAnimationItem.Destroy(currentToolAnchor.gameObject);
+                }
+            });
+        }
+        else
+        {
+            PlayBanShouAnimationByFrame(toolAnimationItem.model.transform, toolAnimationItem.modelAnchor, toolAnimationItem.toolAnchor,
+            () => { toolAnimationItem.isPlaying = false; });
+        }
+    }
+
+    public override void OnDrawGizmos(ToolPackInteractive_IndependentAni toolAnimationItem)
+    {
+        Gizmos.color = Color.yellow;
+        Gizmos.DrawLine(toolAnimationItem.modelAnchor.position, toolAnimationItem.modelAnchor.position + toolAnimationItem.modelAnchor.TransformDirection(localMovePos));
+    }
+#endif
+}

+ 11 - 0
Framework/SimulationToolDev/OperationDriver/OperationData-Example/TriggerMode/OpTrigger_Toolbackpack/IndependentAniGroup/IndependentAni_BanShou.cs.meta

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

+ 27 - 3
Framework/SimulationToolDev/OperationDriver/OperationData-Example/TriggerMode/OpTrigger_Toolbackpack/OpTrigger_ToolPack.cs

@@ -214,8 +214,9 @@ public class OpTrigger_ToolPack : OperationData_TriggerMode
     public List<string> choseToolNames = new List<string>();
 
     [LabelText("使用特殊触发动画(螺丝类)")]
-    public bool useToolIndependentAni=false;
+    public bool useToolIndependentAni = false;
 
+    private ToolPackInteractive_IndependentAni toolPackInteractive_IndependentAni;
     /// <summary>
     /// 学习模式延迟提示高亮时长
     /// </summary>
@@ -249,6 +250,15 @@ public class OpTrigger_ToolPack : OperationData_TriggerMode
                 }
 
                 SetHighlighterState(false);
+
+                if (OperateSetting.Instance.m_CurrentOperationMode == OperationMode.FreeParctice)
+                {
+                    toolPackInteractive_IndependentAni = this.GetComponent<ToolPackInteractive_IndependentAni>();
+                    if (toolPackInteractive_IndependentAni != null)
+                    {
+                        this.GetComponent<ToolPackInteractive_IndependentAni>().isActive = false;
+                    }
+                }
                 break;
             case OperationDataStatus.Listening:
 
@@ -262,7 +272,14 @@ public class OpTrigger_ToolPack : OperationData_TriggerMode
                 timer = 0;
                 OperateSetting.Instance.m_CurrentStepRightToolNames = choseToolNames;
 
-                //this.GetComponent<ToolPackInteractive_IndependentAni>().Init();
+                if (OperateSetting.Instance.m_CurrentOperationMode == OperationMode.FreeParctice)
+                {
+                    toolPackInteractive_IndependentAni = this.GetComponent<ToolPackInteractive_IndependentAni>();
+                    if (toolPackInteractive_IndependentAni != null)
+                    {
+                        this.GetComponent<ToolPackInteractive_IndependentAni>().Init();
+                    }
+                }
 
                 break;
         }
@@ -291,8 +308,14 @@ public class OpTrigger_ToolPack : OperationData_TriggerMode
         }
 
         SetHighlighterState(false);
-        if (OperateSetting.Instance.m_CurrentOperationMode==OperationMode.FreeParctice)
+        if (OperateSetting.Instance.m_CurrentOperationMode == OperationMode.FreeParctice)
         {
+            #region FreePartice
+            if (toolPackInteractive_IndependentAni != null)
+            {
+                return toolPackInteractive_IndependentAni.IsFinished();
+            }
+
             if (useTool && choseToolNames.Count != 0)
             {
                 if (OperateSetting.Instance.m_ToolKitToolConfigs.Count != choseToolNames.Count)
@@ -353,6 +376,7 @@ public class OpTrigger_ToolPack : OperationData_TriggerMode
             }
 
             return false;
+            #endregion
         }
 
         bool tmpState = OperateSetting.Instance.ToolPackUILogic.GetHint();

+ 392 - 14
Framework/SimulationToolDev/OperationDriver/OperationData-Example/TriggerMode/OpTrigger_Toolbackpack/ToolPackInteractive_IndependentAni.cs

@@ -1,5 +1,9 @@
-using System.Collections;
+using Sirenix.OdinInspector;
+using System;
+using System.Collections;
 using System.Collections.Generic;
+using System.Linq;
+using UnityEditor;
 using UnityEngine;
 
 /// <summary>
@@ -11,11 +15,13 @@ public enum IndependentAniTriigerType
     press
 }
 
+[ExecuteAlways]
+[ExecuteInEditMode]
 [RequireComponent(typeof(OpTrigger_ToolPack))]
 /// <summary>
 /// 工具交互-独立动画控制
 /// </summary>
-public class ToolPackInteractive_IndependentAni : MonoBehaviour
+public class ToolPackInteractive_IndependentAni : SerializedMonoBehaviour
 {
     public IndependentAniTriigerType m_IndependentAniTriigerType = IndependentAniTriigerType.press;
     [HideInInspector]
@@ -32,17 +38,20 @@ public class ToolPackInteractive_IndependentAni : MonoBehaviour
         }
     }
 
-    public SimpleMoveItem m_TargetSimplaeMoveItem;
     public bool isActive;
-    private RayCastItem m_CurrentRayCastItem;
+    [HideInInspector]
+    public RayCastItem m_CurrentRayCastItem;
+    private RayCastItem m_LastRayCastItem;
     private Dictionary<RayCastItem, SimplaeModelAssociation> mRayCastItemValues = new Dictionary<RayCastItem, SimplaeModelAssociation>();
+    private IndependentAni_BanShou independentAni_BanShou;
     public void Init()
     {
         mRayCastItemValues.Clear();
+        independentAni_BanShou = (toolAnimationBase as IndependentAni_BanShou);
         foreach (var item in ToolPack.targetObjs)
         {
             SimplaeModelAssociation simplaeModelAssociation = new SimplaeModelAssociation();
-            foreach (var moveItem in m_TargetSimplaeMoveItem.moveObjs)
+            foreach (var moveItem in independentAni_BanShou.m_SimpleMoveItem.moveObjs)
             {
                 if (Vector3.Distance(moveItem.Key.transform.position, item.transform.position) < 0.01f)
                 {
@@ -50,16 +59,19 @@ public class ToolPackInteractive_IndependentAni : MonoBehaviour
                     simplaeModelAssociation.value = 0;
                 }
             }
+            Debug.Log("Init" + item.gameObject.name + "---" + simplaeModelAssociation.model.name);
             mRayCastItemValues.Add(item, simplaeModelAssociation);
         }
+
+        isActive = true;
     }
     public void Update()
     {
-        if (!isActive || !m_TargetSimplaeMoveItem) return;
+        if (!isActive) return;
 
         if (Input.GetMouseButton(0))
         {
-             m_CurrentRayCastItem = null;
+            m_CurrentRayCastItem = null;
             foreach (var item in ToolPack.targetObjs)
             {
                 if (CameraRayCastManager.Instance.CheckCurrentHoverItem(item))
@@ -69,20 +81,386 @@ public class ToolPackInteractive_IndependentAni : MonoBehaviour
                 }
             }
 
-            if (!mRayCastItemValues.ContainsKey(m_CurrentRayCastItem)) return;
+            if (m_CurrentRayCastItem == null)
+            {
+                if (isPlaying && mRayCastItemValues.ContainsKey(m_LastRayCastItem))
+                {
+                    isPlaying = false;
+                    mRayCastItemValues[m_LastRayCastItem].value = independentAni_BanShou.StopPlayBack(this, false);
+
+                    m_LastRayCastItem = null;
+                }
+                return;
+            }
+
+            if (m_LastRayCastItem != m_CurrentRayCastItem)
+            {
+                if (!isPlaying && m_CurrentRayCastItem != null && mRayCastItemValues.ContainsKey(m_CurrentRayCastItem))
+                {
+                    isPlaying = true;
+                    independentAni_BanShou.PlayByValue(this, mRayCastItemValues[m_CurrentRayCastItem].value, false);
+                }
+                else if (isPlaying && mRayCastItemValues.ContainsKey(m_LastRayCastItem))
+                {
+                    isPlaying = false;
+                    mRayCastItemValues[m_LastRayCastItem].value = independentAni_BanShou.StopPlayBack(this, false);
+                }
+            }
 
-            mRayCastItemValues[m_CurrentRayCastItem].value += 1 / m_TargetSimplaeMoveItem.duration * Time.deltaTime;
-            mRayCastItemValues[m_CurrentRayCastItem].value = Mathf.Clamp(mRayCastItemValues[m_CurrentRayCastItem].value, 0, 1);
-            m_TargetSimplaeMoveItem.SetKeyValue(mRayCastItemValues[m_CurrentRayCastItem].model, mRayCastItemValues[m_CurrentRayCastItem].value);
-            m_CurrentRayCastItem.transform.position = mRayCastItemValues[m_CurrentRayCastItem].model.transform.position;
-            m_CurrentRayCastItem.transform.rotation = mRayCastItemValues[m_CurrentRayCastItem].model.transform.rotation;
+            if (isPlaying && mRayCastItemValues.ContainsKey(m_CurrentRayCastItem))
+            {
+                independentAni_BanShou.PlayUpdate(this, false);
+                m_CurrentRayCastItem.transform.position = mRayCastItemValues[m_CurrentRayCastItem].model.transform.position;
+                m_CurrentRayCastItem.transform.rotation = mRayCastItemValues[m_CurrentRayCastItem].model.transform.rotation;
+            }
+            //mRayCastItemValues[m_CurrentRayCastItem].value += 1 / independentAni_BanShou.duration * Time.deltaTime;
+            //mRayCastItemValues[m_CurrentRayCastItem].value = Mathf.Clamp(mRayCastItemValues[m_CurrentRayCastItem].value, 0, 1);
+            //independentAni_BanShou.SetKeyValue(mRayCastItemValues[m_CurrentRayCastItem].model, mRayCastItemValues[m_CurrentRayCastItem].value);
+            //m_CurrentRayCastItem.transform.position = mRayCastItemValues[m_CurrentRayCastItem].model.transform.position;
+            //m_CurrentRayCastItem.transform.rotation = mRayCastItemValues[m_CurrentRayCastItem].model.transform.rotation;
 
-            if (mRayCastItemValues[m_CurrentRayCastItem].value == 1)
+            if (mRayCastItemValues.ContainsKey(m_CurrentRayCastItem) && mRayCastItemValues[m_CurrentRayCastItem].value == 1)
             {
                 mRayCastItemValues[m_CurrentRayCastItem].model.SetActive(false);
             }
+
+            m_LastRayCastItem = m_CurrentRayCastItem;
+        }
+        else if (Input.GetMouseButtonUp(0))
+        {
+            if (isPlaying && mRayCastItemValues.ContainsKey(m_CurrentRayCastItem))
+            {
+                mRayCastItemValues[m_CurrentRayCastItem].value = independentAni_BanShou.StopPlayBack(this, false);
+            }
+
+            m_CurrentRayCastItem = null;
+            m_LastRayCastItem = null;
         }
     }
+
+    public void CurrentFinished()
+    {
+        if (mRayCastItemValues.ContainsKey(m_CurrentRayCastItem))
+        {
+            mRayCastItemValues[m_CurrentRayCastItem].value = 1;
+            Debug.Log(m_CurrentRayCastItem.name + "Value=1");
+        }
+    }
+
+    public bool IsFinished()
+    {
+        foreach (var item in mRayCastItemValues)
+        {
+            if (item.Value.value < 1)
+            {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    #region 模型及工具锚点参数
+    [FoldoutGroup("模型及锚点", Order = -1)]
+    [HorizontalGroup("模型及锚点/模型组")]
+    [LabelText("模型")]
+    [LabelWidth(30)]
+    public GameObject model;
+    [FoldoutGroup("模型及锚点", Order = -1)]
+    [LabelText("锚点")]
+    [LabelWidth(30)]
+    [HorizontalGroup("模型及锚点/模型组")]
+    public Transform modelAnchor;
+
+    [FoldoutGroup("工具及锚点", Order = -1)]
+    [LabelText("工具")]
+    [LabelWidth(30)]
+    [HorizontalGroup("工具及锚点/模型组")]
+    public GameObject toolObj;
+    [FoldoutGroup("工具及锚点", Order = -1)]
+    [LabelText("锚点")]
+    [LabelWidth(30)]
+    [HorizontalGroup("工具及锚点/模型组")]
+    public Transform toolAnchor;
+    private GameObject toolPrefab;
+    [FoldoutGroup("工具及锚点", Order = -1)]
+    [InfoBox("工具预支物路径:Assets/ChivaFramework/Framework/SimulationToolDev/ToolManager/ToolModel")]
+    [ValueDropdown("GetAllToolModel")]
+    [ShowInInspector]
+    [LabelText("加载模型预支物")]
+    public GameObject ToolPrefab
+    {
+        get
+        {
+            return toolPrefab;
+        }
+        set
+        {
+            if (toolPrefab != value)
+            {
+                toolPrefab = value;
+                if (toolObj != null)
+                {
+                    DestroyImmediate(toolObj);
+                }
+                toolObj = GameObject.Instantiate(toolPrefab);
+
+                if (modelAnchor != null)
+                {
+                    if (toolAnchor == null)
+                    {
+                        toolAnchor = new GameObject("工具锚点(该锚点位置会强制刷新,若需调整请调整子级工具预支物相对位置)").transform;
+                        toolAnchor.transform.parent = modelAnchor.transform;
+                        toolAnchor.transform.localPosition = Vector3.zero;
+                        toolAnchor.transform.localRotation = Quaternion.identity;
+                        toolAnchor.transform.localScale = Vector3.one;
+                    }
+                    else
+                    {
+                        toolAnchor.name = "工具锚点(该锚点位置会强制刷新,若需调整请调整子级工具预支物相对位置)";
+                        toolAnchor.transform.parent = modelAnchor.transform;
+                        toolAnchor.transform.localPosition = Vector3.zero;
+                        toolAnchor.transform.localRotation = Quaternion.identity;
+                        toolAnchor.transform.localScale = Vector3.one;
+                    }
+
+                    toolObj.transform.parent = toolAnchor.transform;
+                    toolObj.transform.localPosition = Vector3.zero;
+                    toolObj.transform.localRotation = Quaternion.identity;
+                    toolObj.transform.localScale = Vector3.one;
+                }
+            }
+        }
+    }
+
+#if UNITY_EDITOR
+    private static IEnumerable GetAllToolModel()
+    {
+        var root = "Assets/ChivaFramework/Framework/SimulationToolDev/ToolManager/ToolModel";
+
+        return UnityEditor.AssetDatabase.GetAllAssetPaths()
+            .Where(x => x.StartsWith(root))
+            .Select(x => x.Substring(root.Length))
+            .Select(x => new ValueDropdownItem(x, UnityEditor.AssetDatabase.LoadAssetAtPath<UnityEngine.GameObject>(root + x)));
+    }
+#endif
+
+    public bool ToolActiveState
+    {
+        get
+        {
+            if (toolAnchor == null)
+            {
+                return false;
+            }
+            else
+            {
+                return toolAnchor.gameObject.activeSelf;
+            }
+        }
+    }
+
+    [FoldoutGroup("工具及锚点", Order = -1)]
+    [Button("$ToolBtnName")]
+    public void ToolActive()
+    {
+        if (toolAnchor != null)
+        {
+            toolAnchor.gameObject.SetActive(!toolAnchor.gameObject.activeSelf);
+        }
+    }
+    public string ToolBtnName
+    {
+        get
+        {
+            if (ToolActiveState)
+            {
+                return "隐藏工具";
+            }
+            else { return "显示工具"; }
+        }
+    }
+
+    #endregion
+
+    [SerializeField]
+    [HideInInspector]
+    private IndependentAniBase toolAnimationBase;
+    [BoxGroup("工具动画")]
+    [HideLabel]
+    [ShowInInspector]
+    [TypeFilter("GetFilteredTypeList")]
+    public IndependentAniBase ToolAnimationBase
+    {
+        get
+        {
+            return toolAnimationBase;
+        }
+        set
+        {
+            if (toolAnimationBase != value)
+            {
+                toolAnimationBase = value;
+            }
+        }
+    }
+    public IEnumerable<Type> GetFilteredTypeList()
+    {
+        var q = typeof(IndependentAniBase).Assembly.GetTypes()
+            .Where(x => !x.IsAbstract)
+            .Where(x => !x.IsGenericTypeDefinition)
+            .Where(x => typeof(IndependentAniBase).IsAssignableFrom(x));
+
+        return q;
+    }
+
+    public void SetInitState(bool reverse)
+    {
+        isPlaying = false;
+        if (toolAnimationBase != null)
+        {
+            toolAnimationBase.InitState(this, reverse);
+        }
+    }
+    public void SetFinishedState(bool reverse)
+    {
+        isPlaying = false;
+        if (toolAnimationBase != null)
+        {
+            toolAnimationBase.FinishedState(this, reverse);
+        }
+    }
+
+    public bool PlayToolAnimation(bool reverse)
+    {
+        if (toolAnimationBase != null)
+        {
+            toolAnimationBase.PlayUpdate(this, reverse);
+        }
+        return isPlaying;
+    }
+
+    void Awake()
+    {
+        if (toolAnchor.gameObject.activeSelf)
+        {
+            toolAnchor.gameObject.SetActive(false);
+        }
+    }
+
+    public bool editorReverse = false;
+
+    [Button("$PlayBtnName")]
+    public void Play()
+    {
+        if (!isPlaying)
+        {
+            isPlaying = true;
+            if (toolAnimationBase != null)
+            {
+                toolAnimationBase.PlayTrigger(this, editorReverse);
+            }
+        }
+        else
+        {
+            isPlaying = false;
+            if (toolAnimationBase != null)
+            {
+                toolAnimationBase.StopPlay(this, editorReverse);
+            }
+        }
+    }
+    public string PlayBtnName
+    {
+        get
+        {
+            if (isPlaying)
+            {
+                return "停止";
+
+            }
+            else
+            {
+                return "播放";
+            }
+        }
+    }
+
+
+    public bool isPlaying;
+
+    public void Destroy(GameObject obj)
+    {
+        if (obj != null)
+        {
+            DestroyImmediate(obj);
+        }
+    }
+
+#if UNITY_EDITOR
+
+    [FoldoutGroup("模型及锚点", Order = -1)]
+    [Button("重置模型")]
+    public void AddSelectObj()
+    {
+        if (Selection.gameObjects.Length == 0) return;
+
+        model = Selection.activeGameObject;
+        if (modelAnchor != null)
+        {
+            //DestroyImmediate(modelAnchor.gameObject);
+            modelAnchor.name = "锚点_" + model.gameObject.name;
+            modelAnchor.transform.parent = transform;
+            modelAnchor.transform.position = model.transform.position;
+            modelAnchor.transform.rotation = model.transform.rotation;
+        }
+        else
+        {
+            GameObject tmpItem = new GameObject("锚点_" + model.gameObject.name);
+            tmpItem.transform.parent = transform;
+            tmpItem.transform.position = model.transform.position;
+            tmpItem.transform.rotation = model.transform.rotation;
+            modelAnchor = tmpItem.transform;
+        }
+    }
+
+    private void OnDrawGizmos()
+    {
+        if (ToolAnimationBase != null)
+        {
+            ToolAnimationBase.OnDrawGizmos(this);
+        }
+    }
+    /// <summary>
+    /// 销毁所有子级信息
+    /// </summary>
+    /// <param name="item"></param>
+    private void DestroyChild(Transform item)
+    {
+        if (item.childCount == 0) return;
+
+        for (int i = item.childCount - 1; i >= 0; i--)
+        {
+            DestroyImmediate(item.GetChild(i).gameObject);
+        }
+    }
+
+
+    private void OnEnable()
+    {
+        EditorApplication.update += EditorUpdate;
+    }
+    private void OnDisable()
+    {
+        EditorApplication.update -= EditorUpdate;
+    }
+
+    private float timer = 0;
+    void EditorUpdate()
+    {
+        if (!isPlaying || Application.isPlaying) return;
+        toolAnimationBase.EditorPlayUpdate(this, editorReverse);
+    }
+#endif
 }
 
 public class SimplaeModelAssociation

+ 1 - 1
OperationUIFrame/OperationUIFrameV2/Scripts/UI/PC_OperatePanel.cs

@@ -131,7 +131,7 @@ namespace QFramework
                     operateName = "操作步骤";
                     OperateStep.HelpBtn.gameObject.SetActive(true);
                     OperateStep.AutoPlayBtn.gameObject.SetActive(false);
-                    OperateStep.ToolLibraryBtn.gameObject.SetActive(false);
+                    OperateStep.ToolLibraryBtn.gameObject.SetActive(true);
                     OperateStep.ToolBackPackBtn.gameObject.SetActive(true);
                     OperateStep.EndExam.gameObject.SetActive(false);
                     break;

+ 1 - 2
OperationUIFrame/OperationUIFrameV2/Scripts/UI/ToolLibraryForm.cs

@@ -52,8 +52,7 @@ namespace QFramework
             m_ToolConfigProxy.m_CurrentToolLibraryType = mData.toolLibraryType;
 
             CloseBtn.gameObject.SetActive(mData.selectAction == null);
-
-           
+                      
         }
 
         protected override void OnOpen(IUIData uiData = null)

+ 11 - 1
OperationUIFrame/OperationUIFrameV2/Scripts/UI/ToolLibraryForm/ToolLibrarySelectElement.cs

@@ -279,8 +279,18 @@ namespace QFramework
 
         public void OnClearBtnClick()
         {
-            DAL.Instance.Get<ToolConfigProxy>().ClearToolConfigInfoToCTKSTCIs();
 
+            switch (m_ToolConfigProxy.m_CurrentToolLibraryType)
+            {
+                case ToolLibraryType.ToolRoom:
+                    DAL.Instance.Get<ToolConfigProxy>().ClearToolConfigInfoToCTRSTCIs();
+                    break;
+                case ToolLibraryType.ToolKit:
+                    DAL.Instance.Get<ToolConfigProxy>().ClearToolConfigInfoToCTKSTCIs();
+                    break;
+                default:
+                    break;
+            }
             ShowTargetPage(m_CurrentPage);
         }