Get() public method

public Get ( string fieldName ) : FieldType
fieldName string
return FieldType
コード例 #1
0
    static DisplayMetricsAndroid() {
        // Early out if we're not on an Android device
        if (Application.platform != RuntimePlatform.Android) {
            return;
        }

        // The following is equivalent to this Java code:
        //
        // metricsInstance = new DisplayMetrics();
        // UnityPlayer.currentActivity.getWindowManager().getDefaultDisplay().getMetrics(metricsInstance);
        //
        // ... which is pretty much equivalent to the code on this page:
        // http://developer.android.com/reference/android/util/DisplayMetrics.html

        using (
            AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"),
            metricsClass = new AndroidJavaClass("android.util.DisplayMetrics")
        ) {
            using (
                AndroidJavaObject metricsInstance = new AndroidJavaObject("android.util.DisplayMetrics"),
                activityInstance = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity"),
                windowManagerInstance = activityInstance.Call<AndroidJavaObject>("getWindowManager"),
                displayInstance = windowManagerInstance.Call<AndroidJavaObject>("getDefaultDisplay")
            ) {
                displayInstance.Call("getRealMetrics", metricsInstance);
                Density = metricsInstance.Get<float>("density");
                DensityDPI = metricsInstance.Get<int>("densityDpi");
                HeightPixels = metricsInstance.Get<int>("heightPixels");
                WidthPixels = metricsInstance.Get<int>("widthPixels");
                ScaledDensity = metricsInstance.Get<float>("scaledDensity");
                XDPI = metricsInstance.Get<float>("xdpi");
                YDPI = metricsInstance.Get<float>("ydpi");
            }
        }
    }
コード例 #2
0
        public GenericHIDDevice(int inx, AndroidJavaObject device, IHIDInterface hidInterface)
			: base(inx, device.Get<int>("VID"), device.Get<int>("PID"),device.Get<string>("path"), IntPtr.Zero, hidInterface, device.Get<string>("path"))
        {


            __lastHIDReport = new HIDReport(this.index, new byte[_InputReportByteLength], HIDReport.ReadStatus.Success);
             
            _device=device;
            _listener = new ReadWriteListenerProxy();
        }
コード例 #3
0
ファイル: Density.cs プロジェクト: polishedsolid/Unity
 static Density()
 {
     Value = 1.0f;
     #if UNITY_ANDROID
     using (
         AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"),
         metricsClass = new AndroidJavaClass("android.util.DisplayMetrics")
         ) {
         using (
             AndroidJavaObject metricsInstance = new AndroidJavaObject("android.util.DisplayMetrics"),
             activityInstance = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity"),
             windowManagerInstance = activityInstance.Call<AndroidJavaObject>("getWindowManager"),
             displayInstance = windowManagerInstance.Call<AndroidJavaObject>("getDefaultDisplay")
             ) {
             displayInstance.Call ("getMetrics", metricsInstance);
             Value = metricsInstance.Get<float> ("density");
         }
     }
     #endif
     #if UNITY_IPHONE
     if (Application.platform != RuntimePlatform.OSXEditor) {
         Value = IOSDensity_ ();
     }
     #endif
 }
コード例 #4
0
	// Use this for initialization
	void Start () {
		AndroidJavaClass majcUnityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
		AndroidJavaObject majoDivePluginInstance = majcUnityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");
		metricsClass= new AndroidJavaClass("android.util.DisplayMetrics");
		metricsInstance= new AndroidJavaObject("android.util.DisplayMetrics");
		windowManagerInstance=majoDivePluginInstance.Call<AndroidJavaObject>("getWindowManager");
		displayInstance=windowManagerInstance.Call<AndroidJavaObject>("getDefaultDisplay");
		
		displayInstance.Call("getMetrics",metricsInstance);
		
		density=metricsInstance.Get<float>("density");
		densitydpi=metricsInstance.Get<int> ("densityDpi");
		vpixels=metricsInstance.Get<int>("heightPixels");
		vpixels=Screen.height;
		hpixels=metricsInstance.Get<int>("widthPixels");
		//hpixels=displayInstance.Call<int>("getWidth");
		hpixels=Screen.width;
		scaledDensity=metricsInstance.Get<float>("scaledDensity");
		xdpi=metricsInstance.Get<float>("xdpi");
		ydpi=metricsInstance.Get<float>("ydpi");
		xmm=hpixels/xdpi/0.0393701f;
		ymm=vpixels/ydpi/0.0393701f;
		
		
		hpixels=Screen.width;
		vpixels=Screen.height;
		xmm=hpixels/xdpi/0.0393701f;
		ymm=vpixels/ydpi/0.0393701f;
		mmdist=xmm/2;
	}
コード例 #5
0
        void onRead(AndroidJavaObject jo) {
          //  Debug.Log("ReadWriteListenerProxy>>onRead:");
           //   Debug.Log("ReadWriteListenerProxy>>onRead rawObject:" + bufferObject);

            AndroidJavaObject bufferObject = jo.Get<AndroidJavaObject>("Buffer");

        

            byte[] buffer = AndroidJNIHelper.ConvertFromJNIArray<byte[]>(bufferObject.GetRawObject());
          //  Debug.Log("ReadWriteListenerProxy>>Call array succeded:");

         //   Debug.Log("ReadWriteListenerProxy>>onRead:" + BitConverter.ToString(buffer));
            if (ReadComplete != null)
                ReadComplete.Invoke(buffer);
        }
コード例 #6
0
            public void onAttributionChanged(AndroidJavaObject attribution)
            {
                AdjustAttribution adjustAttribution = new AdjustAttribution ();

                adjustAttribution.trackerName = attribution.Get<string> ("trackerName");
                adjustAttribution.trackerToken = attribution.Get<string> ("trackerToken");
                adjustAttribution.network = attribution.Get<string> ("network");
                adjustAttribution.campaign = attribution.Get<string> ("campaign");
                adjustAttribution.adgroup = attribution.Get<string> ("adgroup");
                adjustAttribution.creative = attribution.Get<string> ("creative");

                if (callback != null) {
                    callback (adjustAttribution);
                }
            }
コード例 #7
0
    private static int getDensitySize(int size) {
		#if UNITY_EDITOR
		return 0;
		#elif UNITY_IPHONE
		float screenScale = getScreenScale_();
		return (int)(size / screenScale + 0.5f);
        #elif UNITY_ANDROID
        AndroidJavaObject displayMetrics = new AndroidJavaObject ("android.util.DisplayMetrics");
        AndroidJavaClass unityPlayerClass = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
        AndroidJavaObject activityObject = unityPlayerClass.GetStatic<AndroidJavaObject> ("currentActivity");
        AndroidJavaObject windowManagerObject = activityObject.Call<AndroidJavaObject> ("getWindowManager");
        AndroidJavaObject displayObject = windowManagerObject.Call<AndroidJavaObject> ("getDefaultDisplay");
        displayObject.Call ("getMetrics", displayMetrics);
        float density = displayMetrics.Get<float> ("density");
        return (int)(((size / density) + 0.5f));
        #endif
    }
コード例 #8
0
    // Use this for initialization.
    public void Start()
    {
        // Ensures all necessary scripts are added for the MainObject
        gameStateManagerRef = gameObject.GetComponent<GameStateManager>();
        gameStateManagerRef.EnsureCoreScriptsAdded();
        gameStateManagerRef.EnsureScriptAdded("MainMenu");

        if(gameStateManagerRef.gameStartedFromUI){
            activeScreen = gameObject.GetComponent("MainMenu") as MainMenu;
            currentScreenArea = ScreenAreas.MainMenu;
        }
        else{
            // This will not be the active screen, but active screen needs to be initialized.
            activeScreen = gameObject.GetComponent("MainMenu") as MainMenu;
            activeScreen.enabled = false;
            currentScreenArea = ScreenAreas.InGame;
        }

        screenOrientation = ScreenOrientation.Landscape;
        deviceOrientation = DeviceOrientation.LandscapeLeft;

        if(Application.platform.Equals(RuntimePlatform.Android)){
            #if UNITY_ANDROID
            using(AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"),
                    metricsClass = new AndroidJavaClass("android.util.DisplayMetrics")){
                using(AndroidJavaObject metricsInstance = new AndroidJavaObject("android.util.DisplayMetrics"),
                        activityInstance = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity"),
                        windowManagerInstance = activityInstance.Call<AndroidJavaObject>("getWindowManager"),
                        displayInstance = windowManagerInstance.Call<AndroidJavaObject>("getDefaultDisplay")){
                    displayInstance.Call("getMetrics", metricsInstance);
                    screenResolution.y = metricsInstance.Get<int>("heightPixels");
                    screenResolution.x = metricsInstance.Get<int>("widthPixels");
                    screenSize.x = Screen.width;
                    screenSize.y = Screen.height;
                    Screen.SetResolution((int)screenResolution.x, (int)screenResolution.y, true);
                    deviceOrientation = Input.deviceOrientation;
                }
            }
            #endif
        }
        else{
            // Overall screen resolution must be set initially to screen size for UI, then set to screen resolution while in game.
            screenSize = new Vector2(Screen.width, Screen.height);
            screenResolution = new Vector2(Screen.currentResolution.width, Screen.currentResolution.height);

            if(gameStateManagerRef.inUI){
                Screen.SetResolution((int)screenSize.x, (int)screenSize.y, gameStateManagerRef.fullScreen);
            }

            // Developer started in a level.
            else{
                Screen.SetResolution((int)screenResolution.x, (int)screenResolution.y, gameStateManagerRef.fullScreen);
            }
        }
    }
コード例 #9
0
 public static void Initialize()
 {
     #if UNITY_ANDROID && !UNITY_EDITOR
         AndroidJavaClass jc = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
         mainActivity = jc.GetStatic<AndroidJavaObject> ("currentActivity");
         serverController = mainActivity.Get<AndroidJavaObject>("serverController");
         clientsController = mainActivity.Get<AndroidJavaObject>("clientsController");
     #endif
 }
コード例 #10
0
    /// <summary>
    /// Use this for initialization
    /// </summary>
    public void Start()
    {
        // Initialize the reference to the GameStateManager so that is actually points to it.
        gameStateManagerRef = gameObject.GetComponent<GameStateManager>();
        // start screen is always the first screen to be displayed so might as well load it here without any fancy footwork
        if (currentScreenArea.Equals(ScreenAreas.None))
        {
            gameObject.AddComponent<MainMenu>();
            activeScreen = gameObject.GetComponent("MainMenu") as MainMenu;
            currentScreenArea = ScreenAreas.MainMenu;
            screenOrientation = ScreenOrientation.Landscape;
            deviceOrientation = DeviceOrientation.LandscapeLeft;

            if (Application.platform.Equals(RuntimePlatform.Android))
            {
                using (AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"),
                      metricsClass = new AndroidJavaClass("android.util.DisplayMetrics"))
                {
                    using (AndroidJavaObject metricsInstance = new AndroidJavaObject("android.util.DisplayMetrics"),
                            activityInstance = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity"),
                            windowManagerInstance = activityInstance.Call<AndroidJavaObject>("getWindowManager"),
                            displayInstance = windowManagerInstance.Call<AndroidJavaObject>("getDefaultDisplay"))
                    {
                        displayInstance.Call("getMetrics", metricsInstance);
                        screenResolution.y = metricsInstance.Get<int>("heightPixels");
                        screenResolution.x = metricsInstance.Get<int>("widthPixels");
                        screenSize.x = Screen.width;
                        screenSize.y = Screen.height;
                        Screen.SetResolution((int)screenResolution.x, (int)screenResolution.y, true);
                        deviceOrientation = Input.deviceOrientation;
                    }
                }
            }

            else
            {
                // Overall screen resolution must be set initially to screen size for UI,
                // then set to screen resolution while in game
                screenSize = new Vector2(Screen.width, Screen.height);
                screenResolution = new Vector2(Screen.currentResolution.width, Screen.currentResolution.height);
                Screen.SetResolution((int)screenSize.x, (int)screenSize.y, gameStateManagerRef.fullScreen);
            }
        }
    }
コード例 #11
0
ファイル: PlayFabAndroid.cs プロジェクト: gabrielamboss/Ulkoa
		public static PlayFabNotificationPackage GetPushCache()
        {
			AndroidJavaObject package = new AndroidJavaObject("com.playfab.unityplugin.GCM.PlayFabNotificationPackage");
			package = PlayFabPushCacheClass.CallStatic<AndroidJavaObject>("getPushCache");
			
			PlayFabNotificationPackage cache = new PlayFabNotificationPackage();
			if(package != null)
			{
				cache.Title = package.Get<string>("Title");
				cache.Message = package.Get<string>("Message");
				cache.Icon = package.Get<string>("Icon");
				cache.Sound = package.Get<string>("Sound");
				cache.CustomData = package.Get<string>("CustomData");
			}
			else
			{
				Debug.Log("Package was null");
			}
			
			return cache;
        }
コード例 #12
0
ファイル: DiveJava.cs プロジェクト: MizoTake/RemakePakure
	public static void init(){
		start_once=0;
		#if UNITY_EDITOR
		
		#elif UNITY_ANDROID
		
		javadivepluginclass = new AndroidJavaClass("com.shoogee.divejava.divejava") ;
		javaunityplayerclass= new AndroidJavaClass("com.unity3d.player.UnityPlayer");
		currentactivity = javaunityplayerclass.GetStatic<AndroidJavaObject>("currentActivity");
		javadiveplugininstance = javadivepluginclass.CallStatic<AndroidJavaObject>("instance");
		object[] args={currentactivity};
		javadiveplugininstance.Call<string>("set_activity",args);

		String answer;
		answer= javadiveplugininstance.Call<string>("setFullscreen");

		// Screen Metrics
		
		metricsClass= new AndroidJavaClass("android.util.DisplayMetrics");
		metricsInstance= new AndroidJavaObject("android.util.DisplayMetrics");
		windowManagerInstance=currentactivity.Call<AndroidJavaObject>("getWindowManager");
		displayInstance=windowManagerInstance.Call<AndroidJavaObject>("getDefaultDisplay");
		
		displayInstance.Call("getMetrics",metricsInstance);
		
		density=metricsInstance.Get<float>("density");
		densitydpi=metricsInstance.Get<int> ("densityDpi");
		vpixels=metricsInstance.Get<int>("heightPixels");
		vpixels=Screen.height;
		hpixels=metricsInstance.Get<int>("widthPixels");
		//hpixels=displayInstance.Call<int>("getWidth");
		hpixels=Screen.width;
		scaledDensity=metricsInstance.Get<float>("scaledDensity");
		xdpi=metricsInstance.Get<float>("xdpi");
		ydpi=metricsInstance.Get<float>("ydpi");
		xmm=hpixels/xdpi/0.0393701f;
		ymm=vpixels/ydpi/0.0393701f;
		
		#elif UNITY_IPHONE
		
		#endif 	
		initiated = true;
	}
コード例 #13
0
    public IEnumerator TakePhotoSuccess(string imagePath)
    {
        Debug.Log("### STRING RETURNED >>"+imagePath+"<< ###");
        if(GameObject.Find("MainScene").GetComponent<GUIStart>().enabled == false)
            yield return false;
        GameObject.Find("camPivot").GetComponent<gyroControl_v2>().enabled = false;
        GameObject.Find("LightPivot").GetComponent<LightConfiguration>().setCompassActive(false);

         Debug.Log("Calling native android functions to get the image size");
         AndroidJavaObject options = new AndroidJavaObject("android/graphics/BitmapFactory$Options");
        // Debug.Log("options set injustdecodebounds");
        options.Set<bool>("inJustDecodeBounds", true);
          //  Debug.Log("factory class");
        AndroidJavaClass factory = new AndroidJavaClass("android.graphics.BitmapFactory");
        //Debug.Log("factorydecodeFile");
        factory.CallStatic<AndroidJavaObject>("decodeFile",imagePath, options);
        int imgWidth = options.Get<int>("outWidth");
        int imgHeight = options.Get<int>("outHeight");
        Debug.Log("imgWidth=" + imgWidth);
        Debug.Log("imgHeight=" + imgHeight);
        float scaleMax = 1;
        //Debug.Log("javaobjects end");
        if (imgWidth > Screen.width)
        {

            scaleMax = ((float)Screen.width) / imgWidth;
        }
        if (imgHeight > Screen.height)
        {
        scaleMax = Mathf.Min(scaleMax, ((float)Screen.height) / imgHeight);
        }
        //Redimensione la photo si elle est plus grande que l'écran
         if(scaleMax<1){
            Debug.Log("Photo too big, scaling the photo taken : ratio="+scaleMax);
            EtceteraAndroid.scaleImageAtPath(imagePath,scaleMax);
         }
         WWW www = new WWW("file://" + imagePath);
         yield return www;
         Texture2D tex = www.texture;

          //  AndroidCommons.Toast("Texture loaded !!!!!");

        //EditorUtility.CompressTexture(tex, TextureFormat.RGBA32,TextureCompressionQuality.Fast);
        //tex.Compress(true);
        //ImgUtils.Bilinear(tex, tex.width / 2, tex.height / 2, true);

        /*
        int k = 0;
        while ((tex.width > 4096 || tex.height > 4096) && k < 2)
        {
            k++;
            Debug.Log("Texture of the photo ist too big !!!! tex.width= " + tex.width + " tex.height= " + tex.height);
            TextureScale.Bilinear(tex, tex.width / 2, tex.height / 2);
        }
        */

        //StartCoroutine(AndroidLoadPhoto(imagePath));

        Montage.sm.updateFond(tex, false,"");

        //	Montage.sm.updateFond(tex, false,"");
        //GetComponent<GUIMenuMain>().setStarter(true, true);

        StartCoroutine (loadImg());

        //		if(System.IO.File.Exists(imagePath))
        //		{
        //			Debug.Log("IMG STILL EXISTS: Deleting ...");
        //			System.IO.File.Delete(imagePath);
        //		}

        Debug.Log("setting background tex");
        GameObject.Find("backgroundImage").GetComponent<BgImgManager>().SetBackgroundTexture(tex);
        GameObject.Find("mainCam").GetComponent<MainCamManager>().FitViewportToScreen();
    }
コード例 #14
0
    private void ResizeTexAtPath(string imagePath)
    {
        AndroidJavaObject options = new AndroidJavaObject("android/graphics/BitmapFactory$Options");
        // Debug.Log("options set injustdecodebounds");
        options.Set<bool>("inJustDecodeBounds", true);
        //  Debug.Log("factory class");
        AndroidJavaClass factory = new AndroidJavaClass("android.graphics.BitmapFactory");
        //Debug.Log("factorydecodeFile");
        factory.CallStatic<AndroidJavaObject>("decodeFile", imagePath, options);
        int imgWidth = options.Get<int>("outWidth");
        int imgHeight = options.Get<int>("outHeight");
        Debug.Log("imgWidth=" + imgWidth);
        Debug.Log("imgHeight=" + imgHeight);
        float scaleMax = 1;
        //Debug.Log("javaobjects end");
        if (imgWidth > Screen.width)
        {

        scaleMax = ((float)Screen.width) / imgWidth;
        }
        if (imgHeight > Screen.height)
        {
        scaleMax = Mathf.Min(scaleMax, ((float)Screen.height) / imgHeight);
        }
        //Redimensione la photo si elle est plus grande que l'écran
        if (scaleMax < 1)
        {
        Debug.Log("Photo too big, scaling the photo taken : ratio=" + scaleMax);
        #if UNITY_ANDROID
        EtceteraAndroid.scaleImageAtPath(imagePath, scaleMax);
        #endif
        }
    }
コード例 #15
0
    bool UpdateCodecOutput(AndroidJavaObject Decoder)
    {
        AndroidJavaObject BufferInfo = new AndroidJavaObject("android.media.MediaCodec$BufferInfo");

        //	returns status if not buffer index
        int OutputBufferIndex = Decoder.Call<int>("dequeueOutputBuffer", BufferInfo, TIMEOUT_USEC );

        //	got a format change, update texture etc
        if ( OutputBufferIndex == INFO_OUTPUT_FORMAT_CHANGED )
        {
            AndroidJavaObject MediaFormat = Decoder.Call<AndroidJavaObject>("getOutputFormat");
            if ( !ChangeFormat( MediaFormat ) )
                return false;

            return true;
        }

        bool Ready = true;
        switch ( OutputBufferIndex )
        {
        case INFO_TRY_AGAIN_LATER:
        case INFO_OUTPUT_BUFFERS_CHANGED:
        case INFO_OUTPUT_FORMAT_CHANGED:
        case OTHER_ERROR:
            Ready = false;
            break;

        default:
            if ( OutputBufferIndex < 0 )
                Ready = false;
            break;
        }

        if ( !Ready )
        {
            //Log ("Not ready to output yet... " + OutputBufferIndex);
            return true;
        }

        //Log ("got Output buffer #" + OutputBufferIndex);
        bool EndOfStream = (BufferInfo.Get<int>("flags") & BUFFER_FLAG_END_OF_STREAM) != 0;
        if ( EndOfStream )
        {
            Log ("end of output stream");
            return false;
        }

        //	grab buffer
        AndroidJavaObject Buffer = GetDecoderOutputBuffer (Decoder, OutputBufferIndex);
        if ( Buffer == null ) {
            Log ("failed to get output buffer #" + OutputBufferIndex);
            return false;
        }

        bool DoRender = ( BufferInfo.Get<int>("size") != 0 );
        //Log ("Got buffer: render? " + DoRender);

        //	gr: too big to copy to memory! over 1gb!?
        //	copy to texture
        int ByteLength = AndroidJNI.GetArrayLength (Buffer.GetRawObject ());
        Log ("Byte buffer length: " + ByteLength);
        //		byte[] Bytes = AndroidJNI.FromByteArray (Buffer.GetRawObject ());
        //byte[] Bytes = Buffer.Call<byte[]> ("array");
        //		Log ("Copy " + Bytes.Length + "bytes to texture!");

        // As soon as we call releaseOutputBuffer, the buffer will be forwarded
        // to SurfaceTexture to convert to a texture.  The API doesn't guarantee
        // that the texture will be available before the call returns, so we
        // need to wait for the onFrameAvailable callback to fire.
        Decoder.Call("releaseOutputBuffer", OutputBufferIndex, DoRender);
        glGetError("releaseOutputBuffer");
        mDecoder.SurfaceTexture.Call ("updateTexImage");
        glGetError ("updateTexImage");
        //	outputSurface.awaitNewImage();
        //	outputSurface.drawImage(true);

        return true;
    }