-
-
Save todorok1/fa4fd8558f2c31c3eb56b2827be0b298 to your computer and use it in GitHub Desktop.
エディタ上でパーリンノイズによる地形を生成するサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <Summary> | |
/// 指定されたコンポーネントへの参照を取得します。 | |
/// コンポーネントがない場合はアタッチします。 | |
/// </Summary> | |
T CheckComponent<T>(GameObject obj) where T : Component | |
{ | |
// 型パラメータで指定したコンポーネントへの参照を取得します。 | |
var targetComp = obj.GetComponent<T>(); | |
if (targetComp == null) | |
{ | |
targetComp = obj.AddComponent<T>(); | |
} | |
return targetComp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment