Unity 2017.4 升級 2018.3


環境

  • Unity 2017.4.2f2
  • Unity 2018.3.0b3
  • macOS 10.13.6

功能介紹

主要功能 Preview of 2018.3 features - Unity Forum

粒子系統升級 Particle System Improvements - Google 文檔

升級文檔

官方升級文檔草案 DRAFT Upgrade Guide 2018.3 - Google 文檔

文件

版本

版本文件 ProjectSettings/ProjectVersion.txt

Packages

1
2
3
4
5
The Unity Package Manager now uses the "Packages" sub-folder of the project to persist package configuration and future package management-related features.

The project manifest ("manifest.json") from the "UnityPackageManager" folder was moved to the "Packages" folder.

You can safely delete the "UnityPackageManager" folder if it is no longer needed, and update your source control configuration accordingly.

Packages 結構發生變化。

插件

刪除過期失效且不更新的插件。

編譯

導入過程中產生大量錯誤、警告與信息,按照錯誤、警告、信息依次處理。

編譯錯誤

發現新版本存在 Bug:修改 Editor 目錄下腳本並不會顯示非 Editor 目錄下腳本的編譯錯誤,只有手動重新 Reimport 普通腳本觸發編譯錯誤才可以正確報錯。


1
2
3
Cannot access protected member `UnityEngine.RuntimeAnimatorController.RuntimeAnimatorController()' via a qualifier of type `UnityEngine.RuntimeAnimatorController'. The qualifier must be of type `ChapterAnimItem' or derived from it

error CS1540

去除初始化 new RuntimeAnimatorController() 調用。


1
2
3
`TextureCompressionQuality' is an ambiguous reference between `UnityEngine.TextureCompressionQuality' and `UnityEditor.TextureCompressionQuality'

error CS0104

直接引用 UnityEditor 命名空間:using TextureCompressionQuality = UnityEditor.TextureCompressionQuality;


1
2
3
Component could not be loaded when loading game object. Cleaning up!

Object GameObject (named 'XXXXXX') has multiple entries of the same Object component. Removing it!

原有粒子特效 Prefab 中存在着廢棄的粒子組件:

  • EllipsoidParticleEmitter (Deprecated)
  • ParticleAnimator(Deprecated)
  • ParticleRenderer(Deprecated)

以上粒子相關組件在 2018.1 標記為已廢棄,在 2018.3 中被完全被移除。

編譯警告

1
2
3
warning CS0618: `UnityEngine.Object.DestroyObject(UnityEngine.Object)' is obsolete: `use Object.Destroy instead.'
warning CS0618: `UnityEngine.TouchScreenKeyboard.done' is obsolete: `Property done is deprecated, use status instead'
warning CS0618: `UnityEngine.TouchScreenKeyboard.wasCanceled' is obsolete: `Property wasCanceled is deprecated, use status instead.'

修正過期 API

API 變化

Prefab 相關 API

由於 2018.3 支持嵌套 Prefab,因此 API 發生較大變化,需要額外處理

API 對應升級列表

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
PrefabUtility.GetPrefabParent
PrefabUtility.GetCorrespondingObjectFromSource

PrefabUtility.ReplacePrefab
PrefabUtility.SavePrefabAsset

PrefabUtility.CreatePrefab
PrefabUtility.SaveAsPrefabAsset

PrefabUtility.GetPrefabType
PrefabUtility.GetPrefabAssetType
PrefabUtility.GetPrefabInstanceStatus

PrefabUtility.FindPrefabRoot
Use GetOutermostPrefabInstanceRoot if source is a Prefab instance or source.transform.root.gameObject if source is a Prefab Asset object.

BuildPipeline.BuildPlayer 返回值

1
2
3
Cannot implicitly convert type `UnityEditor.Build.Reporting.BuildReport' to `string'

error CS0029

BuildPipeline.BuildPlayer 的返回值由 string 改為 BuildReport,根據需要取其中的字段使用即可。

運行時

1
Particle System is trying to spawn on a mesh with zero surface area

Fading in an entire particle system - Unity Forum

It means your mesh has zero surface area and you are not using vertex placement mode. Does your mesh have any triangles? Surface area is the total surface area of all triangles on your mesh. Either switch to vertex mode or add some triangles.

實際原因是因為 ParticleSystem 中 ShapeModule 要求引用的 Mesh 必須開啟 Read/Write 選項。

