04-04-2020, Saat: 22:53
Linkleri görüntüleyebilmek için Kayıt ol manız veya Giriş yapmanız gerekiyor.Anlayışınız için teşekkürler.!
Böyle Bir Ekranım Var Kapama Buttonu Oluşturdum Şimdi Bu Fotoğrafı Haraket Ettiriyorum Sürekleme Kodu Yazılı Ama Bu Sefer Button Geride Kalıyor Haliyle Basınca Kapanmıyor Bunu Burdaki Resimi Nasıl Bağlarım Resim Haraket Ettimi Oda Onla Beraber Hareket Edicek Haraket Kodlarımda Bunlar
Alıntı:using System.Collections;[url=https://hizliresim.com/ixFbbF][/url]
using System.Collections.Generic;
using UnityEngine;
public class sürükleme : MonoBehaviour
{
private bool dragItem = false;
private GameObject dragObject;
private Vector2 touchoffset;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (HasInput)
{
Drag();
}
else
{
if(dragItem)
{
Drop();
}
}
}
private bool HasInput
{
get {
return Input.GetMouseButton(0);
}
}
private void Drag()
{
var InputPosition = Position;
if (dragItem)
{
dragObject.transform.position = InputPosition + touchoffset;
}
else
{
RaycastHit2D[] touches = Physics2D.RaycastAll(InputPosition, InputPosition, 0.5f);
if (touches.Length>0)
{
var hit = touches[0];
if (hit.transform != null )
{
dragItem = true;
dragObject = hit.transform.gameObject;
touchoffset = (Vector2)hit.transform.position - InputPosition;
dragObject.transform.localScale = new Vector3 (1.775139f, 2.130574f, 0.5f);
}
}
}
}
Vector2 Position
{
get
{
return Camera.main.ScreenToWorldPoint(Input.mousePosition);
}
}
void Drop ()
{
dragItem = false;
dragObject.transform.localScale = new Vector3(1.775139f, 2.130574f, 0.5f);
}
}
Böyle Bir Ekranım Var Kapama Buttonu Oluşturdum Şimdi Bu Fotoğrafı Haraket Ettiriyorum Sürekleme Kodu Yazılı Ama Bu Sefer Button Geride Kalıyor Haliyle Basınca Kapanmıyor Bunu Burdaki Resimi Nasıl Bağlarım Resim Haraket Ettimi Oda Onla Beraber Hareket Edicek Haraket Kodlarımda Bunlar