/// <summary>
        /// Creates an instance of this type and returns the result as the specified generic type.
        /// A raw instance will return the actual instance of the type as opposed to a <see cref="ScriptProxy"/> which allows for more control.
        /// The type will be constructed using the appropriate method (AddComponent, CreateInstance, new).
        /// </summary>
        /// <typeparam name="T">The generic type to return the instance as</typeparam>
        /// <param name="parent">The <see cref="GameObject"/> to attach the instance to or null if the type is not a <see cref="MonoBehaviour"/></param>
        /// <param name="parameters">The parameter list for the desired constructor. only used when the type does not inherit from <see cref="UnityEngine.Object"/></param>
        /// <returns>A raw instance as the specified generic type</returns>
        public T CreateRawInstance <T>(GameObject parent = null, params object[] parameters) //where T : class
        {
            // Call through
            ScriptProxy proxy = CreateInstance(parent);

            // Check the error
            if (proxy == null)
            {
                return(default(T));
            }

            // Get the instance
            return(proxy.GetInstanceAs <T>(false));
        }
        /// <summary>
        /// Creates a raw instance of this type.
        /// A raw instance will return the actual instance of the type as opposed to a <see cref="ScriptProxy"/> which allows for more control.
        /// The type will be constructed using the appropriate method (AddComponent, CreateInstance, new).
        /// </summary>
        /// <param name="parent">The <see cref="GameObject"/> to attach the instance to or null if the type is not a <see cref="MonoBehaviour"/></param>
        /// <param name="parameters">The parameter list for the desired constructor. only used when the type does not inherit from <see cref="UnityEngine.Object"/></param>
        /// <returns>A raw instance that can be cast to the desired type</returns>
        public object CreateRawInstance(GameObject parent = null, params object[] parameters)
        {
            // Call through
            ScriptProxy proxy = CreateInstance(parent, parameters);

            // Check for error
            if (proxy == null)
            {
                return(null);
            }

            // Get the instance
            return(proxy.Instance);
        }
Пример #3
0
 // Constructor
 internal ScriptPropertyProxy(bool isStatic, ScriptType type, ScriptProxy owner = null)
 {
     this.isStatic = isStatic;
     this.type     = type;
     this.owner    = owner;
 }