Generating and Displaying Zones

This commit is contained in:
hyperion51 2020-03-29 04:19:24 +01:00
commit f756c5fe6a
67 changed files with 1343 additions and 826 deletions

View file

@ -0,0 +1,35 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BackgroundRenderer : MonoBehaviour
{
public Transform Background;
public Transform Background2;
// public float RotationSpeed1 = 1;
// public float RotationSpeed2 = 1;
private Camera _camera;
private float _ratio;
private Material _material;
private Material _material2;
private float _depth;
private void Start()
{
_camera = GetComponent<Camera>();
_depth = Background.position.z;
_material = Background.GetComponent<MeshRenderer>().material;
_material2 = Background2.GetComponent<MeshRenderer>().material;
}
private void OnPreRender()
{
_material.SetVector("ParallaxDirection", transform.position);
_material2.SetVector("ParallaxDirection", transform.position);
_ratio = (float) Screen.width / Screen.height;
Background2.position = Background.position = new Vector3(transform.position.x, transform.position.y, _depth);
var size = _camera.orthographicSize;
Background2.localScale = Background.localScale = new Vector3(size * 2 * _ratio, size * 2, 1);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 60335bb143d92fd4eac7a5ed8b12494c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,47 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
public class ClickCatcher : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
{
//public bool EnableMouse => PointerIsInside && !_catching;
public bool PointerIsInside { get; private set; }
public event Action<PointerEventData> OnEnter;
public event Action<PointerEventData> OnExit;
public event Action<PointerEventData> OnClick;
public static ClickCatcher Background
{
get
{
if (_background == null)
_background = GameObject.FindGameObjectWithTag("UIBackground").GetComponent<ClickCatcher>();
return _background;
}
}
private static ClickCatcher _background;
public void OnPointerEnter(PointerEventData eventData)
{
//Debug.Log("Pointer Entered");
OnEnter?.Invoke(eventData);
PointerIsInside = true;
}
public void OnPointerExit(PointerEventData eventData)
{
//Debug.Log("Pointer Exited");
OnExit?.Invoke(eventData);
PointerIsInside = false;
}
public void OnPointerClick(PointerEventData eventData)
{
OnClick?.Invoke(eventData);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 20fa7724865c6b04097615292a325dfe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ClickRaycaster : MonoBehaviour
{
public Camera RayCamera;
private ClickCatcher _clickCatcher;
void Start()
{
_clickCatcher = GetComponent<ClickCatcher>();
_clickCatcher.OnClick += pointer =>
{
RaycastHit hit;
Physics.Raycast(RayCamera.ScreenPointToRay(pointer.position), out hit);
if (hit.collider != null)
{
var clickable = hit.collider.GetComponent<ClickableCollider>();
if (clickable != null)
clickable.Click(pointer);
}
};
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ba30ab714c5cf6943957d3e4ae549c84
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,12 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class ClickableCollider : MonoBehaviour
{
public event Action<ClickableCollider, PointerEventData> OnClick;
public void Click(PointerEventData eventData) => OnClick?.Invoke(this, eventData);
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 52538a3309c36fc4583c964a1c0b705f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,29 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static Unity.Mathematics.math;
public class DragHandler : MonoBehaviour
{
public Camera Camera;
public float Scaling;
private Vector2 _previousPosition;
void Update()
{
var newPosition = Camera.ScreenToWorldPoint(Input.mousePosition);
if(Input.GetMouseButtonDown(0))
_previousPosition = newPosition;
if (Input.GetMouseButton(0))
{
Camera.transform.position -= (Vector3)((Vector2) newPosition - _previousPosition);
}
if (abs(Input.mouseScrollDelta.y) > .01f)
{
var previousPosition = Camera.ScreenToWorldPoint(Input.mousePosition);
Camera.orthographicSize *= 1 + Input.mouseScrollDelta.y * Scaling;
Camera.transform.position -= Camera.ScreenToWorldPoint(Input.mousePosition) - previousPosition;
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d172604daaa352b4784c662883d40ec9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,102 @@
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class FlatButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
{
public event Action<FlatButton> OnClick;
public float StateDamping;
// public RectTransform Tab;
public Image Fill;
public Image Outline;
public TextMeshProUGUI Label;
public VerticalLayoutGroup LabelLayout;
public FlatButtonState CurrentState = FlatButtonState.Unselected;
public bool DisableClickWhenSelected = true;
public FlatButtonAppearance UnselectedAppearance;
public FlatButtonAppearance SelectedAppearance;
public FlatButtonAppearance HoverAppearance;
public FlatButtonAppearance ClickAppearance;
private RectOffset _defaultPadding;
private float _currentPadding;
private void Start()
{
_defaultPadding = LabelLayout.padding;
_currentPadding = _defaultPadding.left;
}
public void OnPointerEnter(PointerEventData eventData)
{
if (CurrentState == FlatButtonState.Unselected)
CurrentState = FlatButtonState.Hover;
}
public void OnPointerExit(PointerEventData eventData)
{
if (CurrentState == FlatButtonState.Hover)
CurrentState = FlatButtonState.Unselected;
}
public void OnPointerClick(PointerEventData eventData)
{
if (!DisableClickWhenSelected || CurrentState != FlatButtonState.Selected)
{
Fill.color = ClickAppearance.FillColor;
Outline.color = ClickAppearance.OutlineColor;
OnClick?.Invoke(this);
}
}
private void Update()
{
FlatButtonAppearance appearance;
switch (CurrentState)
{
case FlatButtonState.Unselected:
appearance = UnselectedAppearance;
break;
case FlatButtonState.Selected:
appearance = SelectedAppearance;
break;
case FlatButtonState.Hover:
appearance = HoverAppearance;
break;
default:
appearance = new FlatButtonAppearance();
break;
}
Fill.color = Color.Lerp(Fill.color, appearance.FillColor, StateDamping * Time.deltaTime);
Outline.color = Color.Lerp(Outline.color, appearance.OutlineColor, StateDamping * Time.deltaTime);
_currentPadding = Mathf.Lerp(_currentPadding, appearance.LayoutPadding, StateDamping * Time.deltaTime);
LabelLayout.padding = new RectOffset
{
bottom = _defaultPadding.bottom,
top = _defaultPadding.top,
left = (int) _currentPadding,
right = (int) _currentPadding
};
}
}
public enum FlatButtonState
{
Unselected,
Selected,
Hover
}
[Serializable]
public struct FlatButtonAppearance
{
public Color FillColor;
public Color OutlineColor;
public int LayoutPadding;
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9ec664fdf25c943478e0ca99c935c2fd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class GalaxyZone : MonoBehaviour
{
public MeshRenderer Background;
public MeshRenderer Icon;
public TextMeshPro Label;
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 685a87786d510214eb9f9a11f756dcde
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "Icons", menuName = "Aetheria/Icons")]
public class Icons : ScriptableObject
{
public Texture2D plus;
public Texture2D minus;
private const string AssetPath = "Icons";
private static Icons _instance;
public static Icons Instance {
get { return _instance ?? (_instance = Resources.Load<Icons>(AssetPath)); }
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 32eff58a98b2e4c43a9a375c7db56e25
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,85 @@
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
public class LoginScreen : MonoBehaviour
{
public FlatButton LoginButton;
public FlatButton RegisterButton;
public TMP_InputField Server;
public TMP_InputField EmailUsername;
public TMP_InputField Email;
public TMP_InputField Username;
public TMP_InputField Password;
public TextMeshProUGUI Error;
private bool _registering;
void Start()
{
Error.text = " ";
LoginButton.CurrentState = FlatButtonState.Selected;
CultClient.AddMessageListener<LoginSuccessMessage>(success => SceneManager.LoadScene("Main"));
CultClient.OnError += s => Error.text = s;
RegisterButton.OnClick += _ =>
{
if(!CultClient.Connected)
CultClient.Connect(Server.text);
if (_registering)
{
CultClient.Register(Email.text, Username.text, Password.text);
}
else
{
_registering = true;
EmailUsername.gameObject.SetActive(false);
Email.gameObject.SetActive(true);
Username.gameObject.SetActive(true);
LoginButton.CurrentState = FlatButtonState.Unselected;
RegisterButton.CurrentState = FlatButtonState.Selected;
}
};
LoginButton.OnClick += _ =>
{
if(!CultClient.Connected)
CultClient.Connect(Server.text);
if (_registering)
{
_registering = false;
EmailUsername.gameObject.SetActive(true);
Email.gameObject.SetActive(false);
Username.gameObject.SetActive(false);
LoginButton.CurrentState = FlatButtonState.Selected;
RegisterButton.CurrentState = FlatButtonState.Unselected;
}
else
{
CultClient.Login(EmailUsername.text, Password.text);
}
};
}
private void Update()
{
if (Input.GetKeyDown(KeyCode.Tab) || Input.GetKeyDown(KeyCode.Return))
{
if (Server.isFocused)
{
if(_registering)
Email.Select();
else EmailUsername.Select();
}
else if (EmailUsername.isFocused)
Password.Select();
else if (Email.isFocused)
Username.Select();
else if (Username.isFocused)
Password.Select();
else if (Password.isFocused && Input.GetKeyDown(KeyCode.Return))
(_registering ? RegisterButton : LoginButton).OnPointerClick(null);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a16898360275ccb489eef6245639fb56
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,216 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Text.RegularExpressions;
using JM.LinqFaster;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class PropertiesPanel : MonoBehaviour
{
public Prototype LabelField;
public Prototype FreeFloatField;
public Prototype RangedFloatField;
public Prototype EnumField;
public Prototype BoolField;
public Prototype ColorField;
public Prototype Divider;
public int ResolutionExponentMinumum = 6;
public int ResolutionExponentCount = 5;
private readonly List<Prototype> _propertyFields = new List<Prototype>();
private event EventHandler RefreshPropertyValues;
public void Clear()
{
foreach (var property in _propertyFields.ReverseF())
{
property.ReturnToPool();
}
RefreshPropertyValues = null;
}
public void Inspect(object obj, bool inspectablesOnly = false, bool readWrite = false, bool topLevel = false)
{
if(topLevel)
Clear();
var fields = obj.GetType().GetFields();
foreach (var field in fields)
Inspect(obj, field, inspectablesOnly, readWrite);
if(topLevel)
foreach (var field in _propertyFields)
field.transform.SetSiblingIndex(_propertyFields.IndexOf(field));
RefreshValues();
}
public void Inspect(object obj, FieldInfo field, bool inspectablesOnly = false, bool readWrite = false)
{
var inspectable = field.GetCustomAttribute<InspectableFieldAttribute>();
if (inspectable == null && inspectablesOnly) return;
var type = field.FieldType;
if (type == typeof(float))
{
if (readWrite)
{
var ranged = inspectable as RangedFloatInspectableAttribute;
if (ranged != null)
Inspect(field.Name.SplitCamelCase(), () => (float) field.GetValue(obj), f => field.SetValue(obj, f),
ranged.Min, ranged.Max);
else
Inspect(field.Name.SplitCamelCase(), () => (float) field.GetValue(obj), f => field.SetValue(obj, f));
} else Inspect(field.Name.SplitCamelCase(), () => ((float) field.GetValue(obj)).ToString("0.##"));
}
else if (type == typeof(int))
{
if (readWrite)
{
var ranged = inspectable as RangedIntInspectableAttribute;
if (ranged != null)
Inspect(field.Name.SplitCamelCase(), () => (int) field.GetValue(obj), f => field.SetValue(obj, f),
ranged.Min, ranged.Max);
else
Inspect(field.Name.SplitCamelCase(), () => (int) field.GetValue(obj), f => field.SetValue(obj, f));
} else Inspect(field.Name.SplitCamelCase(), () => ((int) field.GetValue(obj)).ToString());
}
else if (type.IsEnum)
{
if (readWrite)
Inspect(field.Name.SplitCamelCase(), () => (int) field.GetValue(obj), i => field.SetValue(obj, i),
Enum.GetNames(field.FieldType));
else
Inspect(field.Name.SplitCamelCase(), () => Enum.GetName(type, field.GetValue(obj)).SplitCamelCase());
}
else if (type == typeof(string))
{
if (readWrite)
Inspect(field.Name.SplitCamelCase(), () => (string) field.GetValue(obj), i => field.SetValue(obj, i));
else
Inspect(field.Name.SplitCamelCase(), () => (string) field.GetValue(obj));
}
//else if (field.FieldType == typeof(Color)) Inspect(field.Name, () => (Color) field.GetValue(obj), c => field.SetValue(obj, c));
else if (field.FieldType == typeof(bool)) Inspect(field.Name, () => (bool) field.GetValue(obj), b => field.SetValue(obj, b));
else if (type.GetCustomAttribute<InspectableFieldAttribute>() != null)
{
if(!_propertyFields.Any() || !_propertyFields.Last().gameObject.name.ToUpper().Contains("DIVIDER"))
_propertyFields.Add(Divider.Instantiate<Prototype>());
Inspect(field.GetValue(obj), inspectablesOnly, readWrite);
}
else
Debug.Log($"Field \"{field.Name}\" has unknown type {field.FieldType.Name}. No inspector was generated.");
}
public void Inspect(string name, Func<string> read)
{
var labelFieldInstance = LabelField.Instantiate<Prototype>();
_propertyFields.Add(labelFieldInstance);
labelFieldInstance.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = name;
var field = labelFieldInstance.transform.Find("Field").GetComponent<TextMeshProUGUI>();
field.text = read();
RefreshPropertyValues += (sender, args) => field.text = read();
}
public void Inspect(string name, Func<float> read, Action<float> write)
{
var freeFloatFieldInstance = FreeFloatField.Instantiate<Prototype>();
_propertyFields.Add(freeFloatFieldInstance);
freeFloatFieldInstance.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = name;
var inputField = freeFloatFieldInstance.GetComponentInChildren<TMP_InputField>();
inputField.contentType = TMP_InputField.ContentType.DecimalNumber;
inputField.onValueChanged.AddListener(val => write(float.Parse(val)));
RefreshPropertyValues += (sender, args) => inputField.text = read().ToString(CultureInfo.InvariantCulture);
}
public void Inspect(string name, Func<string> read, Action<string> write)
{
var freeFloatFieldInstance = FreeFloatField.Instantiate<Prototype>();
_propertyFields.Add(freeFloatFieldInstance);
freeFloatFieldInstance.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = name;
var inputField = freeFloatFieldInstance.GetComponentInChildren<TMP_InputField>();
inputField.contentType = TMP_InputField.ContentType.Standard;
inputField.onValueChanged.AddListener(val => write(val));
RefreshPropertyValues += (sender, args) => inputField.text = read();
}
public void Inspect(string name, Func<float> read, Action<float> write, float min, float max)
{
var rangedFloatFieldInstance = RangedFloatField.Instantiate<Prototype>();
_propertyFields.Add(rangedFloatFieldInstance);
rangedFloatFieldInstance.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = name;
var slider = rangedFloatFieldInstance.GetComponentInChildren<Slider>();
slider.minValue = min;
slider.maxValue = max;
slider.onValueChanged.AddListener(val => write(val));
RefreshPropertyValues += (sender, args) => slider.value = read();
}
public void Inspect(string name, Func<int> read, Action<int> write)
{
var freeFloatFieldInstance = FreeFloatField.Instantiate<Prototype>();
_propertyFields.Add(freeFloatFieldInstance);
freeFloatFieldInstance.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = name;
var inputField = freeFloatFieldInstance.GetComponentInChildren<TMP_InputField>();
inputField.contentType = TMP_InputField.ContentType.IntegerNumber;
inputField.onValueChanged.AddListener(val => write(int.Parse(val)));
RefreshPropertyValues += (sender, args) => inputField.text = read().ToString(CultureInfo.InvariantCulture);
}
public void Inspect(string name, Func<int> read, Action<int> write, int min, int max)
{
var rangedFloatFieldInstance = RangedFloatField.Instantiate<Prototype>();
_propertyFields.Add(rangedFloatFieldInstance);
rangedFloatFieldInstance.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = name;
var slider = rangedFloatFieldInstance.GetComponentInChildren<Slider>();
slider.wholeNumbers = true;
slider.minValue = min;
slider.maxValue = max;
slider.onValueChanged.AddListener(val => write(Mathf.RoundToInt(val)));
RefreshPropertyValues += (sender, args) => slider.value = read();
}
// public void Inspect(string name, Func<Color> read, Action<Color> write)
// {
// var colorFieldInstance = ColorField.Instantiate<Prototype>();
// _propertyFields.Add(colorFieldInstance);
// colorFieldInstance.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = name;
// var colorButton = colorFieldInstance.GetComponentInChildren<ColorButton>();
// colorButton.OnColorChanged.AddListener(col => write(col));
// RefreshPropertyValues += (sender, args) => colorButton.GetComponent<Image>().color = read();
// }
public void Inspect(string name, Func<bool> read, Action<bool> write)
{
var boolFieldInstance = BoolField.Instantiate<Prototype>();
_propertyFields.Add(boolFieldInstance);
boolFieldInstance.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = name;
var toggle = boolFieldInstance.GetComponentInChildren<Toggle>();
toggle.onValueChanged.AddListener(val => write(val));
RefreshPropertyValues += (sender, args) => toggle.isOn = read();
}
public void Inspect(string name, Func<int> read, Action<int> write, string[] enumOptions)
{
var enumFieldInstance = EnumField.Instantiate<Prototype>();
_propertyFields.Add(enumFieldInstance);
enumFieldInstance.transform.Find("Label").GetComponent<TextMeshProUGUI>().text = name;
var dropDown = enumFieldInstance.GetComponentInChildren<TMP_Dropdown>();
dropDown.options = enumOptions.Select(s => new TMP_Dropdown.OptionData(s)).ToList();
dropDown.onValueChanged.AddListener(val => write(val));
RefreshPropertyValues += (sender, args) => dropDown.value = read();
}
public void RefreshValues()
{
RefreshPropertyValues?.Invoke(this, EventArgs.Empty);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 522d91e5cc66d574486096884d806861
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,15 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TabActivator : MonoBehaviour
{
public TabGroup TabGroup;
public TabButton TabButton;
void Start()
{
TabGroup.OnTabChange += button => gameObject.SetActive(button == TabButton);
gameObject.SetActive(false);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5f60c7818169f95468915fbca3ef4773
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: -50
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,12 @@
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class TabButton : FlatButton
{
public RectTransform Tab;
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4ec4ae0999e1b814cbb86e167df3c039
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,36 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class TabGroup : MonoBehaviour
{
public event Action<TabButton> OnTabChange;
private TabButton[] _tabButtons;
private TabButton _currentButton;
private void Start()
{
_tabButtons = GetComponentsInChildren<TabButton>();
foreach (var thisButton in _tabButtons)
{
thisButton.OnClick += button =>
{
if (_currentButton != null)
{
_currentButton.CurrentState = FlatButtonState.Unselected;
_currentButton.Tab.gameObject.SetActive(false);
}
_currentButton = thisButton;
_currentButton.CurrentState = FlatButtonState.Selected;
_currentButton.Tab.gameObject.SetActive(true);
OnTabChange?.Invoke(_currentButton);
};
thisButton.Tab.gameObject.SetActive(false);
}
_tabButtons.First().OnPointerClick(null);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 828461d20e2142546814879a0a0f44b6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class ZoneObject : MonoBehaviour
{
public MeshRenderer GravityMesh;
public MeshRenderer Icon;
public TextMeshPro Label;
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 17a379c98cd100d4c8548e22c676d246
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,45 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ZoneRenderer : MonoBehaviour
{
public Camera FollowCamera;
public RenderTexture GravityTexture;
public MeshRenderer GravityRenderer;
private int _resX, _resY;
private float _ratio;
private Camera _camera;
private void Start()
{
_camera = GetComponent<Camera>();
}
private void OnPreRender()
{
_camera.transform.position = FollowCamera.transform.position;
if (Screen.width != _resX || Screen.height != _resY)
{
_resX = Screen.width;
_resY = Screen.height;
_ratio = (float) _resX / _resY;
if (GravityTexture != null)
{
GravityTexture?.Release();
}
GravityTexture = new RenderTexture(_resX, _resY, 0, RenderTextureFormat.RFloat);
}
GravityRenderer.material.mainTexture = GravityTexture;
var size = _camera.orthographicSize = FollowCamera.orthographicSize;
GravityRenderer.transform.position = new Vector3(transform.position.x, transform.position.y, 0);
GravityRenderer.transform.localScale = new Vector3(size * 2 * _ratio, size * 2, 1);
_camera.targetTexture = GravityTexture;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 04277e392af12204397c334ea824f957
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: