Skip to content

Instantly share code, notes, and snippets.

Shader "Custom/Snow" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_Snow("Snow", Range(0,2))= 0.0
}
SubShader {
Tags { }
@maco1028
maco1028 / ParticleCol.cs
Created May 5, 2017 19:06
パーティクル衝突
void OnParticleCollision(GameObject objct){
//衝突したオブジェクトタグがenemyだった場合、オブジェクトを破壊する
if(obj.gameObject.tag == "enemy"){
Object.Destroy(gameObject);
}
}
@maco1028
maco1028 / hide_change.cs
Created May 6, 2017 18:49
表示非表示1
public class Hoge : MonoBehaviour
{
private int _frame = 0;
// Use this for initialization
void Start ()
{
}
@maco1028
maco1028 / unitymain.cs
Last active September 14, 2021 04:12
よく使うUnityスクリプト
1.現在のシーン名を判定
if(Application.loadedLevelName == "main"){
scene = true;
}else{
scene = false;
}
2.回転させる
this.transform.Rotate (new Vector3 (0, 0, 5 * Time.deltaTime));
@maco1028
maco1028 / hide_change.cs
Created May 7, 2017 08:52
表示非表示2
public GameObject[] Num_spline = new GameObject[10];
public bool parchk=true;
void Start () {
}
void Update () {
if (Input.GetMouseButtonDown(0)) {
@maco1028
maco1028 / script_onoff.cs
Created May 7, 2017 09:01
ScriptをON OFF
// ボタンの設定
function OnGUI () {
// バッググラウンドと名前設定
GUI.Box (Rect (10,10,100,90), "メニュー");
// ボタンの位置と名前設定
if (GUI.Button (Rect (20,40,80,20), "Script ON")) {
// ボタン押した時に実行したいもの
GetComponent(スクリプト名).enabled = true;
}
if (GUI.Button (Rect (20,70,80,20), "Script OFF")) {
@maco1028
maco1028 / DoubleSide.cs
Created May 7, 2017 09:04
両面シェーダー
Shader "DoubleSide" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
Cull off
@maco1028
maco1028 / date.cs
Last active May 7, 2017 13:29
日付取得
// 現在時刻の取得
System.DateTime now = System.DateTime.Now;
int nowMonth;
int nowDay;
now = System.DateTime.Now;
nowMonth = now.Month;
nowDay = now.Day;
@maco1028
maco1028 / RotateObject.cs
Last active June 6, 2018 13:25
回転 #unity
transform.Rotate(X * Time.deltaTime, Y * Time.deltaTime, Z * Time.deltaTime);
@maco1028
maco1028 / click.cs
Created July 10, 2017 22:17
クリックしたオブジェクトの取得
// 左クリックしたオブジェクトを取得する関数(3D)
public GameObject getClickObject() {
GameObject result = null;
// 左クリックされた場所のオブジェクトを取得
if(Input.GetMouseButtonDown(0)) {
   Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
   RaycastHit hit = new RaycastHit();
   if (Physics.Raycast(ray, out hit)){
     result = hit.collider.gameObject;
   }