Populate Scriptable Objects Automatically
up vote
0
down vote
favorite
A few of my Scriptable Objects(used for seeding my initial game data) contain large 2 dimensional arrays (like 10x10), the data of which i am generating with an external Python script. I do use the Odin inspector plugin as well, to serialize the 2d array for me and provide me with a nice representation of that array inside the Unity editor.
I am simply doing it like this :
[TableMatrix()]
public int[,] table = new int[10, 10];
and this is just an Odin SerializedScriptableObject class.
The problem is, I really want to avoid having to add the 10x10 elements by hand using the Unity editor and also I want my objects to have variable 2d array sizes, one could beb (10,10), another could be (5,5). Is there a way to populate my scriptable objects programmatically to achieve that ? (Or does the Odin inspector plugin support something like that if anyone knows ?)
Thanks !
c# unity3d
This question has an open bounty worth +50
reputation from Spyros ending in 4 days.
This question has not received enough attention.
add a comment |
up vote
0
down vote
favorite
A few of my Scriptable Objects(used for seeding my initial game data) contain large 2 dimensional arrays (like 10x10), the data of which i am generating with an external Python script. I do use the Odin inspector plugin as well, to serialize the 2d array for me and provide me with a nice representation of that array inside the Unity editor.
I am simply doing it like this :
[TableMatrix()]
public int[,] table = new int[10, 10];
and this is just an Odin SerializedScriptableObject class.
The problem is, I really want to avoid having to add the 10x10 elements by hand using the Unity editor and also I want my objects to have variable 2d array sizes, one could beb (10,10), another could be (5,5). Is there a way to populate my scriptable objects programmatically to achieve that ? (Or does the Odin inspector plugin support something like that if anyone knows ?)
Thanks !
c# unity3d
This question has an open bounty worth +50
reputation from Spyros ending in 4 days.
This question has not received enough attention.
You're using jagged array, what happens if you make the matrix like [ ][ ] instead of the jagged array? If you are okay to avoid jagged arrays I can offer a solution :D
– Lotan
2 days ago
Hi @Lotan, please do, the way the array is initialized doesn't matter. I can definitely work around that. What I am mostly concerned with is being able to have a variable size array on each of my scriptable objects and be able to populate them programmatically.
– Spyros
2 days ago
1
@Lotan It's the other way around, a jagged array is an arrays of arrays. The OP is using a multidimensional array (specifically a 2D array)
– Ghost4Man
yesterday
@Ghost4Man that's the way I think will work, but I don't have unity these days to test it :(
– Lotan
yesterday
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
A few of my Scriptable Objects(used for seeding my initial game data) contain large 2 dimensional arrays (like 10x10), the data of which i am generating with an external Python script. I do use the Odin inspector plugin as well, to serialize the 2d array for me and provide me with a nice representation of that array inside the Unity editor.
I am simply doing it like this :
[TableMatrix()]
public int[,] table = new int[10, 10];
and this is just an Odin SerializedScriptableObject class.
The problem is, I really want to avoid having to add the 10x10 elements by hand using the Unity editor and also I want my objects to have variable 2d array sizes, one could beb (10,10), another could be (5,5). Is there a way to populate my scriptable objects programmatically to achieve that ? (Or does the Odin inspector plugin support something like that if anyone knows ?)
Thanks !
c# unity3d
A few of my Scriptable Objects(used for seeding my initial game data) contain large 2 dimensional arrays (like 10x10), the data of which i am generating with an external Python script. I do use the Odin inspector plugin as well, to serialize the 2d array for me and provide me with a nice representation of that array inside the Unity editor.
I am simply doing it like this :
[TableMatrix()]
public int[,] table = new int[10, 10];
and this is just an Odin SerializedScriptableObject class.
The problem is, I really want to avoid having to add the 10x10 elements by hand using the Unity editor and also I want my objects to have variable 2d array sizes, one could beb (10,10), another could be (5,5). Is there a way to populate my scriptable objects programmatically to achieve that ? (Or does the Odin inspector plugin support something like that if anyone knows ?)
Thanks !
c# unity3d
c# unity3d
edited Nov 19 at 13:46
Julxzs
361213
361213
asked Nov 10 at 9:38
Spyros
23.2k1970110
23.2k1970110
This question has an open bounty worth +50
reputation from Spyros ending in 4 days.
This question has not received enough attention.
This question has an open bounty worth +50
reputation from Spyros ending in 4 days.
This question has not received enough attention.
You're using jagged array, what happens if you make the matrix like [ ][ ] instead of the jagged array? If you are okay to avoid jagged arrays I can offer a solution :D
– Lotan
2 days ago
Hi @Lotan, please do, the way the array is initialized doesn't matter. I can definitely work around that. What I am mostly concerned with is being able to have a variable size array on each of my scriptable objects and be able to populate them programmatically.
– Spyros
2 days ago
1
@Lotan It's the other way around, a jagged array is an arrays of arrays. The OP is using a multidimensional array (specifically a 2D array)
– Ghost4Man
yesterday
@Ghost4Man that's the way I think will work, but I don't have unity these days to test it :(
– Lotan
yesterday
add a comment |
You're using jagged array, what happens if you make the matrix like [ ][ ] instead of the jagged array? If you are okay to avoid jagged arrays I can offer a solution :D
– Lotan
2 days ago
Hi @Lotan, please do, the way the array is initialized doesn't matter. I can definitely work around that. What I am mostly concerned with is being able to have a variable size array on each of my scriptable objects and be able to populate them programmatically.
– Spyros
2 days ago
1
@Lotan It's the other way around, a jagged array is an arrays of arrays. The OP is using a multidimensional array (specifically a 2D array)
– Ghost4Man
yesterday
@Ghost4Man that's the way I think will work, but I don't have unity these days to test it :(
– Lotan
yesterday
You're using jagged array, what happens if you make the matrix like [ ][ ] instead of the jagged array? If you are okay to avoid jagged arrays I can offer a solution :D
– Lotan
2 days ago
You're using jagged array, what happens if you make the matrix like [ ][ ] instead of the jagged array? If you are okay to avoid jagged arrays I can offer a solution :D
– Lotan
2 days ago
Hi @Lotan, please do, the way the array is initialized doesn't matter. I can definitely work around that. What I am mostly concerned with is being able to have a variable size array on each of my scriptable objects and be able to populate them programmatically.
– Spyros
2 days ago
Hi @Lotan, please do, the way the array is initialized doesn't matter. I can definitely work around that. What I am mostly concerned with is being able to have a variable size array on each of my scriptable objects and be able to populate them programmatically.
– Spyros
2 days ago
1
1
@Lotan It's the other way around, a jagged array is an arrays of arrays. The OP is using a multidimensional array (specifically a 2D array)
– Ghost4Man
yesterday
@Lotan It's the other way around, a jagged array is an arrays of arrays. The OP is using a multidimensional array (specifically a 2D array)
– Ghost4Man
yesterday
@Ghost4Man that's the way I think will work, but I don't have unity these days to test it :(
– Lotan
yesterday
@Ghost4Man that's the way I think will work, but I don't have unity these days to test it :(
– Lotan
yesterday
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
To change an individual value, you can do table[x,y] = (your value)
. Lets say you want to fill every value with the number one, you could do:
for (int y = 0; y < 10; y++)
{
for (int x = 0; x < 10; x++)
{
table[x, y] = 1;
}
}
Hope that answers your question and sorry if the code is wrong - I don't have access to Unity at the moment, so you may need to fiddle around with it.
The problem is that scriptable objects would require me to preset the array to be 10x10 elements, while my game data to be seeded contain 5x5, 10x10 or other size arrays. It's basically variable.
– Spyros
Nov 19 at 13:26
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
To change an individual value, you can do table[x,y] = (your value)
. Lets say you want to fill every value with the number one, you could do:
for (int y = 0; y < 10; y++)
{
for (int x = 0; x < 10; x++)
{
table[x, y] = 1;
}
}
Hope that answers your question and sorry if the code is wrong - I don't have access to Unity at the moment, so you may need to fiddle around with it.
The problem is that scriptable objects would require me to preset the array to be 10x10 elements, while my game data to be seeded contain 5x5, 10x10 or other size arrays. It's basically variable.
– Spyros
Nov 19 at 13:26
add a comment |
up vote
0
down vote
To change an individual value, you can do table[x,y] = (your value)
. Lets say you want to fill every value with the number one, you could do:
for (int y = 0; y < 10; y++)
{
for (int x = 0; x < 10; x++)
{
table[x, y] = 1;
}
}
Hope that answers your question and sorry if the code is wrong - I don't have access to Unity at the moment, so you may need to fiddle around with it.
The problem is that scriptable objects would require me to preset the array to be 10x10 elements, while my game data to be seeded contain 5x5, 10x10 or other size arrays. It's basically variable.
– Spyros
Nov 19 at 13:26
add a comment |
up vote
0
down vote
up vote
0
down vote
To change an individual value, you can do table[x,y] = (your value)
. Lets say you want to fill every value with the number one, you could do:
for (int y = 0; y < 10; y++)
{
for (int x = 0; x < 10; x++)
{
table[x, y] = 1;
}
}
Hope that answers your question and sorry if the code is wrong - I don't have access to Unity at the moment, so you may need to fiddle around with it.
To change an individual value, you can do table[x,y] = (your value)
. Lets say you want to fill every value with the number one, you could do:
for (int y = 0; y < 10; y++)
{
for (int x = 0; x < 10; x++)
{
table[x, y] = 1;
}
}
Hope that answers your question and sorry if the code is wrong - I don't have access to Unity at the moment, so you may need to fiddle around with it.
edited Nov 19 at 14:49
Julxzs
361213
361213
answered Nov 19 at 13:02
D Manokhin
586118
586118
The problem is that scriptable objects would require me to preset the array to be 10x10 elements, while my game data to be seeded contain 5x5, 10x10 or other size arrays. It's basically variable.
– Spyros
Nov 19 at 13:26
add a comment |
The problem is that scriptable objects would require me to preset the array to be 10x10 elements, while my game data to be seeded contain 5x5, 10x10 or other size arrays. It's basically variable.
– Spyros
Nov 19 at 13:26
The problem is that scriptable objects would require me to preset the array to be 10x10 elements, while my game data to be seeded contain 5x5, 10x10 or other size arrays. It's basically variable.
– Spyros
Nov 19 at 13:26
The problem is that scriptable objects would require me to preset the array to be 10x10 elements, while my game data to be seeded contain 5x5, 10x10 or other size arrays. It's basically variable.
– Spyros
Nov 19 at 13:26
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53237680%2fpopulate-scriptable-objects-automatically%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You're using jagged array, what happens if you make the matrix like [ ][ ] instead of the jagged array? If you are okay to avoid jagged arrays I can offer a solution :D
– Lotan
2 days ago
Hi @Lotan, please do, the way the array is initialized doesn't matter. I can definitely work around that. What I am mostly concerned with is being able to have a variable size array on each of my scriptable objects and be able to populate them programmatically.
– Spyros
2 days ago
1
@Lotan It's the other way around, a jagged array is an arrays of arrays. The OP is using a multidimensional array (specifically a 2D array)
– Ghost4Man
yesterday
@Ghost4Man that's the way I think will work, but I don't have unity these days to test it :(
– Lotan
yesterday