Skip to content

Instantly share code, notes, and snippets.

@ayutaz
Last active December 24, 2019 15:17
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 ayutaz/971413f526893516f39308246ced4265 to your computer and use it in GitHub Desktop.
Save ayutaz/971413f526893516f39308246ced4265 to your computer and use it in GitHub Desktop.
Particleを使用してエフェクト効果をつける(Unity,Particle pack)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CreateMagic : MonoBehaviour
{
public GameObject Prefab1;
public GameObject Prefab2;
public GameObject Prefab3;
public GameObject Prefab4;
public GameObject Prefab5;
public GameObject Prefab6;
public GameObject Prefab7;
public GameObject Prefab8;
public GameObject Prefab9;
private GameObject obj;
private GameObject Pre;
private Vector3 position;
// Start is called before the first frame update
void Start()
{
obj = GameObject.Find("Create");
}
// Update is called once per frame
void Update()
{
position = new Vector3(Random.Range(0f,10f),0f,0f);
if(Input.GetKeyDown(KeyCode.F1)) {
Pre = (GameObject)Instantiate (Prefab1,position, Quaternion.identity);
Pre.transform.parent = obj.transform;
}else if(Input.GetKeyDown(KeyCode.F2)){
Pre = (GameObject)Instantiate (Prefab2,position, Quaternion.identity);
Pre.transform.parent = obj.transform;
}else if(Input.GetKeyDown(KeyCode.F3)){
Pre = (GameObject)Instantiate (Prefab3,position, Quaternion.identity);
Pre.transform.parent = obj.transform;
}else if(Input.GetKeyDown(KeyCode.F4)){
Pre = (GameObject)Instantiate (Prefab4,position, Quaternion.identity);
Pre.transform.parent = obj.transform;
}else if(Input.GetKeyDown(KeyCode.F5)){
Pre = (GameObject)Instantiate (Prefab5,position, Quaternion.identity);
Pre.transform.parent = obj.transform;
}else if(Input.GetKeyDown(KeyCode.F6)){
Pre = (GameObject)Instantiate (Prefab6,position, Quaternion.identity);
Pre.transform.parent = obj.transform;
}else if(Input.GetKeyDown(KeyCode.F7)){
Pre = (GameObject)Instantiate (Prefab7,position, Quaternion.identity);
Pre.transform.parent = obj.transform;
}else if(Input.GetKeyDown(KeyCode.F8)){
Pre = (GameObject)Instantiate (Prefab8,position, Quaternion.identity);
Pre.transform.parent = obj.transform;
}else if(Input.GetKeyDown(KeyCode.F9)){
Pre = (GameObject)Instantiate (Prefab9,position, Quaternion.identity);
Pre.transform.parent = obj.transform;
}
}
}
@ayutaz
Copy link
Author

ayutaz commented Dec 24, 2019

スクリプトの種類を設定

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment