Assemblied created
This commit is contained in:
@ -3,50 +3,52 @@ using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[ExecuteAlways]
|
||||
public class ObjectiveText : MonoBehaviour
|
||||
namespace UI
|
||||
{
|
||||
[SerializeField] public List<VisualObjectiveItemGUI> visualObjects;
|
||||
|
||||
[SerializeField] private Color inCompleteColor = Color.white;
|
||||
|
||||
[SerializeField] private Color completeColor = Color.yellow;
|
||||
|
||||
[SerializeField] private float speed;
|
||||
|
||||
[SerializeField] private Animator animator;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
[ExecuteAlways]
|
||||
public class ObjectiveText : MonoBehaviour
|
||||
{
|
||||
[SerializeField] public List<VisualObjectiveItemGUI> visualObjects;
|
||||
|
||||
[SerializeField] private Color inCompleteColor = Color.white;
|
||||
|
||||
[SerializeField] private Color completeColor = Color.yellow;
|
||||
|
||||
[SerializeField] private float speed;
|
||||
|
||||
[SerializeField] private Animator animator;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
foreach (var item in visualObjects)
|
||||
if (item.isComplete)
|
||||
item.icon.color = Color.Lerp(item.icon.color, completeColor, Time.deltaTime * speed);
|
||||
else
|
||||
item.icon.color = Color.Lerp(item.icon.color, inCompleteColor, Time.deltaTime * speed);
|
||||
}
|
||||
|
||||
public void FadeOut()
|
||||
{
|
||||
animator.Play("FadeOut");
|
||||
}
|
||||
|
||||
public void FadeIn()
|
||||
{
|
||||
animator.Play("FadeIn");
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
[Serializable]
|
||||
public class VisualObjectiveItemGUI
|
||||
{
|
||||
foreach (var item in visualObjects)
|
||||
if (item.isComplete)
|
||||
item.icon.color = Color.Lerp(item.icon.color, completeColor, Time.deltaTime * speed);
|
||||
else
|
||||
item.icon.color = Color.Lerp(item.icon.color, inCompleteColor, Time.deltaTime * speed);
|
||||
}
|
||||
|
||||
public void FadeOut()
|
||||
{
|
||||
animator.Play("FadeOut");
|
||||
}
|
||||
|
||||
public void FadeIn()
|
||||
{
|
||||
animator.Play("FadeIn");
|
||||
public TMP_Text text;
|
||||
public Image icon;
|
||||
public bool isComplete;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class VisualObjectiveItemGUI
|
||||
{
|
||||
public TMP_Text text;
|
||||
public Image icon;
|
||||
public bool isComplete;
|
||||
}
|
16
Assets/Scripts/UI/UI_Definition.asmdef
Normal file
16
Assets/Scripts/UI/UI_Definition.asmdef
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "UI_Definition",
|
||||
"rootNamespace": "UI",
|
||||
"references": [
|
||||
"GUID:6055be8ebefd69e48b49212b09b47b2f"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
7
Assets/Scripts/UI/UI_Definition.asmdef.meta
Normal file
7
Assets/Scripts/UI/UI_Definition.asmdef.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d3648da7fb990349a7d848d55c40947
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,49 +1,51 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class WaypointMarker : MonoBehaviour
|
||||
namespace UI
|
||||
{
|
||||
public Image pointer;
|
||||
public Transform target;
|
||||
public TMP_Text distanceMarker;
|
||||
|
||||
private Vector2 offset;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
public class WaypointMarker : MonoBehaviour
|
||||
{
|
||||
offset = distanceMarker.transform.position - pointer.transform.position;
|
||||
}
|
||||
public Image pointer;
|
||||
public Transform target;
|
||||
public TMP_Text distanceMarker;
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
var minX = pointer.GetPixelAdjustedRect().width / 2;
|
||||
var maxX = Screen.width - minX;
|
||||
var minY = pointer.GetPixelAdjustedRect().height / 2;
|
||||
var maxY = Screen.height - minY;
|
||||
private Vector2 offset;
|
||||
|
||||
Vector2 pos = Camera.main.WorldToScreenPoint(target.position);
|
||||
|
||||
if (Vector3.Dot(target.position - Camera.main.transform.position, Camera.main.transform.forward) < 0)
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
//target is behind player
|
||||
if (pos.x < Screen.width / 2)
|
||||
pos.x = maxX;
|
||||
else
|
||||
pos.x = minX;
|
||||
offset = distanceMarker.transform.position - pointer.transform.position;
|
||||
}
|
||||
|
||||
pos.x = Mathf.Clamp(pos.x, minX, maxX);
|
||||
pos.y = Mathf.Clamp(pos.y, minY, maxY);
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
var minX = pointer.GetPixelAdjustedRect().width / 2;
|
||||
var maxX = Screen.width - minX;
|
||||
var minY = pointer.GetPixelAdjustedRect().height / 2;
|
||||
var maxY = Screen.height - minY;
|
||||
|
||||
pointer.transform.position = pos;
|
||||
distanceMarker.text =
|
||||
Mathf.RoundToInt(Vector3.Distance(Camera.main.transform.position, target.transform.position)) + " meters";
|
||||
if (pos.x < Screen.width / 2)
|
||||
distanceMarker.transform.position = pos + offset;
|
||||
else
|
||||
distanceMarker.transform.position = pos - offset;
|
||||
Vector2 pos = Camera.main.WorldToScreenPoint(target.position);
|
||||
|
||||
if (Vector3.Dot(target.position - Camera.main.transform.position, Camera.main.transform.forward) < 0)
|
||||
{
|
||||
//target is behind player
|
||||
if (pos.x < Screen.width / 2)
|
||||
pos.x = maxX;
|
||||
else
|
||||
pos.x = minX;
|
||||
}
|
||||
|
||||
pos.x = Mathf.Clamp(pos.x, minX, maxX);
|
||||
pos.y = Mathf.Clamp(pos.y, minY, maxY);
|
||||
|
||||
pointer.transform.position = pos;
|
||||
distanceMarker.text =
|
||||
Mathf.RoundToInt(Vector3.Distance(Camera.main.transform.position, target.transform.position)) + " meters";
|
||||
if (pos.x < Screen.width / 2)
|
||||
distanceMarker.transform.position = pos + offset;
|
||||
else
|
||||
distanceMarker.transform.position = pos - offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user