void Awake() { Instance = this; sceneRoot = GameObject.Find("SceneObj/Scene root").GetComponent <Transform>(); //arControl = GameObject.Find("SceneObj/ARToolKit").GetComponent<ARController>(); native = GameObject.Find("NativeCall").GetComponent <NativeCall>(); }
internal static unsafe void SetOutputMatrix(this SourceVoice sourceVoice, Voice destionationVoice, int sourceChannels, int destinationChannels, float *matrix, int operationSet = 0) { IntPtr destPtr = destionationVoice != null ? destionationVoice.NativePointer : IntPtr.Zero; int result = NativeCall <int> .Method <IntPtr, uint, uint, IntPtr, uint>(sourceVoice.NativePointer, 16, destPtr, (uint)sourceChannels, (uint)destinationChannels, new IntPtr(matrix), (uint)operationSet); ((SharpDX.Result)result).CheckError(); }
void Awake() { Instance = this; sceneRoot = GameObject.Find("SceneObj/Scene root").GetComponent <Transform>(); //arControl = GameObject.Find("SceneObj/ARToolKit").GetComponent<ARController>(); native = GameObject.Find("NativeCall").GetComponent <NativeCall>(); arCamera = Global.FindChild <Camera>(sceneRoot.transform, "Camera"); }
public static void SetDepthStencil(this Device device, Texture depthTexture, int level) { using (var surface = GetSurface(depthTexture, level)) { const int SET_DEPTH_STENCIL = 39; ((Result)NativeCall <int> .Method <IntPtr>(device.NativePointer, SET_DEPTH_STENCIL, surface)).CheckError(); } }
public static unsafe void SetRenderTarget(this Device device, int index, Texture renderTargetTexture, int level) { using (var surface = GetSurface(renderTargetTexture, level)) { const int SET_RENDER_TARGET = 37; ((Result)NativeCall <int> .Method <int, IntPtr>(device.NativePointer, SET_RENDER_TARGET, index, surface)).CheckError(); } }
//打开相册 private void OpenPhoto() { NativeCall.OpenPhoto((Texture2D tex) => { rawImage.texture = tex; rawImage.rectTransform.sizeDelta = new Vector2(tex.width, tex.height); }); }
public static unsafe RefCountedPointer GetSurface(this Texture texture, int level) { const int GET_SURFACE_LEVEL = 18; IntPtr result = IntPtr.Zero; IntPtr resultPointer = new IntPtr((void *)&result); // We need address of pointer, because it's out pointer ((Result)NativeCall <int> .Method <int, IntPtr>(texture.NativePointer, GET_SURFACE_LEVEL, level, resultPointer)).CheckError(); return(new RefCountedPointer(result)); }
public void testNativeJava() { String statement = "Java: System.out.println(value);"; ETestParser parser = new ETestParser(statement, false); NativeCall call = parser.parse_native_statement(); Assert.IsNotNull(call); Assert.IsTrue(call is NativeCall); }
public void parsesNativeJava() { String statement = "Java: System.str.println(value);"; OTestParser parser = new OTestParser(statement); NativeCall call = parser.parse_native_statement(); Assert.IsNotNull(call); Assert.IsTrue(call is NativeCall); }
public void testNativeCSharp() { String statement = "C#: Console.println(value);"; ETestParser parser = new ETestParser(statement, false); NativeCall call = parser.parse_native_statement(); Assert.IsNotNull(call); Assert.IsTrue(call is NativeCall); }
public static void Init(string xxteakey = "") { AppController.InitGame(xxteakey); if (nativeCall == null) { nativeCall = new NativeCall(); nativeCall.InitNativeCall(); } }
//打开相机 private void OpenCamera() { NativeCall.OpenCamera((Texture2D tex) => { rawImage.texture = tex; rawImage.rectTransform.sizeDelta = new Vector2(tex.width, tex.height); Instantiate(Resources.Load <GameObject>("ImageCropper")); CutPhoto(tex); }); }
public static unsafe bool HasDeviceChanged(XAudio2 engine, string displayName) { const int GetDeviceDetailsMethodOffset = 4; XAUDIO2_DEVICE_DETAILS details; var result = (Result)NativeCall.Function <int, IntPtr, int, IntPtr>(new NativeFunction(engine.NativePointer, GetDeviceDetailsMethodOffset), engine.NativePointer, 0, new IntPtr(&details)); result.CheckError(); return(!displayName.Equals(details.DisplayName, 256)); }
public void EditTrivia() { MessageManager.Instance.DebugMessage("Start editing trivia question."); // call native UI here... NativeCall nativeCall = FindObjectOfType <NativeCall>(); nativeCall.triviaContentFacade = this; nativeCall.GiveActivityData("ActivityID", "ActivityTitle"); nativeCall.ShowNative("Trivia"); }
void Start() { DontDestroyOnLoad(gameObject); DontDestroyOnLoad(backMusic.gameObject); var temp = Resources.LoadAll <AudioClip>("SysytemAudios/"); systemAudios = new List <AudioClip>(); systemAudios.AddRange(temp); clips = new Dictionary <string, AudioClip>(); native = GameObject.Find("NativeCall").GetComponent <NativeCall>(); }
public static unsafe Result TryAcquire(this Device device) { #if BLIT || BLITCREMENTAL Debug.Assert(false); return(Result.False); #else // Number 7 is offset in member function pointer table, it's same number as found in SharpDX.DirectInput.Device.Acquire() // It's unlikely to change, because it would make existing native apps not working return((Result)NativeCall <int> .Method(device.NativePointer, 7)); #endif }
//private GameObject parentalLock; //private GameObject unlock; protected override void Start() { base.Start(); mButton_Set = GetWidget("Button_Set"); if (mButton_Set != null) { mButton_Set.OnMouseClick = ButtonSetOnClick; } native = GameObject.Find("NativeCall").GetComponent <NativeCall>(); //parentalLock = GameObject.Find("ParentalLock"); //unlock = Global.FindChild(parentalLock.transform, "Unlock"); }
void Awake() { close = transform.Find("UnlockBG/Close"); panel = transform.parent.Find("Panel"); Button button = close.GetComponent <Button>(); if (button != null) { //button.onClick.RemoveListener(OnClick); button.onClick.AddListener(OnClick); } native = GameObject.Find("NativeCall").GetComponent <NativeCall>(); }
//void OnEnable() //{ // RegiSecondPanel(image_Connect, SetBack); // RegiSecondPanel(unlock, UnlockHint); //} //void OnDisable() //{ // UnRegiSecondPanel(image_Connect); // UnRegiSecondPanel(unlock); //} protected override void Start() { base.Start(); native = GameObject.Find("NativeCall").GetComponent <NativeCall>(); mButton_CameraSure = GetWidget("Button_CameraSure"); if (mButton_CameraSure != null) { mButton_CameraSure.OnMouseClick = OnButtonCameraSureClick; } mButton_NetworkSure = GetWidget("Button_NetWorkSure"); if (mButton_NetworkSure != null) { mButton_NetworkSure.OnMouseClick = OnButtonNetworkSureClick; } }
public void SetTextHint(string text) { image_HealthHint.SetActive(true); if (native == null) { native = GameObject.Find("NativeCall").GetComponent <NativeCall>(); } AudioManager.Instance.PlaySystem("healthhint_" + native.GetEyeProtectionDuration().ToString()); if (text_Hint != null) { text_Hint.text = text; } StartCoroutine(WaitFor(3, () => { if (image_HealthHint != null) { image_HealthHint.SetActive(false); } }));//3s之后隐藏 }
//打开相册 private void OpenPhoto() { NativeCall.OpenPhoto((Texture2D tex) => { Debug.LogError("图片读取完成"); CutPhoto(tex); try { byte[] bytes222 = tex.EncodeToPNG(); Debug.LogError("bytes222.lenght:" + bytes222.Length); } catch (System.Exception e) { Debug.LogError(e.ToString()); } Debug.LogError("转换完成.lenght:"); rawImage.texture = tex; //rawImage.rectTransform.sizeDelta = new Vector2(tex.width, tex.height); }); }
protected override void Start() { base.Start(); //arControl = GameObject.Find("SceneObj/ARToolKit").GetComponent<ARController>(); //videoBack = arControl.VideoBackground; //if (videoBack != null) // mCamera = videoBack.GetComponent<Camera>(); arCamera = GameObject.Find("SceneObj/Scene root/Camera").GetComponent <Camera>(); mToggle_Tool = GetWidget("Toggle_Tool"); image_Check = Global.FindChild <Image>(transform, "Image_Check"); tool = mToggle_Tool.GetComponent <Image>(); gird = Global.FindChild(transform, "Grid"); if (mToggle_Tool != null) { mToggle_Tool.OnMouseClick = ToggleToolOnClick; } image_Check.enabled = false; mButton_Photo = GetWidget("Button_Photo"); mButton_Record = GetWidget("Button_Record"); if (mButton_Record != null) { mButton_Record.OnMouseClick = ButtonRecordOnClick; } if (mButton_Photo != null) { mButton_Photo.OnMouseClick = ButtonPhotoOnClick; } gird.transform.localPosition = new Vector3(60f, 128, 0); _sprite = tool.sprite; rect = new Rect(0, 0, Screen.width, Screen.height); //frontMostCamera = GameObject.Find("FrontMostCamera").GetComponent<Camera>(); //if (frontMostCamera != null) // frontMostCamera.enabled = false; IsRender = false; native = GameObject.Find("NativeCall").GetComponent <NativeCall>(); }
public T LoadMethod <T>(string libraryPath, string name, Encoding stringEncoding) where T : Delegate { if (!IsUsable) { throw new SecurityException(INativeLoader.securityExceptionMessage); } if (stringEncoding == Encoding.Default) { stringEncoding = null; } if (stringEncoding != null && !getEncodingMethods.ContainsKey(stringEncoding)) { throw new NotSupportedException($"Encoding '{stringEncoding.BodyName}' is not supported."); } #region Getting native method if (!loadedLibraries.TryGetValue(libraryPath, out IntPtr library)) { if (NativeLibrary.TryLoad(libraryPath, out library)) { loadedLibraries.Add(libraryPath, library); } else { return(null); } } if (!NativeLibrary.TryGetExport(library, name, out IntPtr pointer)) { return(null); } #endregion T function = Marshal.GetDelegateForFunctionPointer <T>(pointer); var wrapper = new NativeCall <T>(this, function); IntPtr wrapperPtr = GCHandle.ToIntPtr(wrapper.handle); wrappers.Add(wrapper); ParameterInfo[] parameters = function.Method.GetParameters(); Type[] parameterTypes = parameters.Select(parameter => parameter.ParameterType).ToArray(); Type type = typeof(NativeCall <T>); #region Generating secured wrapper method var dynamicMethod = new DynamicMethod(name, function.Method.ReturnType, parameterTypes, typeof(NativeCall <>).Module, skipVisibility: true); var il = dynamicMethod.GetILGenerator(); Label nativeCall = il.DefineLabel(); il.DeclareLocal(typeof(GCHandle)); il.Emit(OpCodes.Ldc_I8, wrapperPtr.ToInt64()); il.Emit(OpCodes.Newobj, intPtrConstructor); il.Emit(OpCodes.Call, fromIntPtrMethod); il.Emit(OpCodes.Stloc_0); il.Emit(OpCodes.Ldloca_S, 0); il.Emit(OpCodes.Call, handleGetTarget); il.Emit(OpCodes.Isinst, type); il.Emit(OpCodes.Dup); var getIsUsable = type.GetMethod($"get_{nameof(NativeCall<T>.IsUsable)}", BindingFlags.NonPublic | BindingFlags.Instance); il.Emit(OpCodes.Callvirt, getIsUsable); il.Emit(OpCodes.Brtrue_S, nativeCall); il.Emit(OpCodes.Ldstr, INativeLoader.securityExceptionMessage); il.Emit(OpCodes.Newobj, exceptionConstructor); il.Emit(OpCodes.Throw); il.MarkLabel(nativeCall); var nativeMethod = type.GetField(nameof(NativeCall <T> .nativeMethod), BindingFlags.NonPublic | BindingFlags.Instance); il.Emit(OpCodes.Ldfld, nativeMethod); for (int i = 0; i < parameters.Length; i++) { if (parameterTypes[i] == typeof(string) && stringEncoding != null) { il.Emit(OpCodes.Call, getDefaultEncoding); il.Emit(OpCodes.Call, getDefaultEncoding); il.Emit(OpCodes.Call, getEncodingMethods[stringEncoding]); il.Emit(OpCodes.Call, getDefaultEncoding); il.Emit(OpCodes.Ldarg_S, i); il.Emit(OpCodes.Call, getBytes); il.Emit(OpCodes.Call, convertToTargetBytes); il.Emit(OpCodes.Call, getString); } else { il.Emit(OpCodes.Ldarg_S, i); } } il.Emit(OpCodes.Callvirt, typeof(T).GetMethod(nameof(Action.Invoke))); il.Emit(OpCodes.Ret); #endregion var securedCall = (T)dynamicMethod.CreateDelegate(typeof(T)); wrapper.method = securedCall; return(securedCall); }
public RecordTime currRecord;//当前超时检测 void Start() { records = new List <RecordTime>(); native = GameObject.Find("NativeCall").GetComponent <NativeCall>(); }
public static AppState Reduce(AppState state, object bAction) { int markSize = 20; switch (bAction) { case MapHorizontalDragAction action: { state.mapState.offsetX = action.offset; break; } case MapVerticalDragAction action: { state.mapState.offsetY = action.offset; break; } case MapZoomAction action: { state.mapState.scaleLastFrame = state.mapState.scale; state.mapState.scale = action.scale; break; } case ChangeMapZoomLevelAction action: { state.mapState.zoomLevel = action.zoomLevel; break; } case ChangeIndexAction action: { state.settingState.index = action.index; int ind = action.index; switch (action.index) { case 0: { break; } case 1: { NativeCall.OpenPhoto((Texture2D tex) => { //rawImage.texture = tex; //rawImage.rectTransform.sizeDelta = new Vector2(tex.width / 5, tex.height / 5); }); break; } case 11: { ind = 1; NativeCall.OpenCamera((Texture2D tex) => { //rawImage.texture = tex; //rawImage.rectTransform.sizeDelta = new Vector2(tex.width/5, tex.height/5); }); break; } } if (state.settingState.products.Count >= 3) { state.settingState.products.Dequeue(); } state.settingState.products.Enqueue(new Product() { type = (ProductType)(ind) }); break; } case AddMarkInViewAction action: { foreach (Mark mark in action.newMarks) { if (state.mapState.marks.Count > markSize) { state.mapState.marks.Dequeue(); } state.mapState.marks.Enqueue(mark); } break; } case AddMarkJustLoadingAction action: { state.mapState.marksJustLoading = action.newMarks; break; } case AddMarkOnMapAction action: { foreach (GameObject mark in action.newMarks) { if (state.mapState.marksOnMap.Count > markSize) { GameObject t = state.mapState.marksOnMap.Dequeue(); UnityEngine.Object.Destroy(t); } state.mapState.marksOnMap.Enqueue(mark); } break; } case SelectMarkAction action: { //Debug.LogError("pos: " + action.pos.x + " " + action.pos.y); //Debug.LogError("pos2: " + Input.mousePosition.x + " " + Input.mousePosition.y); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { //Debug.DrawLine(ray.origin, hit.point); GameObject gameobj = hit.collider.gameObject;; if (gameobj.tag == "mark") { Navigator.push(Prefabs.instance.homeContext, new MaterialPageRoute(builder: (_) => { return(new StoreProvider <AppState>( store: StoreProvider.store, new MaterialApp( home: new FindScreenConnector() ) )); })); } } break; } } return(state); }
//保存照片 private void SavePhoto() { NativeCall.SavePhoto(rawImage.texture as Texture2D); }
/** * Creates a dynamic native. This should only be called in AskPluginLoad(), or * else you risk not having your public static shared with other plugins. * * @param name Name of the dynamic native; must be unique among * all other registered dynamic natives. * @param func Function to use as the dynamic native. */ public static void CreateNative(string name, NativeCall func) { throw new NotImplementedException(); }