Skip to content

Instantly share code, notes, and snippets.

@takashi1975
Created July 24, 2019 00:08
Show Gist options
  • Save takashi1975/fbd3279907a9a0b568a0d3e18e24594e to your computer and use it in GitHub Desktop.
Save takashi1975/fbd3279907a9a0b568a0d3e18e24594e to your computer and use it in GitHub Desktop.
Unity DrawLine multi (いったん描画したら機能停止させる)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DrawLineManager : MonoBehaviour
{
[field: SerializeField]
public GameObject prefabDrawLine { get; private set; }
[field: SerializeField]
public GameObject currentDrawLine { get; private set; }
void Start() {
this.currentDrawLine = Instantiate(this.prefabDrawLine, this.transform);
}
void Update()
{
if (Input.GetMouseButtonUp(0)) {
//描画機能停止
if (this.currentDrawLine != null) {
this.currentDrawLine.GetComponent<DrawLine>().enabled = false;
}
this.currentDrawLine = Instantiate(this.prefabDrawLine, this.transform);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment