4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Unityちゃん2Dのインポートのエラー解決(error CS0619)[ver.2017.2.1f1]

Posted at

#UnityにUniryちゃん2Dをインポートしたらエラーになって困った話。
ググってもUnityちゃん2Dについて触れられている物がなくて困った。
超初心者の個人的なメモ。

バージョン:2017.2.1f1
スクリーンショット 2017-12-21 10.10.40.png

スクリーンショット 2017-12-21 10.03.53.png

##エラー内容

スクリーンショット 2017-12-21 9.46.46.png

 error CS0619: `UnityEngine.Types.GetType(string, string)' is obsolete: `This was an internal method which is no longer used'

どうやら書き方が違うようだ。

修正ファイルはこれ
・SpriteAnimationClipEditor.cs
・SpriteAnimationTimeControl.cs

###解決前(SpriteAnimationClipEditor.cs)

SpriteAnimationClipEditor.cs
        protected override Editor GetBaseEditor()
        {
            Editor editor = null;
            var baseType = Types.GetType("UnityEditor.AnimationClipEditor", "UnityEditor.dll");
            CreateCachedEditor(targets, baseType, ref editor);
            return editor;
        }

怒られているのはこの部分

Types.GetType("UnityEditor.AnimationClipEditor", "UnityEditor.dll");

###解決後(SpriteAnimationClipEditor.cs)

SpriteAnimationClipEditor.cs
        protected override Editor GetBaseEditor()
        {
			string typeName = "UnityEngine.AnimationClipEditor";

            Editor editor = null;
            //var baseType = Types.GetType("UnityEditor.AnimationClipEditor", "UnityEditor.dll");
			System.Type baseType = System.Reflection.Assembly.Load("UnityEditor.dll").GetType(typeName);

            CreateCachedEditor(targets, baseType, ref editor);
            return editor;
        }

###解決前(SpriteAnimationTimeControl.cs)

SpriteAnimationTimeControl.cs
         private List<Editor> GetSpriteEditors(params Sprite[] sprites)
            {
                var type = Types.GetType("UnityEditor.SpriteInspector", "UnityEditor.dll");
                var editors = new List<Editor>();
                foreach (var sprite in sprites)
                {
                    Editor _editor = null;
                    Editor.CreateCachedEditor(sprite, type, ref _editor);
                    if (_editor != null)
                        editors.Add(_editor);
                }

                return editors;
            }

###解決後(SpriteAnimationTimeControl.cs)

SpriteAnimationTimeControl.cs
            private List<Editor> GetSpriteEditors(params Sprite[] sprites)
            {
				string typeName = "UnityEngine.SpriteInspector";

                //var type = Types.GetType("UnityEditor.SpriteInspector", "UnityEditor.dll");
				System.Type type = System.Reflection.Assembly.Load("UnityEditor.dll").GetType(typeName);
                var editors = new List<Editor>();
                foreach (var sprite in sprites)
                {
                    Editor _editor = null;
                    Editor.CreateCachedEditor(sprite, type, ref _editor);
                    if (_editor != null)
                        editors.Add(_editor);
                }

                return editors;
            }

これでとりあえず動くようになった。
おしまい。

4
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?