工具间现场恢复
This commit is contained in:
parent
d8a5669ec7
commit
63f9ecf4aa
|
|
@ -11862,6 +11862,9 @@ PrefabInstance:
|
||||||
m_RemovedGameObjects: []
|
m_RemovedGameObjects: []
|
||||||
m_AddedGameObjects: []
|
m_AddedGameObjects: []
|
||||||
m_AddedComponents:
|
m_AddedComponents:
|
||||||
|
- targetCorrespondingSourceObject: {fileID: 977084344072621036, guid: 7e42ad4821305374ba380adcf42bf09b, type: 3}
|
||||||
|
insertIndex: -1
|
||||||
|
addedObject: {fileID: 1608953930}
|
||||||
- targetCorrespondingSourceObject: {fileID: 1842941632173029566, guid: 7e42ad4821305374ba380adcf42bf09b, type: 3}
|
- targetCorrespondingSourceObject: {fileID: 1842941632173029566, guid: 7e42ad4821305374ba380adcf42bf09b, type: 3}
|
||||||
insertIndex: -1
|
insertIndex: -1
|
||||||
addedObject: {fileID: 822250776}
|
addedObject: {fileID: 822250776}
|
||||||
|
|
@ -24473,6 +24476,23 @@ MonoBehaviour:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
m_Calls: []
|
m_Calls: []
|
||||||
m_IsOn: 0
|
m_IsOn: 0
|
||||||
|
--- !u!1 &1608953929 stripped
|
||||||
|
GameObject:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 977084344072621036, guid: 7e42ad4821305374ba380adcf42bf09b, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 822250774}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!114 &1608953930
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1608953929}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 5c35a0593d19159449dafa5033c487e8, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &1615943079
|
--- !u!1 &1615943079
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 553d1215074c14e42aefdbecfdff9beb
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
using MotionFramework;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class ToolRoomToolsContainer : MonoBehaviour//HQB挂载在所有工具的根部,用于初始化工具是否显示
|
||||||
|
{
|
||||||
|
public static ToolRoomToolsContainer instance;
|
||||||
|
private Dictionary<string, List<GameObject>> _toolsNames;
|
||||||
|
ToolRoomToolsContainer() {
|
||||||
|
instance = this;
|
||||||
|
}
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
if (instance != null)
|
||||||
|
{
|
||||||
|
_toolsNames = MotionEngine.GetModule<ToolsPackManager>().GetToolsPack();
|
||||||
|
foreach (var item in _toolsNames)
|
||||||
|
{
|
||||||
|
foreach (var item1 in item.Value)
|
||||||
|
{
|
||||||
|
item1.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5c35a0593d19159449dafa5033c487e8
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -38,6 +38,8 @@ public class ToolsPackWindowItemBtModel
|
||||||
public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
|
public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
|
||||||
{
|
{
|
||||||
private Dictionary<string, List<GameObject>> _toolsPack; //在工具间存
|
private Dictionary<string, List<GameObject>> _toolsPack; //在工具间存
|
||||||
|
private Dictionary<string, List<Vector3>> _toolsPackBackup;//HQB,记录tool的位置,切换场景后toolsPack的obj会销毁,以position作为标记
|
||||||
|
|
||||||
private Dictionary<string, List<ToolsPackString>> _toolsPackString; //只存值
|
private Dictionary<string, List<ToolsPackString>> _toolsPackString; //只存值
|
||||||
private Dictionary<string, Texture2D> _toolsPackWindowBtImage; //工具窗口下的按钮图集
|
private Dictionary<string, Texture2D> _toolsPackWindowBtImage; //工具窗口下的按钮图集
|
||||||
private List<GameObject> _toolsPackWindowItemBts; //工具窗口下创建的按钮集合,点击按钮的X用来删除和新增
|
private List<GameObject> _toolsPackWindowItemBts; //工具窗口下创建的按钮集合,点击按钮的X用来删除和新增
|
||||||
|
|
@ -55,6 +57,37 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
|
||||||
|
|
||||||
public List<string> wearTools = new List<string>();
|
public List<string> wearTools = new List<string>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// HQB检查恢复_toolsPack,因为没有其他的键值,只能先以位置作为键值
|
||||||
|
/// </summary>
|
||||||
|
public void RecoverToolsPack()
|
||||||
|
{
|
||||||
|
if (_toolsPack == null || _toolsPack.Count == 0)return;
|
||||||
|
ToolRoomToolsContainer toolRoomToolsContainer = GameObject.FindObjectOfType<ToolRoomToolsContainer>();
|
||||||
|
if (toolRoomToolsContainer == null) return;
|
||||||
|
|
||||||
|
foreach (var toolItem in _toolsPack)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < toolItem.Value.Count; i++)
|
||||||
|
{
|
||||||
|
if (toolItem.Value[i] == null)
|
||||||
|
{
|
||||||
|
string toolName = toolItem.Key;
|
||||||
|
Vector3 pos = _toolsPackBackup[toolName][i];
|
||||||
|
for (int j = 0; j < toolRoomToolsContainer.transform.childCount; j++)
|
||||||
|
{
|
||||||
|
if (toolRoomToolsContainer.transform.GetChild(j).position.Equals(pos))
|
||||||
|
{
|
||||||
|
toolItem.Value[i] = toolRoomToolsContainer.transform.GetChild(j).gameObject;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 触发事件的方法
|
// 触发事件的方法
|
||||||
public void OnTriggerStringEvent(string message)
|
public void OnTriggerStringEvent(string message)
|
||||||
{
|
{
|
||||||
|
|
@ -69,6 +102,7 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
|
||||||
_toolsPack = new Dictionary<string, List<GameObject>>();
|
_toolsPack = new Dictionary<string, List<GameObject>>();
|
||||||
_toolsPackString = new Dictionary<string, List<ToolsPackString>>();
|
_toolsPackString = new Dictionary<string, List<ToolsPackString>>();
|
||||||
_toolsPackWindowItemBts = new List<GameObject>();
|
_toolsPackWindowItemBts = new List<GameObject>();
|
||||||
|
_toolsPackBackup = new Dictionary<string, List<Vector3>>();//HQB初始化
|
||||||
|
|
||||||
//加载工具窗口按钮
|
//加载工具窗口按钮
|
||||||
_toolsPackWindowBt = Resources.Load<GameObject>("Prefabs/Window/ToolsPack/ToolsPackWindowItemBt");
|
_toolsPackWindowBt = Resources.Load<GameObject>("Prefabs/Window/ToolsPack/ToolsPackWindowItemBt");
|
||||||
|
|
@ -91,11 +125,13 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
|
||||||
|
|
||||||
public void OnUpdate()
|
public void OnUpdate()
|
||||||
{
|
{
|
||||||
|
//Debug.Log("===>ToolsPackManager");//HQB
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnDestroy()
|
public void OnDestroy()
|
||||||
{
|
{
|
||||||
_toolsPack.Clear();
|
_toolsPack.Clear();
|
||||||
|
_toolsPackBackup.Clear();//HQB
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnGUI()
|
public void OnGUI()
|
||||||
|
|
@ -128,6 +164,7 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
|
||||||
if (!_toolsPack.ContainsKey(toolsName))
|
if (!_toolsPack.ContainsKey(toolsName))
|
||||||
{
|
{
|
||||||
_toolsPack.Add(toolsName, new List<GameObject>() { toolsGame });
|
_toolsPack.Add(toolsName, new List<GameObject>() { toolsGame });
|
||||||
|
_toolsPackBackup.Add(toolsName, new List<Vector3>() { toolsGame.transform.position });//HQB
|
||||||
_toolsPackString.Add(toolsName, new List<ToolsPackString>()
|
_toolsPackString.Add(toolsName, new List<ToolsPackString>()
|
||||||
{
|
{
|
||||||
new ToolsPackString()
|
new ToolsPackString()
|
||||||
|
|
@ -143,6 +180,7 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
|
||||||
{
|
{
|
||||||
toolsGame.GetComponent<ToolsPackGameObjectComponent>().SetIndex(_toolsPack[toolsName].Count);
|
toolsGame.GetComponent<ToolsPackGameObjectComponent>().SetIndex(_toolsPack[toolsName].Count);
|
||||||
_toolsPack[toolsName].Add(toolsGame);
|
_toolsPack[toolsName].Add(toolsGame);
|
||||||
|
_toolsPackBackup[toolsName].Add(toolsGame.transform.position);//HQB
|
||||||
_toolsPackString[toolsName].Add(
|
_toolsPackString[toolsName].Add(
|
||||||
new ToolsPackString()
|
new ToolsPackString()
|
||||||
{
|
{
|
||||||
|
|
@ -179,6 +217,7 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
|
||||||
{
|
{
|
||||||
_toolsPack.Remove(toolsName);
|
_toolsPack.Remove(toolsName);
|
||||||
_toolsPackString.Remove(toolsName);
|
_toolsPackString.Remove(toolsName);
|
||||||
|
_toolsPackBackup.Remove(toolsName);//HQB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -203,6 +242,10 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Dictionary<string, List<GameObject>> GetToolsPack()
|
public Dictionary<string, List<GameObject>> GetToolsPack()
|
||||||
{
|
{
|
||||||
|
if (_toolsPack != null || _toolsPack.Count > 0)//HQB
|
||||||
|
{
|
||||||
|
RecoverToolsPack();
|
||||||
|
}
|
||||||
return _toolsPack;
|
return _toolsPack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using DefaultNamespace;
|
||||||
using DefaultNamespace.ProcessMode;
|
using DefaultNamespace.ProcessMode;
|
||||||
using MotionFramework;
|
using MotionFramework;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
@ -12,11 +13,19 @@ namespace ToolsPack
|
||||||
public string Scenename;
|
public string Scenename;
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
this.GetComponent<Button>().onClick.AddListener(delegate
|
//学习模式下不能返回工具间
|
||||||
|
if (MotionEngine.GetModule<DataConfigManager>().GetProcessMode() == ProcessMode.Teaching && Scenename.Equals("工具间"))
|
||||||
{
|
{
|
||||||
// MotionEngine.GetModule<AnimationProcessManager>().HandleClick("前往现场");
|
this.gameObject.SetActive(false);
|
||||||
SceneManager.LoadScene(Scenename);
|
}
|
||||||
});
|
else
|
||||||
|
{
|
||||||
|
this.GetComponent<Button>().onClick.AddListener(delegate
|
||||||
|
{
|
||||||
|
// MotionEngine.GetModule<AnimationProcessManager>().HandleClick("前往现场");
|
||||||
|
SceneManager.LoadScene(Scenename);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -16,7 +16,6 @@ namespace ToolsPack
|
||||||
设备
|
设备
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 工具窗口管理器
|
/// 工具窗口管理器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,9 @@ public class UIManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
public static UIManager instance;
|
public static UIManager instance;
|
||||||
public ToolsPackMenuBtOnClick toolsPackMenuBtOnClick;
|
public ToolsPackMenuBtOnClick toolsPackMenuBtOnClick;
|
||||||
|
[HideInInspector]//HQB 记录工具间拿取的工具
|
||||||
|
public List<Vector3> catchedTools = new List<Vector3>();//HQB采用位置作为索引判断物体是否被拿走
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue