Skip to content

Instantly share code, notes, and snippets.

@adash333
Created August 18, 2019 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adash333/cad6813e7de67ec347405c2ae0723424 to your computer and use it in GitHub Desktop.
Save adash333/cad6813e7de67ec347405c2ae0723424 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ButtonHandler : MonoBehaviour {
GameObject car;
// Use this for initialization
void Start () {
this.car = GameObject.Find ("car");
}
// Update is called once per frame
void Update () {
}
public void OnClick() {
Debug.Log ("Clicked");
// transformを取得
Transform myTransform = this.car.transform;
// World座標を基準に、座標を取得
Vector2 worldPos = myTransform.position;
worldPos.x = -2.8f;
worldPos.y = -2.9f;
myTransform.position = worldPos;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment