- Home /
Array variables structure question
Hi, I'm currently designing a system for a custom editor in unity. It's mostly about making all kinds of modular scripts you can click in and out, but I'm running into a problem with one of my module's structure.
This module is a script that let's developers add Actions to. These Actions can have lots of different effects, like moving an object or sending a message or instantiating something. And these effects have their own set of variables accordingly, like the Send Message Action will have a string field that contains the actual message and a gameobject field that the target can be put in. However I'm not sure how to set something like this up. I've tried a few methods, but I'm looking for a method more optimized, cleaner and efficient. If anyone has any ideas, please share.
These are the methods I've tried so far: 1: Keep arrays individually for every variable. This makes the code cluttered because and stores too much stuff in memory, I think. Also most of the information isn't even used this way, because for every Action ALL possible variables will be stored even though not even a half will be used.
2: Parse all info to an array of string arrays. I've written a lengthy piece of code that parses all info: strings, int, floats, bools and vector3, in and out of a certain string. This works pretty well but it does use an entire array of strings with a lot characters which doesn't sound like it's optimized very well.
If anyone has any ideas, please share.
Answer by TurboHermit · Jan 14, 2014 at 04:48 PM
Just read about Serialization. Went for a List of custom serialized Classes.
Your answer
![](https://koobas.hobune.stream/wayback/20220613130106im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Why can't i use these arrays to access positions and objects properties? Please help! 3 Answers
Create new variable name based on array index 3 Answers
Variable values not available or they lost their value 1 Answer
Accessing a variable... return incorrect value. 1 Answer
How to check for the same variable in multiple scripts (inside an array) ? 0 Answers