【ハルシオンブログ】新しく作ったクラスのオブジェクトがInspectorに表示されないときは、Serializeアトリビュートをつけましょう!
こんにちは。坂内っす。
めっちゃいい天気で散歩に出たい感じっすね。
今頃の天候が一年で一番気持ちいいのでは?気温もイイ感じです。
新しく作ったクラスがInspectorに表示されないとかってことありませんか?
[Blog0419.cs]
こんなコードの場合は、Inspectorはこんな感じ。

public TestClass0419 testClass;
パブリックにしてるのにクラスの中身がInspectorででないよー!
そんな時はこうすれば出ますよ。
[Blog0419.cs]
作ったクラスに[System.Serializable]を追加します。

これでTestClass0419のオブジェクトの中身がInspectorに出るようになります。
ということで、素敵なInspectorライフを!
あでゅ~ノシ
めっちゃいい天気で散歩に出たい感じっすね。
今頃の天候が一年で一番気持ちいいのでは?気温もイイ感じです。
新しく作ったクラスがInspectorに表示されないとかってことありませんか?
[Blog0419.cs]
using UnityEngine;
public class Blog0419 : MonoBehaviour
{
public class TestClass0419 {
public int testClassInt;
public float testClassFloat;
}
public int testInt;
public TestClass0419 testClass;
}
こんなコードの場合は、Inspectorはこんな感じ。

public TestClass0419 testClass;
パブリックにしてるのにクラスの中身がInspectorででないよー!
そんな時はこうすれば出ますよ。
[Blog0419.cs]
using UnityEngine;
public class Blog0419 : MonoBehaviour
{
[System.Serializable]
public class TestClass0419 {
public int testClassInt;
public float testClassFloat;
}
public int testInt;
public TestClass0419 testClass;
}
作ったクラスに[System.Serializable]を追加します。

これでTestClass0419のオブジェクトの中身がInspectorに出るようになります。
ということで、素敵なInspectorライフを!
あでゅ~ノシ
Category: 開発日記(Unity)
« 【ハルシオンブログ】UnityEditorのちょっとしたショートカット紹介 | 【ハルシオンブログ】C#8でswitchが短く書けますね。 »
コメント
| h o m e |