drag object unity 2d
C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DragAndDrop : MonoBehaviour
{
private bool isDragging;
public void OnMouseDown()
{
isDragging = true;
}
public void OnMouseUp()
{
isDragging = false;
}
void Update()
{
if (isDragging) {
Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
transform.Translate(mousePosition);
}
}
}
Also in C#:
- Title
- when do i need to end a sentence with ; in c#
- Category
- C#
- Title
- unity addforceatposition
- Category
- C#
- Title
- c# empty array
- Category
- C#
- Title
- read embedded resource c# xml
- Category
- C#
- Title
- const float c#
- Category
- C#
- Title
- c# else if
- Category
- C#
- Title
- c# bitmap to picturebox
- Category
- C#
- Title
- c# string methods
- Category
- C#
- Title
- rotate to face direction
- Category
- C#
- Title
- vector3.lerp
- Category
- C#
- Title
- transform.translate unity
- Category
- C#
- Title
- c sharp string interpolation
- Category
- C#
- Title
- how to create a list c#
- Category
- C#
- Title
- f reachable queue in c#
- Category
- C#
- Title
- get gameobject child by name
- Category
- C#
- Title
- unity rotate vector
- Category
- C#
- Title
- dictionary update c#
- Category
- C#
- Title
- if get key down unity
- Category
- C#
- Title
- max of array C#
- Category
- C#
- Title
- c# empty char
- Category
- C#
- Title
- unity onselect gizmos wireframe
- Category
- C#
- Title
- unity up arrow input
- Category
- C#
- Title
- c# web form compare dates
- Category
- C#
- Title
- MVC creating a counter for products
- Category
- C#
- Title
- void start
- Category
- C#
- Title
- c# exit program
- Category
- C#
- Title
- call stored proc c#
- Category
- C#
- Title
- unity 2d Drag object
- Category
- C#
- Title
- c# repeat string x times
- Category
- C#
- Title
- how to make a string a list of characters c#
- Category
- C#
- Title
- add getenumerator to class c#
- Category
- C#
- Title
- scaffold-dbcontext sql server
- Category
- C#
- Title
- winforms timer c#
- Category
- C#
- Title
- double tryparse dot comma
- Category
- C#
- Title
- how do i foreach c#
- Category
- C#
- Title
- eventos c#
- Category
- C#
- Title
- how to make a for loop in c#
- Category
- C#
- Title
- index in foreach c#
- Category
- C#
- Title
- convert int to double c#
- Category
- C#
- Title
- unity deactive code from code
- Category
- C#
- Title
- C# webclient submit form
- Category
- C#
- Title
- unity rotate object relative to camera
- Category
- C#
- Title
- making a list of chars in c#
- Category
- C#
- Title
- how to find the area of a circle
- Category
- C#
- Title
- Generate Genealogy view in mvc C# using Google Organizational Chart
- Category
- C#
- Title
- c# implement ienumerable t
- Category
- C#
- Title
- while loop in c#
- Category
- C#
- Title
- unity prevent object from leaving camera view
- Category
- C#
- Title
- c# list get sublist
- Category
- C#
- Title
- unity check if gameobject is active
- Category
- C#
- Title
- math class C# exponents
- Category
- C#
- Title
- c# get every point in a line in matrix
- Category
- C#
- Title
- c# reverse array
- Category
- C#
- Title
- .net core change localhost port
- Category
- C#
- Title
- asp.net tag helper checkbox
- Category
- C#
- Title
- c# get the last item in a list
- Category
- C#
- Title
- c# list to string comma separated
- Category
- C#
- Title
- how to find object by ag unity
- Category
- C#
- Title
- how to create a variable in C#
- Category
- C#
- Title
- create dropdown in datatable c# dynamically
- Category
- C#
- Title
- how to compare datetime in c#
- Category
- C#
- Title
- dynamic group by expression C#
- Category
- C#
- Title
- how to get object to spawn in a curcle
- Category
- C#
- Title
- c# max two values
- Category
- C#
- Title
- c# linq select specific columns
- Category
- C#
- Title
- downlaod file and use C#
- Category
- C#
- Title
- xamarin hide back button
- Category
- C#
- Title
- how to clear console through script unity
- Category
- C#
- Title
- how to flip selection in aseprite
- Category
- C#
- Title
- get hash c#
- Category
- C#
- Title
- textbox in xamarin forms
- Category
- C#
- Title
- is start called after dontdestroyonload
- Category
- C#
- Title
- use newtonsoft json to clone object
- Category
- C#
- Title
- zoom gedit
- Category
- C#
- Title
- C# get pc language
- Category
- C#
- Title
- convert string to number C#
- Category
- C#
- Title
- c# how to open file explorer
- Category
- C#
- Title
- asp.net list all files in folder
- Category
- C#
- Title
- c# long to int
- Category
- C#
- Title
- viewBag as a list
- Category
- C#
- Title
- unity inspector header attribute
- Category
- C#
- Title
- unity variable from another script
- Category
- C#
- Title
- c# linq join multiple conditions
- Category
- C#
- Title
- how to access the dictionary from another script in unity
- Category
- C#
- Title
- install .net sdk ubuntu 20
- Category
- C#
- Title
- c# compare type
- Category
- C#
- Title
- perlin noise unity
- Category
- C#
- Title
- parsing string to int c#
- Category
- C#
- Title
- first sentence letter capital in c#
- Category
- C#
- Title
- unity rigidbody constraints
- Category
- C#
- Title
- collision detector unity c# 2d
- Category
- C#
- Title
- .net loop through dictionary
- Category
- C#
- Title
- unknown discriminator value mongodb
- Category
- C#
- Title
- c# get char from string
- Category
- C#
- Title
- what does gameobject.find return
- Category
- C#
- Title
- query associative table ef6
- Category
- C#
- Title
- c# return multiple value unity
- Category
- C#
- Title
- add object to list c#
- Category
- C#
- Title
- hasmap c#
- Category
- C#
- Title
- 2d movement unity
- Category
- C#