Skip to content

Instantly share code, notes, and snippets.

@todorok1
todorok1 / SendMessageCaller.cs
Created August 11, 2020 08:35
SendMessageの呼び出し元スクリプトのサンプル
/// <Summary>
/// SendMessageを使って対象のスクリプトの処理を呼び出します。
/// </Summary>
public class SendMessageCaller : MonoBehaviour
{
public GameObject targetObj;
void Start()
{
targetObj.SendMessage("ShowLog");
@todorok1
todorok1 / NullCheckExample_01.cs
Created August 10, 2020 09:35
nullチェックをするコードのサンプル
/// <Summary>
/// AudioSourceへの参照がセットされているか確認する処理です。
/// </Summary>
void CheckAudioReference()
{
if (bgmAudio == null)
{
bgmAudio = gameObject.GetComponent<AudioSource>();
}
}
@todorok1
todorok1 / ShowDebugSample.cs
Created July 16, 2020 13:02
デバッグ文を出力するサンプル
int userNumber = 1234;
Debug.Log($"{userNumber}");
// これだと変数の中身だけ表示されて「わけがわからないよ」となる
// 1234
Debug.Log($"userNumber : {userNumber}");
// これなら変数名も出力される
// userNumber : 1234
@todorok1
todorok1 / EditorScriptSample.cs
Created July 8, 2020 11:53
Editorスクリプトのビルドエラー例
Assets/Images/EditorScriptSample.cs(7,35): error CS0246: The type or namespace name 'Editor' could not be found (are you missing a using directive or an assembly reference?)
@todorok1
todorok1 / CoroutineWaitSample.cs
Created July 8, 2020 08:44
コルーチンの待ち時間の書き方
IEnumerator WaitSample()
{
// 1.0秒処理を待ちます。
yield return new WaitForSeconds(1.0f);
// 待ち時間が終わった後に後続の処理が行われます。
}
@todorok1
todorok1 / AdSample_over_3_3.cs
Last active June 26, 2020 05:31
Unity Adsのバージョンが3.3以降の場合のサンプルコード
using UnityEngine;
using UnityEngine.Advertisements;
using UnityEngine.UI;
/// <Summary>
/// 広告のテストを行うサンプルコードです。
/// </Summary>
public class AdSample : MonoBehaviour, IUnityAdsListener
{
// Unity Adsを有効化した時に発行されるIDを記載します。
@todorok1
todorok1 / AdSample_2_x.cs
Created June 26, 2020 04:50
UnityAdsのバージョンが2.xの時のサンプルスクリプト
using UnityEngine;
using UnityEngine.Advertisements;
/// <Summary>
/// 広告のテストを行うサンプルコードです。
/// </Summary>
public class AdSample : MonoBehaviour
{
string placementId = "rewardedVideo";
@todorok1
todorok1 / project.pbxproj_post.txt
Created June 25, 2020 09:36
developmentRegionの変更後
developmentRegion = en;
hasScannedForEncodings = 1;
knownRegions = (
English,
en,
ja,
"ja-JP",
);
@todorok1
todorok1 / project.pbxproj_pre.txt
Created June 25, 2020 09:35
developmentRegionの変更前
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
en,
ja,
"ja-JP",
);
@todorok1
todorok1 / project.pbxproj.txt
Created June 25, 2020 08:56
プロジェクトの中身を見てみよう
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
Japanese,
French,
German,
en,
);