Added custom cursor
This commit is contained in:
27
Assets/Scripts/FakeCursor.cs
Normal file
27
Assets/Scripts/FakeCursor.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class FakeCursor : MonoBehaviour
|
||||
{
|
||||
public Camera AttachedCamera;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Cursor.visible = false;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Vector3 absolutePosition = new()
|
||||
{
|
||||
x = Input.mousePosition.x / Screen.width * 1920,
|
||||
y = Input.mousePosition.y / Screen.height * 1080,
|
||||
z = 5f
|
||||
};
|
||||
transform.position = AttachedCamera.ScreenToWorldPoint(absolutePosition);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
Cursor.visible = true;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/FakeCursor.cs.meta
Normal file
11
Assets/Scripts/FakeCursor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 353f192b40556e34dada2d432a9ffa85
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -27,8 +27,6 @@ namespace InterfaceOff.WorldScene
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
/* Hides the cursor as a custom one is used */
|
||||
|
||||
/* Loads the JSON, temporary. TODO: Insert the JSON into this .cs file */
|
||||
string json = File.ReadAllText(Application.dataPath + "/Resources/playerframe.json");
|
||||
Frames = JsonUtility.FromJson<PlayerFrameInfoArray>(json).FrameInfo;
|
||||
|
||||
Reference in New Issue
Block a user