Unity-C#

 2024.07.07 unityC#  
 2024.05.15 unityC#  
 2024.05.15 unityC#  
 2022.11.06 unityC#  
 2022.11.06 unityC#  
 2022.11.06 unityC#  
 2022.11.06 unityC#  
 2022.11.06 unityC#  
 2022.08.16 spritekit  

MouseDrag


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour
{
 private Vector3 screenPoint;
  void OnMouseDrag()
 {
 screenPoint = Camera.main.WorldToScreenPoint(transform.position);
float screenX = Input.mousePosition.x;
// float screenY = Input.mousePosition.y;
float screenY = screenPoint.y;
 float screenZ = screenPoint.z;
 Vector3 currentScreenPoint = new Vector3(screenX, screenY, screenZ);
 Vector3 currentPosition = Camera.main.ScreenToWorldPoint(currentScreenPoint);
transform.position = currentPosition;
}
}
///////////////////////////////