Skip to main content
Cleanup
Source Link
DMGregory
  • 141k
  • 23
  • 258
  • 401

The proper way How to save and instantiate game data containing lists of polymorphic types

Let's say iI have a class named Entity such as:

class Entity
{
  public string name;
  public List<Behavior> behaviors;
  // other stuff...
}

I want to create an editor window that allow game designers to create "instances" of that class by giving the name and a set of Behavior, which are premade classes by devs. What

What I need is a file format to save what the proper way (or one of them)game designers have input in the editor window when they click on "save", like json, to use that data later in the runtime of the game. But, of course, you can't save a list of polymorphic classes instances with json, so I'm looking for alternatives.

How can I save what GDsdesigners create and useload/instantiate/use it during runtime?

At first, I was thinking of creating prefabs, but:

  • prefabutility.createprefab is tagged as Obsolete in the docdocs
  • I don't know if it's a good solution in term of memory, maintainability, scalability, ...

The proper way to save and instantiate game data

Let's say i have a class named Entity such as:

class Entity
{
  public string name;
  public List<Behavior> behaviors;
  // other stuff...
}

I want to create an editor window that allow game designers to create "instances" of that class by giving the name and a set of Behavior, which are premade classes by devs. What is the proper way (or one of them) to save what GDs create and use it during runtime?

At first, I was thinking of creating prefabs, but:

  • prefabutility.createprefab is tagged as Obsolete in the doc
  • I don't know if it's a good solution in term of memory, maintainability, scalability, ...

How to save and instantiate game data containing lists of polymorphic types

Let's say I have a class named Entity such as:

class Entity
{
  public string name;
  public List<Behavior> behaviors;
  // other stuff...
}

I want to create an editor window that allow game designers to create "instances" of that class by giving the name and a set of Behavior, which are premade classes by devs.

What I need is a file format to save what the game designers have input in the editor window when they click on "save", like json, to use that data later in the runtime of the game. But, of course, you can't save a list of polymorphic classes instances with json, so I'm looking for alternatives.

How can I save what designers create and load/instantiate/use it during runtime?

At first, I was thinking of creating prefabs, but:

  • prefabutility.createprefab is tagged as Obsolete in the docs
  • I don't know if it's a good solution in term of memory, maintainability, scalability, ...
deleted 6 characters in body
Source Link

Let's say i have a class named `Entity` such as: ``` class Entity { public string name; public List behaviors; // other stuff... } ```

Let's say i have a class named Entity such as:

I want to create an editor window that allow game designers to create "*instances*" of that class by giving the name and a set of `Behavior`, which are premade classes by devs.
class Entity
{
  public string name;
  public List<Behavior> behaviors;
  // other stuff...
}
What is the proper way (or one of them) to save what GDs create and use it during runtime?

I want to create an editor window that allow game designers to create "instances" of that class by giving the name and a set of Behavior, which are premade classes by devs. What is the proper way (or one of them) to save what GDs create and use it during runtime?

At first, I was thinking of creating prefabs, but:

  • prefabutility.createprefab is tagged as Obsolete in the doc
  • I don't know if it's a good solution in term of memory, maintainability, scalability, ...

Let's say i have a class named `Entity` such as: ``` class Entity { public string name; public List behaviors; // other stuff... } ``` I want to create an editor window that allow game designers to create "*instances*" of that class by giving the name and a set of `Behavior`, which are premade classes by devs. What is the proper way (or one of them) to save what GDs create and use it during runtime?

At first, I was thinking of creating prefabs, but:

  • prefabutility.createprefab is tagged as Obsolete in the doc
  • I don't know if it's a good solution in term of memory, maintainability, scalability, ...

Let's say i have a class named Entity such as:

class Entity
{
  public string name;
  public List<Behavior> behaviors;
  // other stuff...
}

I want to create an editor window that allow game designers to create "instances" of that class by giving the name and a set of Behavior, which are premade classes by devs. What is the proper way (or one of them) to save what GDs create and use it during runtime?

At first, I was thinking of creating prefabs, but:

  • prefabutility.createprefab is tagged as Obsolete in the doc
  • I don't know if it's a good solution in term of memory, maintainability, scalability, ...
added 6 characters in body
Source Link

Let's say i have a class named Entity such as:

 
class Entity
{
  public string name;
  public List<Behavior> behaviors;
  // other stuff...
}
Let's say i have a class named `Entity` such as:

I want to create an editor window that allow game designers to create "instances" of that class by giving the name and a set of Behavior, which are premade classes by devs. What is the proper way (or one of them) to save what GDs create and use it during runtime?

``` class Entity { public string name; public List behaviors; // other stuff... } ``` I want to create an editor window that allow game designers to create "*instances*" of that class by giving the name and a set of `Behavior`, which are premade classes by devs. What is the proper way (or one of them) to save what GDs create and use it during runtime?

At first, I was thinking of creating prefabs, but:

  • prefabutility.createprefab is tagged as Obsolete in the doc
  • I don't know if it's a good solution in term of memory, maintainability, scalability, ...

Let's say i have a class named Entity such as:

class Entity
{
  public string name;
  public List<Behavior> behaviors;
  // other stuff...
}

I want to create an editor window that allow game designers to create "instances" of that class by giving the name and a set of Behavior, which are premade classes by devs. What is the proper way (or one of them) to save what GDs create and use it during runtime?

At first, I was thinking of creating prefabs, but:

  • prefabutility.createprefab is tagged as Obsolete in the doc
  • I don't know if it's a good solution in term of memory, maintainability, scalability, ...
 
Let's say i have a class named `Entity` such as: ``` class Entity { public string name; public List behaviors; // other stuff... } ``` I want to create an editor window that allow game designers to create "*instances*" of that class by giving the name and a set of `Behavior`, which are premade classes by devs. What is the proper way (or one of them) to save what GDs create and use it during runtime?

At first, I was thinking of creating prefabs, but:

  • prefabutility.createprefab is tagged as Obsolete in the doc
  • I don't know if it's a good solution in term of memory, maintainability, scalability, ...
Source Link
Loading