2using System.Collections;
3using System.Runtime.Serialization;
5using JetBrains.Annotations;
6using NaughtyAttributes;
20 private bool originalState =
true;
21 private bool _setupOk;
23 [SerializeField]
internal GameObject selectedGO;
24 private GameObject canvasSelector;
25 private GameObject canvasHierarchy;
26 private GameObject canvas;
44 if (go ==
null)
return;
60 GetComponentInChildren<ObjectDroppedEvent>().NameText.text = go.name;
65 if (!_setupOk)
return;
68 selectedGO?.SetActive(originalState);
73 selectedGO?.SetActive(originalState);
81 originalState = selectedGO.activeSelf;
89 selectedGO?.SetActive(!Show);
94 yield
return new WaitForEndOfFrame();
107 if (hash ==
"")
return;
124 GetComponentInChildren<ObjectDroppedEvent>().NameText.text =
gop.
asset.name;
127 private void OnAssetIsNullCallback()
135 canvasSelector.GetComponent<Canvas>().enabled =
false;
136 GetComponentInParent<Canvas>().enabled =
true;
137 canvasSelector.transform.GetChild(0).GetComponent<
Button>().onClick.RemoveListener(
SetSelectedGO);
143 canvasHierarchy.transform.SetParent(canvas.transform,
false);
148 canvasSelector.GetComponent<Canvas>().enabled =
false;
149 GetComponentInParent<Canvas>().enabled =
true;
150 canvasSelector.transform.GetChild(0).GetComponent<
Button>().onClick.RemoveListener(
SetSelectedGO);
157 canvasHierarchy.transform.SetParent(canvas.transform,
false);
162 canvas = GameObject.Find(
"Canvas");
165 Debug.LogError(
"canvas not found!");
179 canvasHierarchy = GameObject.Find(
"Hierarchy");
180 if (canvasHierarchy ==
null)
182 Debug.LogError(
"Hierarchy not found!");
186 canvasHierarchy.transform.SetParent(canvasSelector.transform,
false);
188 GetComponentInParent<Canvas>().enabled =
false;
189 canvasSelector.transform.GetChild(0).GetComponent<
Button>().onClick.AddListener(
SetSelectedGO);
191 canvasSelector.GetComponent<Canvas>().enabled =
true;
203 private void ReSetGO()
208 public new void GetObjectData(SerializationInfo info, StreamingContext context)
210 base.GetObjectData(info, context);
212 info.AddValue(
"selectedGO", selectedGO, typeof(GameObject));
213 info.AddValue(
"Show", Show, typeof(
bool));
216 info.AddValue(
"selectedGOHash", selectedGO.GetComponent<
HashHolder>().
Hash, typeof(
string));
220 info.AddValue(
"selectedGOHash",
selectedHash, typeof(
string));
225 public ShowHideAction(SerializationInfo info, StreamingContext context) : base(info, context)
227 selectedGO = (GameObject) info.GetValue(
"selectedGO", typeof(GameObject));
228 Show = info.GetBoolean(
"Show");
229 foreach (var e
in info)
230 if (e.Name ==
"selectedGOHash")
UnityEngine.UI.Button Button
static GameObject activeGameObject
void Initialize(bool reinitialize=false)
static string T(string key)
GameObject GetGameObject()
void SetGameObject(string hash)
override void Triggered(string id)
new void GetObjectData(SerializationInfo info, StreamingContext context)
override void Deactivate()
ShowHideAction(SerializationInfo info, StreamingContext context)
void OnValueChanged(bool value)
string canvasSelectorName
void SetGameObject(GameObject go)
IEnumerator SetGameObjectJob(string hash)
void RestoreOriginalState()