1
Mesh DLoadingPage_CameraFlashBase requires Read/Write Enabled to be set in the importer to work on the particle system shape module

Particle System 升級后需要啟用 Mesh 的 Read/Write Enabled 開關,需要編寫腳本處理這種情況。

注意:需要關閉 AssetPostprocessor 中的禁用 Read/Write 代碼。

增加查找出問題特效腳本:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;

public static class MeshToolForParticle
{
    [MenuItem("Tools/ParticleSystem/FindScenes", false, 20)]
    public static void FindScenes()
    {
        var guids = AssetDatabase.FindAssets("t:Scene");

        foreach (var guid in guids)
        {
            string path = AssetDatabase.GUIDToAssetPath(guid);
            var scene = EditorSceneManager.OpenScene(path, OpenSceneMode.Single);
            var roots = scene.GetRootGameObjects();
            bool found = false;
            foreach (var go in roots)
            {
                found |= Find(go);
            }

            if (found)
            {
                Debug.Log(path);
            }
        }
    }

    [MenuItem("Tools/ParticleSystem/FindPrefabs", false, 20)]
    public static void FindPrefabs()
    {
        var guids = AssetDatabase.FindAssets("t:Prefab");

        foreach (var guid in guids)
        {
            string path = AssetDatabase.GUIDToAssetPath(guid);
            var prefab = AssetDatabase.LoadAssetAtPath<GameObject>(path);
            Find(prefab);
        }
    }

    private static bool Find(GameObject go)
    {
        bool found = false;
        var particles = go.GetComponentsInChildren<ParticleSystem>(true);
        foreach (var particle in particles)
        {
            if (particle.shape.enabled && particle.shape.shapeType == ParticleSystemShapeType.Mesh &&
                particle.shape.meshShapeType != ParticleSystemMeshShapeType.Vertex)
            {
                string prefabPath = PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(particle);
                Debug.LogWarning(string.Format("Path: {0}\nPrefab: {1}", particle.gameObject.GetGameObjectPath(), prefabPath));
                found = true;
            }
        }

        return found;
    }
}

構建

Android

1
2
Failed getting available Android API levels. Make sure your android sdk tools version is 25 or higher and you have internet connection.
UnityEditor.Android.<StartGettingReleasedAPILevels>c__AnonStorey0:<>m__0() (at ?)

構建時報錯,按照提示,直接點擊 Update 按鈕升級 Android SDK 即可。

iOS

iOS 構建完成后報告鏈接錯誤,仔細檢查后發現鏈接庫被 Git LFS 管理,在檢出時並未被還原為二進制文件,而是保留文本指針內容。

執行 git lfs checkout 命令修正此問題。

新版本優化

Unity 2018.3 中終於把 meta 文件中無用的

1
2
timeCreated: 1523361353
licenseType: Pro

兩個字段刪除了,實際上 timeCreated 並不是指資源創建的時間,而是資源修改的時間。

TODO

1
2
3
NullReferenceException: Object reference not set to an instance of an object

SuperTextMesh.OnValidate () (at Assets/Plugins/Clavian/SuperTextMesh/Scripts/SuperTextMesh.cs:1012)

SuperTextMesh 需要升級


1
2
ExecuteAlways
ExecuteInEditMode

兩個屬性有變化,需要更新


1
2
3
HasCoreStatsInBuild is only valid when called while building the player!

UnityEditor.BuildPipeline:BuildAssetBundles(String, BuildAssetBundleOptions, BuildTarget) (at ?)

構建 AssetBundle 時有錯誤,不確定是由什么引起的


1
2
3
4
5
Your multi-scene setup may be improved by tending to the following issues:
Multiple scenes baked with Auto enabled can appear differently in Play mode when reloading them. Consider disabling Auto and rebaking.

Your current multi-scene setup has inconsistent Lighting settings which may lead to different lighting when loading scenes individually or in a different order! Consider homogenizing the following:
1/2 scenes have Auto baking enabled.

統一所有場景的光照設置


1
`UnityEditor.AndroidBuildSystem.Internal' is obsolete: `Internal build system is deprecated. Please use Gradle instead'

需要轉換項目到 Gradle


1
warning CS0618: `UnityEngine.WWW' is obsolete: `Use UnityWebRequest, a fully featured replacement which is more efficient and has additional features'

暫時禁用 WWW 過期警告,需要升級到新版本 API。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM