Unity-Android:图片错位

本文探讨了在Unity中使用ListView显示图片时遇到的错乱问题,分析了可能的原因,即Unity生成的资源ID与Android原生ID冲突导致图片加载错误。最终通过将图片放置在Assets文件夹下并采用流方式读取来解决该问题。

问题:在Android工程中,有listView简单的显示文字和图片,运行正常;在Unity中运行的时候,出现listView的图片都是错乱的,相应的图片都不对。

原因:有人说,是android打包完jar文件,生成资源id,unity打包的时候,也会生成资源id.unity生成的资源id与android的不一样了,并且覆盖了android的。

解决:查了好多资料,各种把drawable资源打包jar的都没有用。最后只能将需要的图片放到Assets下,用stream的方式读取图片,再显示了。

行 68241: 07-23 10:20:24.618672 3397 3397 W InputLog: Input event injection from sendInputEvent : pid = 3397,MotionEvent { action=ACTION_DOWN, actionButton=0, id[0]=0, x[0]=1311.5059, y[0]=2210.7686, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=661662, downTime=661662, deviceId=4, source=0x1002, displayId=0, eventId=383371642 } 行 68257: 07-23 10:20:24.620804 9378 9378 W InputLog: VRI[InputMethod] : debugInputEventStart event=MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=NO-SECURE, y[0]=NO-SECURE, pointerCount=1, eventTime=661662, downTime=661662 } 行 68323: 07-23 10:20:24.626437 9378 9378 W InputLog: VRI[InputMethod] : debugInputEventFinished event:MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=NO-SECURE, y[0]=NO-SECURE, pointerCount=1, eventTime=661662, downTime=661662 }, sEvent=DebugEvent [ type=2, action=0, downTime=661662, eventTime=661662, stateRecord=[2025-07-23 10:20:24.620|START_EVENT, 2025-07-23 10:20:24.620|ENQUEUE_EVENT|true|false, 2025-07-23 10:20:24.621|EarlyPostImeInputStage|0x0, 2025-07-23 10:20:24.621|NativePostImeInputStage|0x0, 2025-07-23 10:20:24.626|ViewPostImeInputStage|0xc, 2025-07-23 10:20:24.626|SyntheticInputStage|0xc, 2025-07-23 10:20:24.626|FINISH_EVENT|0xc], handleDetail=|Touch handled by view onTouchEvent in com.sohu.inputmethod.sogou.keyboard.KeyboardRootComponentView|mView handled=true ] 行 68913: 07-23 10:20:24.697469 3397 3397 W InputLog: Input event injection from sendInputEvent : pid = 3397,MotionEvent { action=ACTION_UP, actionButton=0, id[0]=0, x[0]=1311.5059, y[0]=2210.7686, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=661743, downTime=661662, deviceId=4, source=0x1002, displayId=0, eventId=698701059 } 行 68968: 07-23 10:20:24.698974 9378 9378 W InputLog: VRI[InputMethod] : debugInputEventStart event=MotionEvent { action=ACTION_UP, id[0]=0, x[0]=NO-SECURE, y[0]=NO-SECURE, pointerCount=1, eventTime=661743, downTime=661662 } 行 69031: 07-23 10:20:24.702492 19709 19709 W InputLog: DecorView : dispatchKeyEvent cb handled=true, KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_DEL, scanCode=0, metaState=0, flags=0x6, repeatCount=0, eventTime=661749000000, downTime=661749000000, deviceId=-1, source=0x0, displayId=-1 }, activity=androidx.appcompat.app.AppCompatDelegateImpl$AppCompatWindowCallback@e1eb472, mFeatureId=-1 行 69035: 07-23 10:20:24.702585 19709 19709 W InputLog: DecorView : dispatchKeyEvent cb handled=true, KeyEvent { action=ACTION_UP, keyCode=KEYCODE_DEL, scanCode=0, metaState=0, flags=0x6, repeatCount=0, eventTime=661750000000, downTime=661749000000, deviceId=-1, source=0x0, displayId=-1 }, activity=androidx.appcompat.app.AppCompatDelegateImpl$AppCompatWindowCallback@e1eb472, mFeatureId=-1 以上日志 为什么点击了输入法上的删除键,但是没生效呢?
07-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

延澈左

小小心意

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值