mirror of
https://github.com/ConjureETS/Unity_Utils.git
synced 2026-03-24 04:50:58 +00:00
Moved files to proper folders
This commit is contained in:
parent
ddb92f7236
commit
b0d6a2a72d
@ -1,39 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public class SerializableDictionary<TKey, TValue> : Dictionary<TKey, TValue>, ISerializationCallbackReceiver
|
|
||||||
{
|
|
||||||
[SerializeField] private List<TKey> _keys = new List<TKey>();
|
|
||||||
[SerializeField] private List<TValue> _values = new List<TValue>();
|
|
||||||
|
|
||||||
public void OnBeforeSerialize()
|
|
||||||
{
|
|
||||||
_keys.Clear();
|
|
||||||
_values.Clear();
|
|
||||||
|
|
||||||
foreach (KeyValuePair<TKey,TValue> pair in this)
|
|
||||||
{
|
|
||||||
_keys.Add(pair.Key);
|
|
||||||
_values.Add(pair.Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnAfterDeserialize()
|
|
||||||
{
|
|
||||||
Clear();
|
|
||||||
|
|
||||||
if (_keys.Count != _values.Count)
|
|
||||||
{
|
|
||||||
throw new Exception(
|
|
||||||
$"There are {_keys.Count} keys and {_values.Count} values after deserialization." +
|
|
||||||
" Make sure that both key and value types are serializable.");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < _keys.Count; ++i)
|
|
||||||
{
|
|
||||||
Add(_keys[i], _values[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
42
Util/SerializableDictionary.cs
Normal file
42
Util/SerializableDictionary.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Util
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class SerializableDictionary<TKey, TValue> : Dictionary<TKey, TValue>, ISerializationCallbackReceiver
|
||||||
|
{
|
||||||
|
[SerializeField] private List<TKey> _keys = new List<TKey>();
|
||||||
|
[SerializeField] private List<TValue> _values = new List<TValue>();
|
||||||
|
|
||||||
|
public void OnBeforeSerialize()
|
||||||
|
{
|
||||||
|
_keys.Clear();
|
||||||
|
_values.Clear();
|
||||||
|
|
||||||
|
foreach (KeyValuePair<TKey,TValue> pair in this)
|
||||||
|
{
|
||||||
|
_keys.Add(pair.Key);
|
||||||
|
_values.Add(pair.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnAfterDeserialize()
|
||||||
|
{
|
||||||
|
Clear();
|
||||||
|
|
||||||
|
if (_keys.Count != _values.Count)
|
||||||
|
{
|
||||||
|
throw new Exception(
|
||||||
|
$"There are {_keys.Count} keys and {_values.Count} values after deserialization." +
|
||||||
|
" Make sure that both key and value types are serializable.");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < _keys.Count; ++i)
|
||||||
|
{
|
||||||
|
Add(_keys[i], _values[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,38 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
using TMPro;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This class sets the text and image of the popup message
|
|
||||||
/// </summary>
|
|
||||||
public class PopupMessage : MonoBehaviour
|
|
||||||
{
|
|
||||||
public TextMeshProUGUI popupMessage;
|
|
||||||
private Image image;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the X mark image in the child object
|
|
||||||
/// </summary>
|
|
||||||
private void Awake()
|
|
||||||
{
|
|
||||||
image = GetComponentsInChildren<Image>()[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the new test and shows or hides the X mark image.
|
|
||||||
/// Hides the whole gameObject after 2 seconds
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="newText"></param>
|
|
||||||
/// <param name="enabled"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public IEnumerator Reset(string newText, bool enabled = false)
|
|
||||||
{
|
|
||||||
|
|
||||||
popupMessage.text = newText;
|
|
||||||
image.gameObject.SetActive(enabled);
|
|
||||||
yield return new WaitForSeconds(2f);
|
|
||||||
gameObject.SetActive(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user