unity2d导入psb文件注意事项

一、前言

导入psb多个图层是方便制作2d骨骼动画

二、设置psb文件锚点

导入psb文件的时候默认的锚点一般都不是我们想要的位置,人物朝左、朝右旋转的时候会出现人物移动很多位置,可以手动设置锚点到我们需要的位置。
unity2d导入psb文件注意事项_第1张图片

三、unity导入psb文件报错

今天开始我的unity导入psb文件就一直报这个错,之前都没问题,重新unity和重启电脑都没用
吐槽

很难在百度找到答案?所以大家是怎样找答案的?求指导。。。

NullReferenceException: Max Size: SerializedProperty is null

3.1 错误信息

NullReferenceException: Max Size: SerializedProperty is null
UnityEditor.EditorGUI.BeginPropertyInternal (UnityEngine.Rect totalPosition, UnityEngine.GUIContent label, UnityEditor.SerializedProperty property) (at <0d6ce211ebbc47e1a35a84c3672ff58f>:0)
UnityEditor.EditorGUI.BeginProperty (UnityEngine.Rect totalPosition, UnityEngine.GUIContent label, UnityEditor.SerializedProperty property) (at <0d6ce211ebbc47e1a35a84c3672ff58f>:0)
UnityEditor.Modules.DefaultTextureImportSettingsExtension.ShowImportSettings (UnityEditor.BaseTextureImportPlatformSettings editor) (at <0d6ce211ebbc47e1a35a84c3672ff58f>:0)
UnityEditor.BaseTextureImportPlatformSettings.ShowPlatformSpecificSettings (System.Collections.Generic.List`1[T] platformSettings, System.Int32 selected) (at <0d6ce211ebbc47e1a35a84c3672ff58f>:0)
UnityEditor.U2D.Common.TexturePlatformSettingsHelper.ShowPlatformSpecificSettings () (at Library/PackageCache/[email protected]/Editor/InternalBridge/TexturePlatformSettings/TexturePlatformSettings.cs:158)
UnityEditor.U2D.PSD.PSDImporterEditor.DoPlatformSettings () (at Library/PackageCache/[email protected]/Editor/PSDImporterEditor.cs:419)
UnityEditor.U2D.PSD.PSDImporterEditor.DoSettingsUI () (at Library/PackageCache/[email protected]/Editor/PSDImporterEditor.cs:274)
UnityEditor.U2D.PSD.PSDImporterEditor.OnInspectorGUI () (at Library/PackageCache/[email protected]/Editor/PSDImporterEditor.cs:232)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.b__0 () (at <122642d41668428d845063b1753c4e72>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

3.2 解决办法

在你的unity项目的任意一个位置创建一个名为的 C# 脚本FixPSDImporter并将其粘贴到其中并修复!

public static class FixPSDImporter
    {
        [UnityEditor.InitializeOnLoadMethod]
        public static void ResetPSDImporterFoldout()
        {
            UnityEditor.EditorPrefs.DeleteKey("PSDImporterEditor.m_PlatformSettingsFoldout");
        }
    }

3.3 后续

嗯,我发现在一个项目创建了这个文件,其他的项目也没报错了,很完美。

你可能感兴趣的:(unity,unity,c#,游戏引擎)