导入ui
This commit is contained in:
40
Assets/Honeti/MorpheusGUI/Scripts/AnimatedCursor.cs
Normal file
40
Assets/Honeti/MorpheusGUI/Scripts/AnimatedCursor.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AnimatedCursor : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Texture2D[] _cursorTexturesArray;
|
||||
[SerializeField] private float _frameRate;
|
||||
[SerializeField] private int _heatPointX = 0;
|
||||
[SerializeField] private int _heatPointY = 0;
|
||||
|
||||
private int _currentFrame;
|
||||
private float _frameTimer;
|
||||
|
||||
bool animate = false;
|
||||
|
||||
public void ChangeCursor()
|
||||
{
|
||||
Cursor.SetCursor(_cursorTexturesArray[0], new Vector2(_heatPointX, _heatPointY), CursorMode.Auto);
|
||||
animate = true;
|
||||
}
|
||||
public void ResetCursor()
|
||||
{
|
||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
animate = false;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!animate) return;
|
||||
|
||||
_frameTimer -= Time.deltaTime;
|
||||
if (_frameTimer <= 0f)
|
||||
{
|
||||
_frameTimer += _frameRate;
|
||||
_currentFrame = (_currentFrame + 1) % _cursorTexturesArray.Length;
|
||||
Cursor.SetCursor(_cursorTexturesArray[_currentFrame], new Vector2(_heatPointX, _heatPointY), CursorMode.Auto);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Honeti/MorpheusGUI/Scripts/AnimatedCursor.cs.meta
Normal file
11
Assets/Honeti/MorpheusGUI/Scripts/AnimatedCursor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc2dd8555e715b946a894583baba997a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
21
Assets/Honeti/MorpheusGUI/Scripts/ChangeCursorOnHover.cs
Normal file
21
Assets/Honeti/MorpheusGUI/Scripts/ChangeCursorOnHover.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ChangeCursorOnHover : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Texture2D _cursorImege;
|
||||
[SerializeField] private int _heatPointX = 0;
|
||||
[SerializeField] private int _heatPointY = 0;
|
||||
// Start is called before the first frame update
|
||||
|
||||
public void ChangeCursor()
|
||||
{
|
||||
Cursor.SetCursor(_cursorImege, new Vector2(_heatPointX, _heatPointY), CursorMode.Auto);
|
||||
}
|
||||
|
||||
public void ResetCursor()
|
||||
{
|
||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 774feaa475775b7448e112c1fb0e5034
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user