private IEnumerator Start() { // Play music track if (_audioBG != null) { AudioSource.PlayClipAtPoint(_audioBG, Vector3.zero); } if (_capture != null) { _capture.BeginFinalFileWritingAction += OnBeginFinalFileWriting; } // Make sure we're authorised for using the microphone. On iOS the OS will forcibly // close the application if authorisation has not been granted. Make sure the // "Microphone Usage Description" field has been filled in the player settings. if (!Application.HasUserAuthorization(UserAuthorization.Microphone)) { yield return(Application.RequestUserAuthorization(UserAuthorization.Microphone)); } if (Application.HasUserAuthorization(UserAuthorization.Microphone)) { // On iOS modified the audio session to allow recording from the microphone. NativePlugin.SetMicrophoneRecordingHint(true); } }
private void Start() { print("The developer's name is " + NativePlugin.GetName()); print("(AKA " + NativePlugin.GetAlias() + ")"); print(NativePlugin.ModifyText("MAGICAL TEXT")); //print(NativePlugin.ModifyText(null)); }
private void UnzipThread() { label_1: while (true) { this.mUnzipSignal.WaitOne(); this.mMutex.WaitOne(); if (!this.mShuttingDown) { if (this.mUnzipJobs == null) { this.mMutex.ReleaseMutex(); } else { goto label_5; } } else { break; } } this.mMutex.ReleaseMutex(); return; label_5: AssetDownloader.UnzipJob[] array = this.mUnzipJobs.ToArray(); for (int index = 0; index < array.Length; ++index) { if (array[index].State == AssetDownloader.UnzipJobState.Waiting) { array[index].State = AssetDownloader.UnzipJobState.Extracting; } } this.mMutex.ReleaseMutex(); for (int index = 0; index < array.Length; ++index) { AssetDownloader.UnzipJob unzipJob = array[index]; if (unzipJob.State == AssetDownloader.UnzipJobState.Extracting) { if (NativePlugin.UnZip(unzipJob.Dest, unzipJob.Bytes, unzipJob.Size) != 0) { this.mMutex.WaitOne(); unzipJob.State = AssetDownloader.UnzipJobState.Error; this.mMutex.ReleaseMutex(); } else { this.mMutex.WaitOne(); unzipJob.State = AssetDownloader.UnzipJobState.Finished; this.mMutex.ReleaseMutex(); } } } goto label_1; }
IntPtr GetPointer(int i) { var ptr = NativePlugin.GetLittleDataPtr(i); if (ptr == IntPtr.Zero) { throw new System.IndexOutOfRangeException("Index out of bounds: " + i); } return(ptr); }
private void Start() { if (NativePlugin.Init()) { // Find the index for the video codec _videoCodecIndex = FindVideoCodecIndex(X264CodecName); } else { this.enabled = false; } }
private void Start() { float d = 0; NativePlugin.GetData(out d); print("Data = " + d); NativePlugin.SetData(90); NativePlugin.GetData(out d); print("Data = " + d); //NativePlugin.SetData(NativePlugin.GetReferenceDataValue()); }
void Start() { byte[] data = Encoding.Default.GetBytes("test12345678"); byte[] encrypt_data = NativePlugin.Encrypt(data); string str_encrypt = Encoding.Default.GetString(encrypt_data); Debug.Log("encrypt -> " + str_encrypt); string str_decrypt = Encoding.Default.GetString(NativePlugin.Decrypt(encrypt_data)); Debug.Log("decrypt -> " + str_decrypt); LoadSceneFromAssetBundle(SceneLoadManager.Instance.LoadSceneName); }
protected static bool IsTrialVersion() { bool result = false; try { result = NativePlugin.IsTrialVersion(); } catch (System.DllNotFoundException) { // Silent catch as we report this error elsewhere } return result; }
private void Start() { var st = NativePlugin.GetStructure(); print("Value = " + st.TheValue); NativePlugin.PassStructureByReference(ref st); print("Value = " + st.TheValue); var st2 = NativePlugin.PassStructureByValue(st); print("Value = " + st2.TheValue); }
private static int FindVideoCodecIndex(string name) { int result = -1; int numVideoCodecs = NativePlugin.GetNumAVIVideoCodecs(); for (int i = 0; i < numVideoCodecs; i++) { if (NativePlugin.GetAVIVideoCodecName(i) == name) { result = i; break; } } return(result); }
private void LoadRuntimePluginIntoMemory(string fileName) { try { NativePlugin plugin = new NativePlugin(fileName); _plugins.Add(plugin); } catch (AGSEditorException ex) { _guiController.ShowMessage("There was an error loading plugin '" + fileName + "'." + Environment.NewLine + Environment.NewLine + ex.Message, MessageBoxIcon.Warning); } catch (Exception ex) { _guiController.ShowMessage("There was an error loading plugin '" + fileName + "'." + Environment.NewLine + Environment.NewLine + ex.ToString(), MessageBoxIcon.Warning); } }
private void Start() { if (NativePlugin.Init()) { // Find the index for the video codec _videoCodec = CodecManager.FindCodec(CodecType.Video, X264CodecName); if (_videoCodec == null) { _videoCodec = CodecManager.FindCodec(CodecType.Video, FallbackCodecName); } } else { this.enabled = false; } }
public static string LoadTextData(string path) { AssetList.Item itemByPath1 = AssetManager.TxtAssetList.FindItemByPath(path); if (itemByPath1 != null) { int size; IntPtr num = NativePlugin.DecompressFile(AssetDownloader.TextCachePath + itemByPath1.IDStr, out size); if (num == IntPtr.Zero) { return((string)null); } byte[] numArray = new byte[size]; Marshal.Copy(num, numArray, 0, size); NativePlugin.FreePtr(num); using (StreamReader streamReader = new StreamReader((Stream) new MemoryStream(numArray), Encoding.UTF8)) return(streamReader.ReadToEnd()); } else { AssetList.Item itemByPath2 = AssetManager.AssetList.FindItemByPath(path); if (itemByPath2 != null) { int size; IntPtr num = NativePlugin.DecompressFile(AssetDownloader.CachePath + itemByPath2.IDStr, out size); if (num == IntPtr.Zero) { return((string)null); } byte[] numArray = new byte[size]; Marshal.Copy(num, numArray, 0, size); NativePlugin.FreePtr(num); using (StreamReader streamReader = new StreamReader((Stream) new MemoryStream(numArray), Encoding.UTF8)) return(streamReader.ReadToEnd()); } else { TextAsset textAsset = (TextAsset)Resources.Load <TextAsset>(path); if (Object.op_Inequality((Object)textAsset, (Object)null)) { return(textAsset.get_text()); } return((string)null); } } }
private void Start() { fromCamera = GetComponent <CaptureFromCamera>(); fromCamera._outputFolderPath = ""; int numAudioDevices = NativePlugin.GetNumAVIAudioInputDevices(); if (numAudioDevices > 0) { _audioDeviceNames = new string[numAudioDevices]; for (int i = 0; i < numAudioDevices; i++) { _audioDeviceNames[i] = NativePlugin.GetAVIAudioInputDeviceName(i); } } }
private void Update() { var ptr = NativePlugin.GetLittleDataPtr(Index); if (ptr == IntPtr.Zero) { return; } if (Set) { NativePlugin.SetLittleDataData(ptr, Value); } else { Value = NativePlugin.GetLittleDataData(ptr); } }
public void CreateVideoFromByteArray(string filePath, int width, int height, int frameRate) { byte[] frameData = new byte[width * height * 4]; GCHandle frameHandle = GCHandle.Alloc(frameData, GCHandleType.Pinned); // Start the recording session int encoderHandle = NativePlugin.CreateRecorderAVI(filePath, (uint)width, (uint)height, frameRate, (int)NativePlugin.PixelFormat.RGBA32, false, _videoCodecIndex, false, 0, 0, -1, -1, false, false, false); if (encoderHandle >= 0) { NativePlugin.Start(encoderHandle); // Write out 100 frames int numFrames = 100; for (int i = 0; i < numFrames; i++) { // TODO: fill the byte array with your own data :) // Wait for the encoder to be ready for the next frame int numAttempts = 32; while (numAttempts > 0) { if (NativePlugin.IsNewFrameDue(encoderHandle)) { // Encode the new frame NativePlugin.EncodeFrame(encoderHandle, frameHandle.AddrOfPinnedObject()); break; } System.Threading.Thread.Sleep(1); numAttempts--; } } // End the session NativePlugin.Stop(encoderHandle, false); NativePlugin.FreeRecorder(encoderHandle); } if (frameHandle.IsAllocated) { frameHandle.Free(); } }
public override IList <MenuCommand> GetContextMenu(string controlID) { if (controlID == TOP_LEVEL_COMMAND_ID) { return(null); } IList <MenuCommand> contextMenu = new List <MenuCommand>(); _rightClickedPlugin = GetPluginByFileName(controlID.Substring(3)); MenuCommand useThisPluginCmd = new MenuCommand(MENU_ITEM_ENABLED, "Use this plugin", null); useThisPluginCmd.Checked = _rightClickedPlugin.Enabled; contextMenu.Add(useThisPluginCmd); MenuCommand propertiesCmd = new MenuCommand(MENU_ITEM_PROPERTIES, "Plugin properties...", null); propertiesCmd.Enabled = (_rightClickedPlugin.HasProperties && _rightClickedPlugin.Enabled); contextMenu.Add(propertiesCmd); return(contextMenu); }
public override void RefreshDataFromGame() { // Disable all plugins before loading the game foreach (NativePlugin nativePlugin in _plugins) { nativePlugin.Enabled = false; } foreach (Plugin gamePlugin in _agsEditor.CurrentGame.Plugins) { NativePlugin nativePlugin = GetPluginByFileName(gamePlugin.FileName.ToLower()); if (nativePlugin == null) { _guiController.ShowMessage("This game uses the plugin '" + gamePlugin.FileName + "', which was not found. If you save the game now, all references to this plugin will be removed.", MessageBoxIcon.Warning); } else { nativePlugin.Enabled = true; nativePlugin.DeserializeData(gamePlugin.SerializedData); } } RepopulateTreeView(); }
public int Function() { return(NativePlugin.CppClass_Function(CppPtr)); }
private AssetBundleCache OpenAssetBundle(string assetbundleID, bool persistent = false, bool isDependency = false) { AssetList.Item itemById = AssetManager.AssetList.FindItemByID(assetbundleID); if (itemById == null) { DebugUtility.LogError("AssetBundle not found: " + assetbundleID); return((AssetBundleCache)null); } for (int index = 0; index < this.mAssetBundles.Count; ++index) { if (this.mAssetBundles[index].Name == assetbundleID) { return(this.mAssetBundles[index]); } } if (this.mAssetBundles.Count >= AssetManager.MaxAssetBundles) { this.UnloadUnusedAssetBundles(true, true); } string path = AssetDownloader.CachePath + assetbundleID; if (!File.Exists(path)) { DebugUtility.LogError("AssetBundle doesn't exist: " + assetbundleID); return((AssetBundleCache)null); } if ((itemById.Flags & AssetBundleFlags.RawData) != (AssetBundleFlags)0) { DebugUtility.LogError("AssetBundle is RawData: " + assetbundleID); return((AssetBundleCache)null); } AssetBundle ab; if ((itemById.Flags & AssetBundleFlags.Compressed) != (AssetBundleFlags)0) { int size; IntPtr num = NativePlugin.DecompressFile(path, out size); if (num == IntPtr.Zero) { DebugUtility.LogError("Failed to decompress AssetBundle: " + assetbundleID); return((AssetBundleCache)null); } byte[] destination = new byte[size]; Marshal.Copy(num, destination, 0, size); NativePlugin.FreePtr(num); ab = AssetBundle.LoadFromMemory(destination); if (Object.op_Equality((Object)ab, (Object)null)) { DebugUtility.LogError("Failed to create AssetBundle from memory: " + assetbundleID); } } else { ab = AssetBundle.LoadFromFile(path); if (Object.op_Equality((Object)ab, (Object)null)) { DebugUtility.LogError("Failed to open AssetBundle: " + assetbundleID); } } AssetBundleCache assetBundleCache = new AssetBundleCache(assetbundleID, ab); this.mAssetBundles.Add(assetBundleCache); assetBundleCache.Persistent = persistent; return(assetBundleCache); }
private void OnDestroy() { NativePlugin.Deinit(); }
private void UnzipThread2() { AssetDownloader.UnzipThread2Arg mUnzipThreadArg = this.mUnzipThreadArg; if (mUnzipThreadArg == null) { return; } bool flag = false; while (!flag) { this.mMutex.WaitOne(); AssetDownloader.UnzipJob[] array = this.mUnzipJobs.ToArray(); this.mUnzipJobs.Clear(); bool completed = mUnzipThreadArg.completed; bool abort = mUnzipThreadArg.abort; bool mShuttingDown = this.mShuttingDown; this.mMutex.ReleaseMutex(); if (mShuttingDown || abort) { return; } if (array == null || array.Length <= 0) { if (completed) { return; } this.mUnzipSignal.WaitOne(); } else { AssetDownloader.UnzipJob unzipJob = (AssetDownloader.UnzipJob)null; for (int index1 = 0; index1 < array.Length; ++index1) { unzipJob = array[index1]; if (unzipJob.State == AssetDownloader.UnzipJobState.Error) { flag = true; break; } try { if (array != null) { AssetDownloader.UnZipFileSize = (long)((IEnumerable <AssetDownloader.UnzipJob>)array).Sum <AssetDownloader.UnzipJob>((Func <AssetDownloader.UnzipJob, int>)(arg => arg.Size)); } } catch (Exception ex) { Debug.Log((object)ex.ToString()); } File.WriteAllBytes(AssetDownloader.CachePath + unzipJob.nodes[0].ID, unzipJob.Bytes); if ((unzipJob.nodes[0].Item.Flags & AssetBundleFlags.IsCombined) != (AssetBundleFlags)0) { int size = 0; string path = AssetDownloader.CachePath + unzipJob.nodes[0].ID; if ((unzipJob.nodes[0].Item.Flags & AssetBundleFlags.Compressed) != (AssetBundleFlags)0) { IntPtr num1 = NativePlugin.DecompressFile(path, out size); if (num1 == IntPtr.Zero) { throw new Exception("Failed to decompress file [" + path + "]"); } byte[] numArray = new byte[size]; Marshal.Copy(num1, numArray, 0, size); using (BinaryReader binaryReader = new BinaryReader((Stream) new MemoryStream(numArray))) { int num2 = binaryReader.ReadInt32(); for (int index2 = 0; index2 < num2; ++index2) { string lower = binaryReader.ReadInt32().ToString("X8").ToLower(); int count = binaryReader.ReadInt32(); byte[] bytes = binaryReader.ReadBytes(count); File.WriteAllBytes(AssetDownloader.CachePath + lower, bytes); AssetList.Item itemById = mUnzipThreadArg.assetlist.FindItemByID(lower); itemById.Exist = true; AssetDownloader.mExistFile.Add(new AssetDownloader.ExistAssetList(itemById.ID, mUnzipThreadArg.assetlist.SearchItemIdx(itemById.ID))); } } NativePlugin.FreePtr(num1); File.Delete(path + ".tmp"); } else { using (BinaryReader binaryReader = new BinaryReader((Stream)File.Open(path, FileMode.Open))) { int num = binaryReader.ReadInt32(); for (int index2 = 0; index2 < num; ++index2) { string lower = binaryReader.ReadInt32().ToString("X8").ToLower(); int count = binaryReader.ReadInt32(); byte[] bytes = binaryReader.ReadBytes(count); File.WriteAllBytes(AssetDownloader.CachePath + lower, bytes); AssetList.Item itemById = mUnzipThreadArg.assetlist.FindItemByID(lower); itemById.Exist = true; AssetDownloader.mExistFile.Add(new AssetDownloader.ExistAssetList(itemById.ID, mUnzipThreadArg.assetlist.SearchItemIdx(itemById.ID))); } } } } using (List <AssetDownloader.UnzipJob.Node> .Enumerator enumerator = unzipJob.nodes.GetEnumerator()) { while (enumerator.MoveNext()) { AssetDownloader.UnzipJob.Node current = enumerator.Current; if (!File.Exists(unzipJob.Dest + current.ID)) { flag = true; break; } } } if (!flag) { using (List <AssetDownloader.UnzipJob.Node> .Enumerator enumerator = unzipJob.nodes.GetEnumerator()) { while (enumerator.MoveNext()) { AssetDownloader.UnzipJob.Node current = enumerator.Current; current.Item.Exist = true; AssetDownloader.mExistFile.Add(new AssetDownloader.ExistAssetList(current.Item.ID, mUnzipThreadArg.assetlist.SearchItemIdx(current.Item.ID))); } } } else { break; } } try { AssetDownloader.UnZipFileSize = 0L; if (this.mDownloadObserver != null) { this.mDownloadObserver.IsWait = false; } } catch (Exception ex) { Debug.Log((object)ex.ToString()); } if (flag && unzipJob != null) { for (int index = 0; index < unzipJob.nodes.Count; ++index) { string path1 = unzipJob.Dest + unzipJob.nodes[index].ID; if (File.Exists(path1)) { File.Delete(path1); } string path2 = unzipJob.Dest + unzipJob.nodes[index].ID + ".meta"; if (!File.Exists(path2)) { File.Delete(path2); } unzipJob.nodes[index].Item.Exist = false; } } } } this.mMutex.WaitOne(); mUnzipThreadArg.error = true; this.mMutex.ReleaseMutex(); }
private void Start() { NativePlugin.FillArray(Integers, 125); }
public override IList<MenuCommand> GetContextMenu(string controlID) { if (controlID == TOP_LEVEL_COMMAND_ID) { return null; } IList<MenuCommand> contextMenu = new List<MenuCommand>(); _rightClickedPlugin = GetPluginByFileName(controlID.Substring(3)); MenuCommand useThisPluginCmd = new MenuCommand(MENU_ITEM_ENABLED, "Use this plugin", null); useThisPluginCmd.Checked = _rightClickedPlugin.Enabled; contextMenu.Add(useThisPluginCmd); MenuCommand propertiesCmd = new MenuCommand(MENU_ITEM_PROPERTIES, "Plugin properties...", null); propertiesCmd.Enabled = (_rightClickedPlugin.HasProperties && _rightClickedPlugin.Enabled); contextMenu.Add(propertiesCmd); return contextMenu; }
private void Update() { transform.position = NativePlugin.ConvertVector(Vector); }
public byte this[int i] { get { return(NativePlugin.GetLittleDataData(GetPointer(i))); } set { NativePlugin.SetLittleDataData(GetPointer(i), value); } }