###前提・実現したいこと
Unity超初心者です。
オブジェクトをマウスドラッグでプレイ中に移動できるようにするソースがあり、
どれも同じようにプレハブ化しているつもりなのですが、できるものとできないものがあります。
できないものに関しては、ソースファイルをAddComponentした後にドラッグしてもまったく反応がなく、コンソールにも何もでてこない状態です。
何か心当たりがあったりするでしょうか?
###該当のソースコード
↓以下のソースが該当のものです。
//The original code is obtained from http://answers.unity3d.com/questions/581904/2d-mode-trying-to-make-a-sprite-dragable.html for my future reference. //By Shatcore 2013 using UnityEngine; using System.Collections; public class ButtonClick : MonoBehaviour { float x; float y; // Update is called once per frame void Update(){ x = Input.mousePosition.x; y = Input.mousePosition.y; } void OnMouseDrag(){ transform.position = Camera.main.ScreenToWorldPoint(new Vector3(x,y,10.0f)); } }
よろしくお願いいたします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。