Question by
eladiozro · Sep 01, 2021 at 06:36 AM ·
editorlistscriptable objectstoring
List equals instance in editor but isn't intended
So I am storing a list of values in an scriptable object.
public class ExampleScriptableObject : ScriptableObject
{
public List<Example> targetProgram = new List<Example>();
}
I am grabing the values from a list of components in the Editor.
[ExecuteInEditMode]
public class ExampleComponent : MonoBehaviour
{
public List<Example> gameObjectComponentExample = new List<Example>();
public int somemorevalues;
}
And when I try to do "save" the properties into the list inside the scriptable object running in the Editor
foreach (ExampleComponent comp in componentsList)
{
exampleScriptable.targetProgram .Add(comp.exampleProperties);
}
This equals is making an instance which copy every attribute in real time, and what I want is to store the values that are currently in that moment. Everything changes in real time from both sides, I need to just copy their values how they look like in the moment.
Comment
Your answer
Follow this Question
Related Questions
Custom Inspector for a list of custom class members. 2 Answers
Load JSON Scriptable Object and Prefabs 1 Answer
Preventing an array from clearing when playing game. 2 Answers
Define attacks to choose from 1 Answer
Mouse graphic glitch in Game tab 2 Answers