unity 2d Drag object
C#
private Vector2 screenPoint;
private Vector3 offset;
void OnMouseDown() {
offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint(new Vector2(Input.mousePosition.x, Input.mousePosition.y));
}
void OnMouseDrag()
{
Vector2 curScreenPoint = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
Vector2 curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint) + offset;
transform.position = curPosition;
}
Also in C#:
- Title
- how to import datagridview to datatable in c#
- Category
- C#
- Title
- c# make request to rest api
- Category
- C#
- Title
- 5 second timer in c#
- Category
- C#
- Title
- unity pro version free download
- Category
- C#
- Title
- unity accessing 2d pointlight from c# script
- Category
- C#
- Title
- C# invoke
- Category
- C#
- Title
- c# data types
- Category
- C#
- Title
- c# instantiate
- Category
- C#
- Title
- go right unity
- Category
- C#
- Title
- c# winform remove button border
- Category
- C#
- Title
- repeater itemdatabound event in c#
- Category
- C#
- Title
- create expression func c# for use in where clause
- Category
- C#
- Title
- c# check internet connection easy
- Category
- C#
- Title
- freeze position unity c#
- Category
- C#
- Title
- .net directorysearcher get manager accountname
- Category
- C#
- Title
- c# convert list to string
- Category
- C#
- Title
- how to convert string to bool c#
- Category
- C#
- Title
- c# remove specific character from string
- Category
- C#
- Title
- run async methods within a sync process
- Category
- C#
- Title
- C# int to hex
- Category
- C#
- Title
- c# warning CS0108
- Category
- C#
- Title
- C# Into To Tring Debug.Log
- Category
- C#
- Title
- unity3d find y position on navmesh
- Category
- C#
- Title
- c# date
- Category
- C#
- Title
- how to crouch in unity
- Category
- C#
- Title
- split on uppercase c#
- Category
- C#
- Title
- make string
- Category
- C#
- Title
- how to see if they are aholding down a key unity
- Category
- C#
- Title
- how to change an int value c#
- Category
- C#
- Title
- how to remove space between string in c#
- Category
- C#
- Title
- c# linq select from object list
- Category
- C#
- Title
- compose graphql query string in c#
- Category
- C#
- Title
- verifyusertokenasync password reset token
- Category
- C#
- Title
- polling data source c# using threads
- Category
- C#
- Title
- Execute code every x seconds with Update()
- Category
- C#
- Title
- c# abstract class
- Category
- C#
- Title
- how to work with ascii in c#
- Category
- C#
- Title
- codecademy
- Category
- C#
- Title
- unknown discriminator value mongodb
- Category
- C#
- Title
- while loop c#
- Category
- C#
- Title
- .net 4.5 use tls 1.2
- Category
- C#
- Title
- c# round number
- Category
- C#
- Title
- Request.ServerVariables["HTTP_X_FORWARDED_FOR"] get only one ipaddress
- Category
- C#
- Title
- to list c#
- Category
- C#
- Title
- how to trim path in C#
- Category
- C#
- Title
- csharp first element of array
- Category
- C#
- Title
- Celsius to Fahrenheit c#
- Category
- C#
- Title
- c# store generic type without arguments
- Category
- C#
- Title
- c# unity rotate first person controller script
- Category
- C#
- Title
- c# to vb.net
- Category
- C#
- Title
- unity movetowards 2d
- Category
- C#
- Title
- round vector3 unity
- Category
- C#
- Title
- how to compare datetime in c#
- Category
- C#
- Title
- get normal from 3 points
- Category
- C#
- Title
- xamarin forms alarm
- Category
- C#
- Title
- unity atan value
- Category
- C#
- Title
- csharp create array list
- Category
- C#
- Title
- c# length of array
- Category
- C#
- Title
- c# file exist
- Category
- C#
- Title
- how to select time and date in datetimepicker in c#
- Category
- C#
- Title
- How to get number of months between 2 dates c#
- Category
- C#
- Title
- unity get number of child objects
- Category
- C#
- Title
- c# random string
- Category
- C#
- Title
- find month number from date C#
- Category
- C#
- Title
- get gameobject child by name
- Category
- C#
- Title
- string to enum c# 3
- Category
- C#
- Title
- c# map
- Category
- C#
- Title
- c# .net core memory cache
- Category
- C#
- Title
- how to generate random unique id in c#
- Category
- C#
- Title
- uwp file open picker
- Category
- C#
- Title
- convert string to decimal c#
- Category
- C#
- Title
- vb.net tostring numeric format string
- Category
- C#
- Title
- order by C#
- Category
- C#
- Title
- c# catch two exceptions in one block
- Category
- C#
- Title
- chase object unity
- Category
- C#
- Title
- instantiate object in circle
- Category
- C#
- Title
- unity add sections to a list
- Category
- C#
- Title
- iphone
- Category
- C#
- Title
- godot c# move towards
- Category
- C#
- Title
- public enum c#
- Category
- C#
- Title
- c# get pc ip address
- Category
- C#
- Title
- datetitime contrusctor c#
- Category
- C#
- Title
- asp.net tag helper checkbox
- Category
- C#
- Title
- unity 2d enemy field of view
- Category
- C#
- Title
- unity set position
- Category
- C#
- Title
- linq foreach c#
- Category
- C#
- Title
- create line in unity
- Category
- C#
- Title
- c# array inst working
- Category
- C#
- Title
- how to flip selection in aseprite
- Category
- C#
- Title
- c# get full URL of page
- Category
- C#
- Title
- how to delete transition unity
- Category
- C#
- Title
- print content of array c#
- Category
- C#
- Title
- unity making homing missile
- Category
- C#
- Title
- c# string to byte array
- Category
- C#
- Title
- declare string array c# without size
- Category
- C#
- Title
- c# sql duplicate key exception
- Category
- C#
- Title
- vector between two points unity
- Category
- C#
- Title
- asp net identity add a unique fields to user
- Category
- C#
- Title
- how to add a list to observablecollection in c#
- Category
- C#
- Title
- c# write to console
- Category
- C#