分割字符串:
Debug.Log(k.Substring(k.LastIndexOf('\\') + 1, k.Length - 1 - k.LastIndexOf(@"\")).Split('.')[2]);
跟随鼠标:
using UnityEngine;
public class Cursor : MonoBehaviour
{
public float speed = 8.0f;
public float distanceFromCamera = 5.0f;
void Update()
{
Vector3 mousePosition = Input.mousePosition;
mousePosition.z = distanceFromCamera;
Vector3 mouseScreenToWorld = Camera.main.ScreenToWorldPoint(mousePosition);
Vector3 position = Vector3.Lerp(transform.position, mouseScreenToWorld, 1.0f - Mathf.Exp(-speed * Time.deltaTime));
transform.position = position;
}
}
|