Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

415
Visualizações
how to configurate nested object in Unity's inspector

I tried to create nested object in C# script in Unity and change the values in it.

Class of nested object

using UnityEngine;

public class Replica : ScriptableObject
{
    public string Text;
    public int Speed = 1;
    public int PersonaID = 0;
}

Class with nested object

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

[CreateAssetMenu(fileName = "Data", menuName = "ScriptableObjects/DialogContainer", order = 1)]
public class DialogContainer : ScriptableObject {
    public Replica[] Replicas; // Here is nested object
    public Sprite[] Avatars;
}

And when I created the ScriptableObject I saw that: Photo of ScriptableObject interface

Here I can only put an instance of the class there, but I cannot configure it.

But i want to change values right in inspector without creating and inserting object of class "Replica" like in InputManager where I can create one more obj in axis, open it and change values in inspector like that. Photo of interface I want to see

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

If u want configurate your class in inspector, that class must be not derived from MonoBehaviour or ScriptableObject and be with tag [System.Serializable] than u can serialize it in nested class without creating instance.

Replica:

[System.Serializable]
public class Replica
{
    public string Text;
    public int Speed = 1;
    public int PersonaID = 0;
}

Dialog Container:

using System.Collections.Generic;
using UnityEngine;

public class DialogContainer : MonoBehaviour{
    public List<Replica> Replicas;
    public Sprite[] Avatars;
}

Than I saw that:Inspector screenshot

over 4 years ago · Santiago Trujillo Relatório

0

Unless you make a custom editor for DialogContainer, you can't do what you want to do. If you have a parent ScriptableObject that contains a child list of ScriptableObjects, you can't edit each child's fields when you have the parent selected in your Project View.

You will have to edit each child Replica by selecting the Replica instance in the Project View. Then the Inspector will let you edit that Replica.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda