随笔记录2

1. unity提供了AndroidJavaClass支持,直接贴源码:

 

                if( nativeManager == null ){
			using( var jc = new AndroidJavaClass( "cn.easyar.android.NativeManager" ) )
   			nativeManager = jc.CallStatic<AndroidJavaObject>( "instance" );
		}
		
		string sdCardPath = nativeManager.Call<string>("GetExternalStoragePath");
		Debug.Log("SDCard Path : " + sdCardPath);
		
		if( sdCardPath != null && sdCardPath != "" ){
			// create SightPlus picture directory.
			if( !System.IO.Directory.Exists( System.IO.Path.Combine (sdCardPath, "Pictures") ) ){
				try{
					System.IO.Directory.CreateDirectory( System.IO.Path.Combine (sdCardPath, "Pictures") );
				}catch{
					Debug.Log("Create Pictures dir failed");
				}
			}
			
			if( !System.IO.Directory.Exists( System.IO.Path.Combine (sdCardPath, "Pictures/SightPlus") ) ){
				try{
					System.IO.Directory.CreateDirectory( System.IO.Path.Combine (sdCardPath, "Pictures/SightPlus") );
				}catch{
					Debug.Log("Create Pictures dir failed");
				}
			}
			
			if( System.IO.Directory.Exists( System.IO.Path.Combine (sdCardPath, "Pictures/SightPlus") ) ){
				screenshotRootPathForAndroid = System.IO.Path.Combine (sdCardPath, "Pictures/SightPlus");
			}
		}

 

 

 

 

 

2. UnityEngine下面的structure可以在子线程中调用,如Vector3, Color,说白了就是不继承UnityEngine.Object的对象。

 

3. 协程与多线程毫无关系,是多帧执行代码的方式,其他引擎也有类似的框架。原本一帧内完成的繁重工作 放到多帧里去执行,避免了卡帧的情况。贴个使用技巧:

 

<span style="white-space:pre">		</span>float lastBreakTime = Time.time;
		for (int px=0; px<rpixels.Length; px++) {
			rpixels [px] = source.GetPixelBilinear (incX * ((float)px % targetWidth), flip ? 1 - incY * ((float)Mathf.Floor (px / targetWidth)<span style="white-space:pre">			</span>) : incY * ((float)Mathf.Floor (px / targetWidth)));
			if (Time.time - lastBreakTime > 0.03f) {
				lastBreakTime = Time.time;
				yield return 0;
			}
		}

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值