Last active
April 23, 2018 23:50
-
-
Save JunShimura/89945b453272d928d7d7e2cf1f73ce92 to your computer and use it in GitHub Desktop.
[Unity初心者Tips]確実に!必要なComponentを入れるRequire ComponentとReset() ref: https://qiita.com/JunShimura/items/6576eb63c19c2c9f0c0a
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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
[RequireComponent(typeof(TestClassB))] | |
[RequireComponent(typeof(TestClassC))] | |
[RequireComponent(typeof(Rigidbody))] | |
public class TestClassA : MonoBehaviour | |
{ | |
[SerializeField] | |
TestClassB testClassB; | |
[SerializeField] | |
TestClassC testClassC; | |
[SerializeField] | |
Rigidbody rigidBody; | |
[SerializeField] | |
GameController gameController; | |
[SerializeField] | |
TestEnemy testEnemy; | |
private void Reset() | |
{ | |
testClassB = GetComponent<TestClassB>(); | |
testClassC = GetComponent<TestClassC>(); | |
rigidBody = GetComponent<Rigidbody>(); | |
gameController = FindObjectOfType<GameController>(); | |
if (gameController == null) { | |
Debug.Log("ERROR!Gamecontroller not found"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment