搜尋此網誌

2024年5月1日 星期三

IL_00af: call System.Int32& System.Int32[0...,0...]::Address

 打包app執行轟炸超人發現遊戲開局就crash了....


在pc上複查發現這個錯誤



最後發現是這邊出錯, int[,]在查詢數據時 address 不知道為什麼出錯了

for (int j = 0; j < map.MapConfig.ChunkH; j++){ strm += "["; for (int i = 0; i < map.MapConfig.ChunkW; i++){                 //這邊出錯
strm += matrixData[j, i] + ","; } strm += "],"; } strm += "]";


詳細錯誤如下

IL_00af: call System.Int32& System.Int32[0...,0...]::Address(System.Int32,System.Int32) at ETHotfix.AIPlayer.calcNonPath(System.Int32 depth) (at G:/OlgCase/bbm/source/Unity/Assets/Hotfix/GameGather/Bomber/AI/AIPlayer.cs:366) at ETHotfix.AIPlayer.calcPath() (at G:/OlgCase/bbm/source/Unity/Assets/Hotfix/GameGather/Bomber/AI/AIPlayer.cs:200) at ETHotfix.AIPlayer.V_Think() (at G:/OlgCase/bbm/source/Unity/Assets/Hotfix/GameGather/Bomber/AI/AIPlayer.cs:86) at ETHotfix.AIPlayer.think() (at G:/OlgCase/bbm/source/Unity/Assets/Hotfix/GameGather/Bomber/AI/AIPlayer.cs:79) at ETHotfix.AILogic.UpdateLogic() (at G:/OlgCase/bbm/source/Unity/Assets/Hotfix/GameGather/Bomber/AI/AILogic.cs:292) at ETHotfix.BaseEntity.updateAILogicAct() (at G:/OlgCase/bbm/source/Unity/Assets/Hotfix/GameGather/Bomber/Entity/BaseEntity.cs:1581)

代碼修改, 把查詢給int再使用就好了


for (int j = 0; j < map.MapConfig.ChunkH; j++){ strm += "["; for (int i = 0; i < map.MapConfig.ChunkW; i++){ num = matrixData[j, i]; strm += num + ","; } strm += "],";
以後有空再來查這個問題

2024年4月29日 星期一

ILRuntime 性能優化

在使用 ILRuntime需要注意

1) 減少使用 foreach, Dictionary, IEnumerable 的調用會產生額外 GC

2) 減少調用主工程包含enum參數的函數, 因為在調用的時候會進行值得轉型, 產生額外 GC

3) ILBinding需要執行, 否則runtime性能會差很多


升級 ILRuntime 到 2.x 版本在 1.6 版本打包Android(package Hotfix.dll by Release)跟 Editor 下的性能非常糟糕,所有的消耗都在 GC 上面,後來升級 2.x 版本就好了



從更新後重新生成 ILBinding 發現修改了 IList 改成 using AutoList,這部分應該是優化了GC回收效率

Cocos 構建 error Java executable not found at

建構資源打包到 app 後發現個問題, 遊戲啟動就黑屏, 看了日誌如下

沒看出甚麼問題重新打個包, 發現一個奇怪的錯誤, 但之前都是這樣打包也沒注意這個情況

查看了系統配置, JAVA_HOME、PATH 都是正常的, 改其他版本 Java 也沒用, 最後發現 Cocos 

這個配置是配置到 java 安裝目錄而不是 bin 目錄, 修改如下就好了


Cocos app 運行錯誤 [ERROR]: E/ ERROR: Uncaught TypeError: Error 6903, please go to.....EngineErrorMap.md#6903 to

 

打包 apk 測試遇到奇怪的問題, 

[ERROR]: E/ ERROR: Uncaught TypeError: Error 6903, please go to https://github.com/cocos-creator/engine/blob/develop/EngineErrorMap.md#6903 to see details., location: src/cocos-js/cc.js:0:0


官網說這是資源加載有問題, 測試了確定不是加載不到, 是在後續流程使用clone出錯

public static createEffect(path: any, cb: any, parent: any) {
    this.loadRes("/gamePackages/effects/" + path, Prefab, function (err: any,
        prefab: any) {
        if (err) {
            cb('err', null);
            return;
        }

        //實際是這裡出錯
        var node = instantiate(prefab);
        if (!parent) {
            parent = find("Canvas");
        }

        parent.addChild(node);
        cb(null, node);
        });
    }


測試了發現instantiate(prefab) 有問題, prefab載入的並非是prefab資源

 public static loadRes(url: string, type: any, cb: Function = () => { }) {
        resources.load(url, (err: any, res: any) => {
            if (err) {
                error(err.message || err);
                cb(err, res);
                return;
            }

            cb && cb(null, res);
        })
    }

由於 BonusTime.Prefab 跟 BonusTime.anim 原本在同一個層級目錄所造成的, resources.load 加載到的是 animation 資源


後來把 
BonusTime.anim 改名成 BonusTimeaAim.anim 結果發現 animation.on("finished" 在動畫結束後調用沒有正常調用, 查看了下 animation 配置, 估計是因為修改了命名造成



代碼裡是這樣撥放的

let ani = node.getComponent(Animation);
ani.play('bonusTime');
ani.once(Animation.EventType.FINISHED, () => {
node && node.destroy();
callback(null);
 }, this);

後來把命名改回去, 拆分到不同目錄才解決問題

2024年4月26日 星期五

Animation Image.Sprite 使用無效

 今天用了animaiton編技能效果, 上次使用已經是 2013年的時候了, 測試了下就上手, 但奇怪的是 image.sprite 的更改一直無效, 可以看到 image.sprite 上面已經紀錄了不同 frame 下的 sprite, 但 run 起來就是無效



https://forum.unity.com/threads/whats-the-difference-between-animation-and-animator.288962/


查了下發現不能用老版 animation 必須改用 animator, 因為 ugui.image 是在老版後面才出現的功能, unity 沒有回頭去更新 animation 功能, 下面我們就來新增新版本試試看



老版本跟新版本區別在創建流程不同跟添加 component 不一樣

老版本是在 GameObject 新增 Animation Component, 然後開啟 Windows -> Animation -> Animation, Create 新增 Animation Clip, 這樣就是使用 animation 運行


如果要搭配 animator, 則 GameObject 無須新增, 直接開啟 Windows -> Animation -> Animation, Create 新增 Animation Clip, 查看 unity 會新增 animation clip 跟  animation controller 兩個檔案並且 GameObject 是新增了 Animator Component, 在這個情況下去編輯 Image.Sprite 就正常






2024年4月25日 星期四

com.unity.render-pipelines.universal 版本不支持 跟場景混亂

 測試某個插件導入到項目中出現問題, 一般這個問題是因為版本不匹配造成的, 因為直接比對了兩項目的 package 將差異 "com.unity.render-pipelines.universal": "10.6.0", 加入目前項目就出現這個問題



需要查詢 com.unity.render-pipelines.universal 對應 unity 版本,  在官網的插件中選擇版本下拉清單可以查看到對應 unity 版本


隨便改成了 12.0.0 版本, 目測服務器沒有這個版本

查看 Package Manager 顯示是 not found

再切回去官網查目前最新 12.1.15, 但還是 not found


後來打開 Package Manager 查詢支持, 名字是 Universal RP, 版本 12.1.7 執行 import


import 完成後出現錯誤, 場景變紫色

Shader error in Couldn't open include file 'Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl'. at line 59


這是URP升級造成的, 生成一個URP Asset如下

開啟 Player Settingg -> Graphics, 將 URP Asset 拖拉近來, 再回到場景就好了






參考:

https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@12.1/manual/index.html


https://blog.csdn.net/q764424567/article/details/133927994

2024年4月24日 星期三

5212 凌網 漲停

5 快到520總統就職日子了, 4月底最近的股票是起起落落, 當然也有美國不降息造成的資金回攏問題, 資金回攏亞幣暴跌, 美元兌換台幣來到歷史新高, 本來去年提前把美元定存贖回換台幣就是為了亞幣上漲再換美元的, 結果事實跟預料果然有出入....


今天買的股票 5212 凌網 漲停了, 新聞也沒看到甚麼消息, 不過從成交量來看總感覺是有人在洗盤面, 如果沒有更好的基礎面因素, 估計後續營利到10-20%也可以賣掉了