diff options
Diffstat (limited to 'Runtime/Export/BaseClass.txt')
-rw-r--r-- | Runtime/Export/BaseClass.txt | 1174 |
1 files changed, 1174 insertions, 0 deletions
diff --git a/Runtime/Export/BaseClass.txt b/Runtime/Export/BaseClass.txt new file mode 100644 index 0000000..f083ca0 --- /dev/null +++ b/Runtime/Export/BaseClass.txt @@ -0,0 +1,1174 @@ +C++RAW + + +#include "UnityPrefix.h" +#include "Configuration/UnityConfigure.h" +#include "Runtime/Mono/MonoManager.h" +#include "Runtime/Graphics/Transform.h" +#include "Runtime/Utilities/PathNameUtility.h" +#include "Runtime/Input/InputManager.h" +#include "Runtime/Input/TimeManager.h" +#include "Runtime/Misc/ResourceManager.h" +#include "Runtime/Profiler/ProfilerImpl.h" +#include "Runtime/Mono/MonoBehaviour.h" +#include "Runtime/BaseClasses/Tags.h" +#include "Runtime/Misc/DebugUtility.h" +#include "Runtime/Misc/PlayerSettings.h" +#include "Runtime/GameCode/CloneObject.h" +#include "Runtime/Math/Random/Random.h" +#include "Runtime/Misc/PreloadManager.h" +#include "Runtime/Allocator/MemoryManager.h" +#include "Runtime/Audio/AudioClip.h" +#if ENABLE_AUDIO +#include "Runtime/Audio/AudioSource.h" +#include "Runtime/Audio/AudioListener.h" +#include "Runtime/Audio/AudioManager.h" +#include "Runtime/Audio/AudioReverbZone.h" +#include "Runtime/Audio/AudioReverbFilter.h" +#include "Runtime/Audio/AudioHighPassFilter.h" +#include "Runtime/Audio/AudioLowPassFilter.h" +#include "Runtime/Audio/AudioChorusFilter.h" +#include "Runtime/Audio/AudioDistortionFilter.h" +#include "Runtime/Audio/AudioEchoFilter.h" +#endif +#include "Runtime/Animation/Animation.h" +#include "Runtime/Math/Color.h" +#include "Runtime/Utilities/PlayerPrefs.h" +#include "Runtime/Camera/Camera.h" +#include "Runtime/Dynamics/RigidBody.h" +#include "Runtime/Utilities/Word.h" +#include "Runtime/Camera/Light.h" +#include "Runtime/Filters/Misc/TextMesh.h" +#include "Runtime/Dynamics/ConstantForce.h" +#include "Runtime/Filters/Renderer.h" +#include "Runtime/Misc/SaveAndLoadHelper.h" +#include "Runtime/Network/NetworkView.h" +#include "Runtime/Network/NetworkManager.h" +#include "Runtime/Camera/RenderLayers/GUIText.h" +#include "Runtime/Camera/RenderLayers/GUITexture.h" +#include "Runtime/Dynamics/Collider.h" +#include "Runtime/Dynamics/HingeJoint.h" +#include "Runtime/Filters/Particles/ParticleEmitter.h" +#include "Runtime/Misc/Player.h" +#include "Runtime/BaseClasses/IsPlaying.h" +#include "Runtime/Misc/CaptureScreenshot.h" +#include "Runtime/Misc/GameObjectUtility.h" +#include "Runtime/Misc/Plugins.h" +#include "Runtime/Misc/ResourceManagerUtility.h" +#include "Runtime/Utilities/PathNameUtility.h" +#include "Runtime/Utilities/File.h" +#include <ctime> +#include "Runtime/Input/GetInput.h" +#include "Runtime/NavMesh/NavMeshAgent.h" +#include "Runtime/NavMesh/NavMesh.h" +#include "Runtime/NavMesh/OffMeshLink.h" +#include "Runtime/Misc/BuildSettings.h" +#include "Runtime/Animation/AnimationManager.h" +#include "Runtime/Animation/AnimationClip.h" +#include "Runtime/BaseClasses/RefCounted.h" +#include "Runtime/Misc/GOCreation.h" +#include "Runtime/Utilities/URLUtility.h" +#include "Runtime/Graphics/ScreenManager.h" +#include "Runtime/Serialize/PersistentManager.h" +#include "Runtime/Shaders/GraphicsCaps.h" +#include "Runtime/Misc/SystemInfo.h" +#include "Runtime/Utilities/FileUtilities.h" +#include "Runtime/Misc/GraphicsDevicesDB.h" +#include "Configuration/UnityConfigureVersion.h" +#include "Runtime/Profiler/CollectProfilerStats.h" +#include "Runtime/File/ApplicationSpecificPersistentDataPath.h" +#include "Runtime/Mono/Coroutine.h" +#include "Runtime/Scripting/Scripting.h" +#include "Runtime/Scripting/ScriptingUtility.h" +#include "Runtime/Scripting/ScriptingExportUtility.h" +#include "Runtime/Scripting/GetComponent.h" +#include "Runtime/Scripting/Backend/ScriptingBackendApi.h" +#include "Runtime/Scripting/Backend/ScriptingTypeRegistry.h" +#include "Runtime/Scripting/ScriptingObjectWithIntPtrField.h" + +#if SUPPORT_REPRODUCE_LOG +#include "Runtime/Misc/ReproductionLog.h" +#endif + +#if WEBPLUG + #include "PlatformDependent/CommonWebPlugin/UnityWebStream.h" + #include "PlatformDependent/CommonWebPlugin/WebScripting.h" +#endif + +#if UNITY_EDITOR + #include "Editor/Src/EditorSettings.h" + #include "Editor/Src/EditorUserBuildSettings.h" + #include "Editor/Mono/MonoEditorUtility.h" +#endif + +#if UNITY_WII + #include "PlatformDependent/Wii/WiiUtility.h" +#endif + +using namespace Unity; + +/* + Mono defines a bool as either 1 or 2 bytes. + On windows a bool on the C++ side needs to be 2 bytes. + We use the typemap to map bool's to short's. + When using the C++ keyword and you want to export a bool value + to mono you have to use a short on the C++ side. +*/ + + +void PauseEditor (); +using namespace std; + +CSRAW +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Collections; +using System.Collections.Generic; +using UnityEngineInternal; + +namespace UnityEngine +{ + +[StructLayout (LayoutKind.Sequential)] +internal struct ReferenceData +{ + public int instanceID; + public IntPtr cachedPtr; +} + +// Bit mask that controls object destruction and visibility in inspectors +CSRAW [Flags] +ENUM HideFlags + // A normal, visible object. This is the default. + None = 0, + + // The object will not appear in the hierarchy and will not show up in the project view if it is stored in an asset. + HideInHierarchy = 1, + + // It is not possible to view it in the inspector + HideInInspector = 2, + + // The object will not be saved to the scene. __It will not be destroyed when a new scene is loaded__. + DontSave = 4, + + // The object is not be editable in the inspector + NotEditable = 8, + + // A combination of not shown in the hierarchy and not saved to to scenes. + HideAndDontSave = 13 +END + +// Options for how to send a message. +ENUM SendMessageOptions + // A receiver is required for SendMessage. + RequireReceiver = 0, + + // No receiver is required for SendMessage. + DontRequireReceiver = 1 +END + +// The various primitives that can be created using the GameObject.CreatePrimitive function. +CSRAW +ENUM PrimitiveType + // A sphere primitive + Sphere = 0, + + // A capsule primitive + Capsule = 1, + + // A cylinder primitive + Cylinder = 2, + + // A cube primitive + Cube = 3, + + // A plane primitive + Plane = 4, + + // A quad primitive + Quad = 5 +END + +// The coordinate space in which to operate. +ENUM Space + // Applies transformation relative to the world coordinate system + World = 0, + // Applies transformation relative to the local coordinate system + Self = 1 +END + + + +// LayerMask allow you to display the LayerMask popup menu in the inspector +STRUCT LayerMask + CSRAW + private int m_Mask; + + //*undocumented* TODO: make this actually work + CSRAW public static implicit operator int (LayerMask mask) { return mask.m_Mask; } + + // implicitly converts an integer to a LayerMask + public static implicit operator LayerMask (int intVal) { LayerMask mask; mask.m_Mask = intVal; return mask; } + + // Converts a layer mask value to an integer value. + CSRAW public int value { get { return m_Mask; } set { m_Mask = value; } } + + // Given a layer number, returns the name of the layer as defined in either a Builtin or a User Layer in the [[wiki:class-TagManager|Tag Manager]] + CUSTOM static string LayerToName (int layer) { return scripting_string_new(LayerToString(layer)); } + + // Given a layer name, returns the layer index as defined by either a Builtin or a User Layer in the [[wiki:class-TagManager|Tag Manager]] + CUSTOM static int NameToLayer (string layerName) { return StringToLayer(layerName); } +END + + +// The platform application is running. Returned by Application.platform. +ENUM RuntimePlatform + // In the Unity editor on Mac OS X. + OSXEditor = 0, + + // In the player on Mac OS X. + OSXPlayer = 1, + + // In the player on Windows. + WindowsPlayer = 2, + + // In the web player on Mac OS X. + OSXWebPlayer = 3, + + // In the Dashboard widget on Mac OS X. + OSXDashboardPlayer = 4, + + // In the web player on Windows. + WindowsWebPlayer = 5, + + // In the player on Nintendo Wii. + WiiPlayer = 6, + + // In the Unity editor on Windows. + WindowsEditor = 7, + + // In the player on the iPhone. + IPhonePlayer = 8, + + // In the player on the XBOX360 + XBOX360 = 10, + + // In the player on the Play Station 3 + PS3 = 9, + + // In the player on Android devices. + Android = 11, + + //Google Native Client + NaCl = 12, + + //*undocumented* + LinuxPlayer = 13, + + //Flash Player + FlashPlayer = 15, + + //*undocumented* + MetroPlayerX86 = 18, + + //*undocumented* + MetroPlayerX64 = 19, + + //*undocumented* + MetroPlayerARM = 20, + + //*undocumented* + WP8Player = 21, + + //*undocumented* + BB10Player = 22, + + //*undocumented* + TizenPlayer = 23, + +END + +// The language the user's operating system is running in. Returned by Application.systemLanguage. +ENUM SystemLanguage + //Afrikaans + Afrikaans = 0, + //Arabic + Arabic = 1, + //Basque + Basque = 2, + //Belarusian + Belarusian = 3, + //Bulgarian + Bulgarian = 4, + //Catalan + Catalan = 5, + //Chinese + Chinese = 6, + //Czech + Czech = 7, + //Danish + Danish = 8, + //Dutch + Dutch = 9, + //English + English = 10, + //Estonian + Estonian = 11, + //Faroese + Faroese = 12, + //Finnish + Finnish = 13, + //French + French = 14, + //German + German = 15, + //Greek + Greek = 16, + //Hebrew + Hebrew = 17, + //*undocumented* + Hugarian = 18, + //Icelandic + Icelandic = 19, + //Indonesian + Indonesian = 20, + //Italian + Italian = 21, + //Japanese + Japanese = 22, + //Korean + Korean = 23, + //Latvian + Latvian = 24, + //Lithuanian + Lithuanian = 25, + //Norwegian + Norwegian = 26, + //Polish + Polish = 27, + //Portuguese + Portuguese = 28, + //Romanian + Romanian = 29, + //Russian + Russian = 30, + //Serbo-Croatian + SerboCroatian = 31, + //Slovak + Slovak = 32, + //Slovenian + Slovenian = 33, + //Spanish + Spanish = 34, + //Swedish + Swedish = 35, + //Thai + Thai = 36, + //Turkish + Turkish = 37, + //Ukrainian + Ukrainian = 38, + //Vietnamese + Vietnamese = 39, + //Unknown + Unknown = 40, + //Hungarian + Hungarian = 18 +END + +// The type of the log message in the delegate registered with Application.RegisterLogCallback. +ENUM LogType + // LogType used for Errors. + Error = 0, + // LogType used for Asserts. (These indicate an error inside Unity itself.) + Assert = 1, + // LogType used for Warnings. + Warning = 2, + // LogType used for regular log messages. + Log = 3, + // LogType used for Exceptions. + Exception = 4 +END + +// Enumeration for [[SystemInfo.deviceType]], denotes a coarse grouping of kinds of devices. +ENUM DeviceType + // Device type is unknown. You should never see this in practice. + Unknown = 0, + + // A handheld device like mobile phone or a tablet. + Handheld = 1, + + // A stationary gaming console. + Console = 2, + + // Desktop or laptop computer. + Desktop = 3, +END + +// Access system information. +CLASS SystemInfo + + // Operating system name with version (RO). + CUSTOM_PROP static string operatingSystem { return scripting_string_new( systeminfo::GetOperatingSystem() ); } + + // Processor name (RO). + CUSTOM_PROP static string processorType { return scripting_string_new( systeminfo::GetProcessorType() ); } + + // Number of processors present (RO). + CUSTOM_PROP static int processorCount { return systeminfo::GetProcessorCount(); } + + // Amount of system memory present (RO). + CUSTOM_PROP static int systemMemorySize { return systeminfo::GetPhysicalMemoryMB(); } + + + // Amount of video memory present (RO). + CUSTOM_PROP static int graphicsMemorySize { return (int)gGraphicsCaps.videoMemoryMB; } + + + // The name of the graphics device (RO). + CUSTOM_PROP static string graphicsDeviceName { return scripting_string_new(gGraphicsCaps.rendererString.c_str()); } + + + // The vendor of the graphics device (RO). + CUSTOM_PROP static string graphicsDeviceVendor { return scripting_string_new(gGraphicsCaps.vendorString.c_str()); } + + + // The identifier code of the graphics device (RO). + CUSTOM_PROP static int graphicsDeviceID { return gGraphicsCaps.rendererID; } + + + // The identifier code of the graphics device vendor (RO). + CUSTOM_PROP static int graphicsDeviceVendorID { return gGraphicsCaps.vendorID; } + + + // The graphics API version supported by the graphics device (RO). + CUSTOM_PROP static string graphicsDeviceVersion { return scripting_string_new(gGraphicsCaps.fixedVersionString.c_str()); } + + + + // Graphics device shader capability level (RO). + CUSTOM_PROP static int graphicsShaderLevel { return gGraphicsCaps.shaderCaps; } + + + // Approximate pixel fill-rate of the graphics device (RO). + CUSTOM_PROP static int graphicsPixelFillrate { + return GetGraphicsPixelFillrate (gGraphicsCaps.vendorID, gGraphicsCaps.rendererID); + } + + + // Are built-in shadows supported? (RO) + CUSTOM_PROP static bool supportsShadows { + return RenderTexture::IsEnabled() && GetBuildSettings().hasShadows && gGraphicsCaps.supportsRenderTextureFormat[kRTFormatDepth]; + } + // Are render textures supported? (RO) + CUSTOM_PROP static bool supportsRenderTextures { + return RenderTexture::IsEnabled(); + } + CUSTOM_PROP static bool supportsRenderToCubemap { + return RenderTexture::IsEnabled() && (gGraphicsCaps.hasRenderToCubemap); + } + // Are image effects supported? (RO) + CUSTOM_PROP static bool supportsImageEffects { + return RenderTexture::IsEnabled() && (gGraphicsCaps.npotRT >= kNPOTRestricted); + } + + // Are 3D (volume) textures supported? (RO) + CUSTOM_PROP static bool supports3DTextures { + return gGraphicsCaps.has3DTexture; + } + + // Are compute shaders supported? (RO) + CUSTOM_PROP static bool supportsComputeShaders { + return gGraphicsCaps.hasComputeShader; + } + + // Is GPU draw call instancing supported? (RO) + CUSTOM_PROP static bool supportsInstancing { + return gGraphicsCaps.hasInstancing; + } + + // How many simultaneous render targets (MRTs) are supported? (RO) + CUSTOM_PROP static int supportedRenderTargetCount { + return RenderTexture::IsEnabled() ? gGraphicsCaps.maxMRTs : 0; + } + + // Is the stencil buffer supported? (RO) + CUSTOM_PROP static int supportsStencil { + return gGraphicsCaps.hasStencil && GetBuildSettings ().hasAdvancedVersion; + } + + //*undocumented* + CUSTOM_PROP static bool supportsVertexPrograms { return true; } + + // Is render texture format supported? + CUSTOM static bool SupportsRenderTextureFormat (RenderTextureFormat format) { + return RenderTexture::IsEnabled() && gGraphicsCaps.supportsRenderTextureFormat[format]; + } + + /// What [[NPOT|NPOTSupport]] support does GPU provide? (RO) + /// + /// SA: [[NPOTSupport]] enum. + CUSTOM_PROP static NPOTSupport npotSupport { return gGraphicsCaps.npot; } + + //A unique device identifier. It is guaranteed to be unique for every device (RO). + CONDITIONAL !UNITY_FLASH && !UNITY_WEBGL + CUSTOM_PROP static string deviceUniqueIdentifier { + return scripting_string_new (systeminfo::GetDeviceUniqueIdentifier ()); + } + + // The user defined name of the device (RO). + CONDITIONAL !UNITY_FLASH && !UNITY_WEBGL + CUSTOM_PROP static string deviceName { + return scripting_string_new (systeminfo::GetDeviceName ()); + } + + // The model of the device (RO). + CONDITIONAL !UNITY_FLASH && !UNITY_WEBGL + CUSTOM_PROP static string deviceModel { + return scripting_string_new (systeminfo::GetDeviceModel ()); + } + + // Returns a boolean value that indicates whether an accelerometer is + CUSTOM_PROP static bool supportsAccelerometer { + return systeminfo::SupportsAccelerometer (); + } + + // Returns a boolean value that indicates whether a gyroscope is available + CUSTOM_PROP static bool supportsGyroscope { + return IsGyroAvailable (); + } + + // Returns a boolean value that indicates whether the device is capable to + CUSTOM_PROP static bool supportsLocationService { + return systeminfo::SupportsLocationService (); + } + + // Returns a boolean value that indicates whether the device is capable to + CUSTOM_PROP static bool supportsVibration { + return systeminfo::SupportsVibration (); + } + + // Returns the kind of device the application is running on. See [[DeviceType]] enumeration for possible values. + CUSTOM_PROP static DeviceType deviceType + { + return systeminfo::DeviceType (); + } + + CUSTOM_PROP static int maxTextureSize + { + return gGraphicsCaps.maxTextureSize; + } + +END + +// Suspends the coroutine execution for the given amount of seconds. +CSRAW [StructLayout(LayoutKind.Sequential)] +CLASS WaitForSeconds : YieldInstruction + //*undocumented* + CSRAW internal float m_Seconds; + + // Creates a yield instruction to wait for a given number of seconds + CSRAW public WaitForSeconds (float seconds) { m_Seconds = seconds; } +END + +// Waits until next fixed frame rate update function. SA: MonoBehaviour::pref::FixedUpdate. +CLASS WaitForFixedUpdate : YieldInstruction +END + +// Waits until the end of the frame after all cameras and GUI is rendered, just before displaying the frame on screen. +CLASS WaitForEndOfFrame : YieldInstruction +END + + +// MonoBehaviour.StartCoroutine returns a Coroutine. Instances of this class are only used to reference these coroutines and do not hold any exposed properties or functions. +CSRAW [StructLayout (LayoutKind.Sequential)] + +CLASS Coroutine : YieldInstruction + CSRAW internal IntPtr m_Ptr; + private Coroutine () { } + + THREAD_SAFE + CUSTOM private void ReleaseCoroutine () + { + Assert (self.GetPtr() != NULL); + Coroutine::CleanupCoroutineGC (self); + } + + CSRAW + ~Coroutine () + { + ReleaseCoroutine (); + } +END + +CSRAW + +// The RequireComponent attribute lets automatically add required component as a dependency. + + +CSRAW [AttributeUsage(AttributeTargets.Class, AllowMultiple=true)] +CLASS RequireComponent : Attribute + //*undocumented* + CSRAW public Type m_Type0; + //*undocumented* + CSRAW public Type m_Type1; + //*undocumented* + CSRAW public Type m_Type2; + + // Require a single component + CSRAW public RequireComponent (Type requiredComponent) { m_Type0 = requiredComponent; } + // Require a two components + CSRAW public RequireComponent (Type requiredComponent, Type requiredComponent2) { m_Type0 = requiredComponent; m_Type1 = requiredComponent2; } + // Require three components + CSRAW public RequireComponent (Type requiredComponent, Type requiredComponent2, Type requiredComponent3) { m_Type0 = requiredComponent; m_Type1 = requiredComponent2; m_Type2 = requiredComponent3; } +END + + +// The AddComponentMenu attribute allows you to place a script anywhere in the "Component" menu, instead of just the "Component->Scripts" menu. + +CLASS AddComponentMenu : Attribute + CSRAW private string m_AddComponentMenu; + + // The script will be placed in the component menu according to /menuName/. /menuName/ is the path to the component + CSRAW public AddComponentMenu (string menuName) { m_AddComponentMenu = menuName; } + + //* undocumented + CSRAW public string componentMenu { get {return m_AddComponentMenu; } } +END + + +// The ContextMenu attribute allows you to add commands to the context menu +CLASS ContextMenu : Attribute + + // Adds the function to the context menu of the component. + CSRAW public ContextMenu (string name) { m_ItemName = name; } + + + CSRAW private string m_ItemName; + + //* undocumented + CSRAW public string menuItem { get { return m_ItemName; } } +END + + +// Makes a script execute in edit mode. +CLASS ExecuteInEditMode : Attribute +END + + +// Makes a variable not show up in the inspector but be serialized. +CLASS HideInInspector : Attribute +END + +// A class you can derive from if you want to create objects that don't need to be attached to game objects. +CSRAW +[StructLayout (LayoutKind.Sequential)] +NONSEALED_CLASS ScriptableObject : Object + + //*undocumented* Users are not supposed to instantiate unextended ScriptableObjects, are they? + CSRAW public ScriptableObject () + { + Internal_CreateScriptableObject(this); + } + + THREAD_SAFE + CUSTOM private static void Internal_CreateScriptableObject([Writable]ScriptableObject self) + { + Scripting::CreateEngineScriptableObject(self.GetScriptingObject()); + } + + CONDITIONAL ENABLE_MONO + OBSOLETE warning Use EditorUtility.SetDirty instead + AUTO void SetDirty (); + + // Creates an instance of a scriptable object with /className/. + CUSTOM static ScriptableObject CreateInstance (string className) { return Scripting::CreateScriptableObject (className.AsUTF8()); } + + // Creates an instance of a scriptable object with /type/. + CSRAW public static ScriptableObject CreateInstance (Type type) { return CreateInstanceFromType(type); } + + CUSTOM private static ScriptableObject CreateInstanceFromType (Type type) { return Scripting::CreateScriptableObjectWithType (type); } + + CSRAW + #if ENABLE_GENERICS + // Creates an instance of a scriptable object with /T/. + public static T CreateInstance<T> () where T : ScriptableObject + { + return (T)CreateInstance(typeof(T)); + } + #endif + + // This function is called when the object is loaded + CSNONE void OnEnable (); + + + // This function is called when the scriptable object goes out of scope + CSNONE void OnDisable(); + + // This function is called when the scriptable object will be destroyed. + CSNONE void OnDestroy(); + + +END + +// The Resources class allows you to find and access Objects including assets. +CLASS Resources + + CONDITIONAL (ENABLE_GENERICS && !UNITY_FLASH) + CSRAW internal static T[] ConvertObjects<T>(Object[] rawObjects) where T : Object + { + if (rawObjects == null) return null; + T[] typedObjects = new T[rawObjects.Length]; + for (int i = 0; i < typedObjects.Length; i++) + typedObjects[i] = (T)rawObjects[i]; + return typedObjects; + } + + // Returns a list of all objects of Type /type/. + CSRAW + [TypeInferenceRule(TypeInferenceRules.ArrayOfTypeReferencedByFirstArgument)] + CUSTOM static Object[] FindObjectsOfTypeAll (Type type) { DISALLOW_IN_CONSTRUCTOR return Scripting::FindObjectsOfType (type, Scripting::kFindAnything); } + + CONDITIONAL (ENABLE_GENERICS && !UNITY_FLASH) + CSRAW public static T[] FindObjectsOfTypeAll<T> () where T : Object + { + return ConvertObjects<T>(FindObjectsOfTypeAll (typeof (T))); + } + + // Loads an asset stored at /path/ in a Resources folder. + + CSRAW public static Object Load (string path) + { + return Load(path, typeof(Object)); + } + + CONDITIONAL ENABLE_GENERICS + CSRAW public static T Load<T> (string path) where T : Object + { + return (T) Load (path, typeof (T)); + } + + // Loads an asset stored at /path/ in a Resources folder. + CSRAW + [TypeInferenceRule(TypeInferenceRules.TypeReferencedBySecondArgument)] + CUSTOM static Object Load (string path, Type systemTypeInstance) + { + Scripting::RaiseIfNull (systemTypeInstance); + + ScriptingClassPtr klass = GetScriptingTypeRegistry().GetType(systemTypeInstance); + string lowerPath = ToLower(path.AsUTF8()); + ResourceManager::range found = GetResourceManager().GetPathRange(lowerPath); + + Object* obj = NULL; + ScriptingObjectPtr o = SCRIPTING_NULL; + for (ResourceManager::iterator i=found.first;i != found.second;i++) + { + obj = i->second; + GetResourceManager ().PreloadDependencies (obj->GetInstanceID ()); + + o = Scripting::ScriptingWrapperFor(obj); + if (o == SCRIPTING_NULL) + continue; + + ScriptingClassPtr k = scripting_object_get_class(o, GetScriptingTypeRegistry()); + if (o && scripting_class_is_subclass_of(k,klass)) + { + break; + } + + GameObject* go = dynamic_pptr_cast<GameObject*> (obj); + if (go != NULL) + { + o = ScriptingGetComponentOfType(*go, systemTypeInstance, false); + if (o != SCRIPTING_NULL) + { + break; + } + } + } + + // Android keeps its Resources folder split up (to minimize seeks inside the .apk) + // To not "leak" SerializedFile objects we need to unload the added stream here.. + if (obj && UNITY_ANDROID) + { + PersistentManager& pm = GetPersistentManager(); + pm.UnloadNonDirtyStreams(); + } + + return o; + } + + // Loads all assets in a folder or file at /path/ in a Resources folder. + CUSTOM static Object[] LoadAll (string path, Type systemTypeInstance) + { + Scripting::RaiseIfNull (systemTypeInstance); + + ScriptingClassPtr klass = GetScriptingTypeRegistry().GetType(systemTypeInstance); + ResourceManager::range found = GetResourceManager().GetAll(); + string cpath = ToLower(path.AsUTF8()); + + vector<PPtr<Object> > objects; + + for (ResourceManager::iterator i=found.first;i != found.second;i++) + { + // Path doesn't match (But allow empty path for all objects) + if (!StartsWithPath(i->first, cpath)) + continue; + + Object* obj = i->second; + GetResourceManager ().PreloadDependencies (obj->GetInstanceID ()); + + ScriptingObjectPtr o = Scripting::ScriptingWrapperFor(obj); + if (o == SCRIPTING_NULL) + continue; + + ScriptingClassPtr k = scripting_object_get_class(o, GetScriptingTypeRegistry()); + if (o && scripting_class_is_subclass_of(k, klass)) + { + objects.push_back(i->second); + } + else + { + GameObject* go = dynamic_pptr_cast<GameObject*> (obj); + if (go != NULL) + { + o = ScriptingGetComponentOfType(*go, systemTypeInstance, false); + if (o != SCRIPTING_NULL) + { + objects.push_back(ScriptingObjectToObject<Object>(o)); + } + } + } + } + + return CreateScriptingArrayFromUnityObjects (objects, ClassID(Object)); + } + + // Loads all assets in a folder or file at /path/ in a Resources folder. + + CSRAW public static Object[] LoadAll (string path) + { + return LoadAll(path, typeof(Object)); + } + + CONDITIONAL (ENABLE_GENERICS && !UNITY_FLASH) + CSRAW public static T[] LoadAll<T> (string path) where T : Object + { + return ConvertObjects<T>(LoadAll (path, typeof (T))); + } + + // *undocumented + CSRAW + [TypeInferenceRule(TypeInferenceRules.TypeReferencedByFirstArgument)] + CUSTOM static Object GetBuiltinResource (Type type, string path) + { + Scripting::RaiseIfNull(type); + return GetScriptingBuiltinResource(type, path.AsUTF8()); + } + + CONDITIONAL ENABLE_GENERICS + CSRAW public static T GetBuiltinResource<T> (string path) where T : Object + { + return (T) GetBuiltinResource (typeof (T), path); + } + + // Returns a resource at an asset path (Editor Only). + CSRAW + [TypeInferenceRule(TypeInferenceRules.TypeReferencedBySecondArgument)] + CUSTOM static Object LoadAssetAtPath (string assetPath, Type type) + { + #if UNITY_EDITOR + return LoadAssetAtPath(assetPath, type); + #else + return SCRIPTING_NULL; + #endif + } + + CONDITIONAL ENABLE_GENERICS + CSRAW public static T LoadAssetAtPath<T> (string assetPath) where T : Object + { + return (T) LoadAssetAtPath (assetPath, typeof (T)); + } + + // Unloads /assetToUnload/ from memory. + CUSTOM static void UnloadAsset (Object assetToUnload) { Scripting::UnloadAssetFromScripting (assetToUnload); } + + // Unloads assets that are not used. + CUSTOM static AsyncOperation UnloadUnusedAssets () + { + AsyncOperation* result = UnloadUnusedAssetsOperation::UnloadUnusedAssets (); + ScriptingObjectPtr o = scripting_object_new(MONO_COMMON.asyncOperation); + ScriptingObjectWithIntPtrField<AsyncOperation>(o).SetPtr(result); + return o; + } + +END + + +OBSOLETE warning Use SerializeField on the private variables that you want to be serialized instead +CLASS SerializePrivateVariables : Attribute +END + +// Priority of a thread. +ENUM ThreadPriority + // Lowest thread priority + Low = 0, + // Below normal thread priority + BelowNormal = 1, + // Normal thread priority + Normal = 2, + // Highest thread priority + High = 4 +END + + +// Force Unity to serialize a private field. + + + +CLASS SerializeField : Attribute +END + +// Controls the [[wiki:Profiler]] from script. +CLASS Profiler + + // *undocumented* + CUSTOM_PROP static bool supported + { + #if ENABLE_PROFILER + return GetBuildSettings().hasPROVersion; + #else + return false; + #endif + } + + + // Sets profiler output file in built players. + CUSTOM_PROP static string logFile + { + #if ENABLE_PROFILER + return scripting_string_new(UnityProfiler::Get().GetLogPath()); + #else + return SCRIPTING_NULL; + #endif + } + { + #if ENABLE_PROFILER + if (!GetBuildSettings().hasPROVersion) + { + ErrorString("Profiler is only supported in Unity Pro."); + return; + } + UnityProfiler::Get().SetLogPath(value); + #else + ErrorString("Profiler is not supported in this build"); + #endif + } + + // Sets profiler output file in built players. + CUSTOM_PROP static bool enableBinaryLog + { + #if ENABLE_PROFILER + return UnityProfiler::Get().BinaryLogEnabled(); + #else + return false; + #endif + } + { + #if ENABLE_PROFILER + if (!GetBuildSettings().hasPROVersion) + { + ErrorString("Profiler is only supported in Unity Pro."); + return; + } + UnityProfiler::Get().EnableBinaryLog(value); + #else + ErrorString("Profiler is not supported in this build"); + #endif + } + + // Enables the Profiler. + CUSTOM_PROP static bool enabled + { + #if ENABLE_PROFILER + return UnityProfiler::Get().GetEnabled(); + #else + return false; + #endif + } + { + #if ENABLE_PROFILER + if (!GetBuildSettings().hasPROVersion) + { + ErrorString("Profiler is only supported in Unity Pro."); + return; + } + return UnityProfiler::Get().SetEnabled(value); + #else + ErrorString("Profiler is not supported in this build"); + #endif + } + + + // Displays the recorded profiledata in the profiler. + CSRAW [System.Diagnostics.ConditionalAttribute("ENABLE_PROFILER")] + CUSTOM static void AddFramesFromFile (string file) + { + #if ENABLE_PROFILER + if(file.Length() == 0) + { + ErrorString ("AddFramesFromFile: Invalid empty path"); + return; + } + UnityProfiler::Get().AddFramesFromFile(file); + #endif + } + + + /// *listonly* + CSRAW [System.Diagnostics.ConditionalAttribute("ENABLE_PROFILER")] + CSRAW static public void BeginSample(string name) + { + BeginSampleOnly(name); + } + + // Begin profiling a piece of code with a custom label. + CSRAW [System.Diagnostics.ConditionalAttribute("ENABLE_PROFILER")] + CUSTOM static void BeginSample(string name, Object targetObject) + { + #if ENABLE_PROFILER + UnityProfilerPerThread* prof = UnityProfilerPerThread::ms_InstanceTLS; + if (prof && prof->GetIsActive()) + prof->BeginSampleDynamic(name, targetObject); + #endif + } + + CUSTOM private static void BeginSampleOnly(string name) + { + #if ENABLE_PROFILER + UnityProfilerPerThread* prof = UnityProfilerPerThread::ms_InstanceTLS; + if (prof && prof->GetIsActive()) + prof->BeginSampleDynamic(name, NULL); + #endif + } + + // End profiling a piece of code with a custom label. + CSRAW [System.Diagnostics.ConditionalAttribute("ENABLE_PROFILER")] + CUSTOM static void EndSample () + { + #if ENABLE_PROFILER + UnityProfilerPerThread* prof = UnityProfilerPerThread::ms_InstanceTLS; + if (prof) + prof->EndSampleDynamic(); + #endif + } + + // Heap size used by the program + CUSTOM_PROP static uint usedHeapSize + { + #if ENABLE_PROFILER + return GetUsedHeapSize(); + #else + return 0; + #endif + } + + // Returns the runtime memory usage of the resource. + + CUSTOM static int GetRuntimeMemorySize(Object o) + { + #if ENABLE_PROFILER + return o->GetRuntimeMemorySize(); + #else + return 0; + #endif + } + + // Returns the size of the mono heap + CUSTOM static uint GetMonoHeapSize () + { + #if ENABLE_PROFILER && ENABLE_MONO + return mono_gc_get_heap_size (); + #else + return 0; + #endif + } + + // Returns the used size from mono + CUSTOM static uint GetMonoUsedSize () + { + #if ENABLE_PROFILER && ENABLE_MONO + return mono_gc_get_used_size (); + #else + return 0; + #endif + } + ///*undocumented* + CUSTOM static uint GetTotalAllocatedMemory() + { + #if ENABLE_MEMORY_MANAGER + return GetMemoryManager().GetTotalAllocatedMemory(); + #else + return 0; + #endif + } + ///*undocumented* + CUSTOM static uint GetTotalUnusedReservedMemory() + { + #if ENABLE_MEMORY_MANAGER + return GetMemoryManager().GetTotalUnusedReservedMemory(); + #else + return 0; + #endif + } + ///*undocumented* + CUSTOM static uint GetTotalReservedMemory() + { + #if ENABLE_MEMORY_MANAGER + return GetMemoryManager().GetTotalReservedMemory(); + #else + return 0; + #endif + } + + //CUSTOM static void SharkBeginRemoteProfiling () + //{ + // #if ENABLE_SHARK_PROFILE + // SharkBeginRemoteProfiling(); + // #endif + //} + // + //CUSTOM static void SharkEndRemoteProfiling () + //{ + // #if ENABLE_SHARK_PROFILE + // SharkEndRemoteProfiling(); + // #endif + //} +END + +CSRAW } + +CSRAW +namespace UnityEngineInternal +{ + +using UnityEngine; + +//*undocumented* +// class for reproduction framework +CONDITIONAL ENABLE_MONO +CLASS Reproduction + + CUSTOM static void CaptureScreenshot () + { +#if SUPPORT_REPRODUCE_LOG + CaptureScreenshotReproduction(true); +#else + Scripting::RaiseMonoException("This method only works with internal development builds."); +#endif + } + +END + +CSRAW } |