using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; namespace MoleMole { public class NewbieHighlightInfo { private enum CallbackType { ButtonCallback = 0, PanelCallback = 1 } private NewbieDialogContext _newbieDialogContext; public Transform originTrans; private List _enabledScripts; private Transform _highlightTrans; private List _eventTriggers; private List _ignoreScriptList; public NewbieHighlightInfo(NewbieDialogContext newbieDialogContext, Transform originTrans, Transform newParent, bool disableHighlightInvoke, Action preCallback, Action pointerDownCallback, Action pointerUpCallback) { _ignoreScriptList = new List(); _ignoreScriptList.Add("ImageForSmoothMask"); _ignoreScriptList.Add("MonoButtonWwiseEvent"); _newbieDialogContext = newbieDialogContext; this.originTrans = originTrans; GameObject gameObject = CopyOriginTransform(originTrans); _highlightTrans = gameObject.transform; _highlightTrans.SetParent(newParent); _highlightTrans.SetSiblingIndex(1); _highlightTrans.localScale = Vector3.one; BindOriginTransformHelper(); BindViewCallback(disableHighlightInvoke, preCallback, pointerDownCallback, pointerUpCallback); } public void Recover() { UnbindOriginTransformHelper(); UnbindViewCallback(); if (_highlightTrans != null && _highlightTrans.gameObject != null) { UnityEngine.Object.Destroy(_highlightTrans.gameObject); } } private GameObject CopyOriginTransform(Transform originTrans) { _enabledScripts = new List(); MonoBehaviour[] componentsInChildren = originTrans.gameObject.GetComponentsInChildren(); MonoBehaviour[] array = componentsInChildren; foreach (MonoBehaviour monoBehaviour in array) { if (monoBehaviour.GetType().Namespace == "MoleMole" && monoBehaviour.enabled && !_ignoreScriptList.Contains(monoBehaviour.GetType().Name)) { _enabledScripts.Add(monoBehaviour); monoBehaviour.enabled = false; } } Vector3 position = new Vector3(originTrans.position.x, originTrans.position.y, originTrans.position.z); Transform parent = originTrans.parent; MonoBehaviour[] components = parent.gameObject.GetComponents(); List list = new List(); MonoBehaviour[] array2 = components; foreach (MonoBehaviour monoBehaviour2 in array2) { if (monoBehaviour2 is LayoutGroup && monoBehaviour2.enabled) { list.Add(monoBehaviour2); monoBehaviour2.enabled = false; } } GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate(originTrans.gameObject, position, originTrans.rotation); foreach (MonoBehaviour enabledScript in _enabledScripts) { enabledScript.enabled = true; } foreach (MonoBehaviour item in list) { item.enabled = true; } Button componentInChildren = gameObject.transform.GetComponentInChildren