UnityEngine.Object.FindObjectOfType C# (CSharp) Method

FindObjectOfType() public static method

public static FindObjectOfType ( Type type ) : System.Object
type Type
return System.Object
		public static System.Object FindObjectOfType(Type type){}
		public static void DontDestroyOnLoad(System.Object target){}

Usage Example

コード例 #1
0
    public static T Get <T>()
    {
        object obj;

        objects.TryGetValue(typeof(T), out obj);

        if (obj == null)
        {
            if (typeof(Object).IsAssignableFrom(typeof(T)))
            {
                obj = Object.FindObjectOfType(typeof(T));
            }
            else
            {
                obj = Activator.CreateInstance <T>();
            }
            objects[typeof(T)] = obj;
        }

        return((T)obj);
    }
All Usage Examples Of UnityEngine.Object::FindObjectOfType