private void OnEnable() { m_CurSelectIdIndex = -1; m_Target = target as RoamSpacecraftEntity; if (m_Target.m_CurSpacecraftId > 0) { List <EditorSpacecraft> spacecraftList = m_Target.m_SpacecraftDatas; if (spacecraftList != null && spacecraftList.Count > 0) { for (int iSpace = 0; iSpace < spacecraftList.Count; iSpace++) { if (spacecraftList[iSpace].spacecraft_id == m_Target.m_CurSpacecraftId) { m_CurSelectIdIndex = iSpace; break; } } } if (m_CurSelectIdIndex < 0) { m_CurSelectIdIndex = m_Target.m_ShowIdList.IndexOf(m_Target.m_CurSpacecraftId.ToString()); } } m_LastSelectIdIndex = m_CurSelectIdIndex; m_LastSpeedMode = m_Target.m_SpeedMode; m_LastModelName = m_Target.m_ModelName; }
void Refresh() { if (m_CurSelectIdIndex >= 0 && (m_CurSelectIdIndex != m_LastSelectIdIndex || m_Target.m_SpeedMode != m_LastSpeedMode)) { // m_Target.m_CurSpacecraftId = -1; bool isFind = false; List <EditorSpacecraft> spacecraftDatas = m_Target.m_SpacecraftDatas; if (spacecraftDatas != null && spacecraftDatas.Count > 0) { if (spacecraftDatas.Count > m_CurSelectIdIndex) { EditorSpacecraft editorData = spacecraftDatas[m_CurSelectIdIndex]; if (editorData != null) { m_Target.m_CurSpacecraftId = editorData.spacecraft_id; } } EditorSpacecraft spaceCraft = spacecraftDatas.Find(x => x.spacecraft_id == m_Target.m_CurSpacecraftId); if (spaceCraft != null && spaceCraft.spacecraft_modes != null && spaceCraft.spacecraft_modes.Length > 0) { EditorSpacecraftMode[] modes = spaceCraft.spacecraft_modes; for (int iMode = 0; iMode < modes.Length; iMode++) { if (modes[iMode].speed_mode == (int)m_Target.m_SpeedMode) { m_Target.m_CurEditorModeData.Copy(modes[iMode]); isFind = true; break; } } } } if (!isFind) { m_Target.m_CurEditorModeData.Init(); m_Target.m_CurEditorModeData.speed_mode = (int)m_Target.m_SpeedMode; } m_LastSelectIdIndex = m_CurSelectIdIndex; m_LastSpeedMode = m_Target.m_SpeedMode; m_Target.RefreshShowIdList(); } GameObject targetObj = m_Target.GetPlayerPrefab(); if (targetObj != null && m_LastModelName != targetObj.name) { if (GUILayout.Button("同步预设信息")) { m_Target.InitSpacecraftEditor(); m_CurSelectIdIndex = -1; m_LastSelectIdIndex = m_CurSelectIdIndex; m_LastModelName = m_Target.m_ModelName; } } }