I’ve asked this in the forums but I’ve gotten no response:
I have tried everything, Arrays / Multidimensional Arrays, Jagged Arrays, Lists, Classes…
I am not getting the result I want to work in the Editor.
I have an Array of textures. However, I want to dynamically add/delete other texture arrays.
MainArray
-----TextureArray1
----------texture1
----------texture2
----------texture3
-----TextureArray2
----------texture4
----------texture5
----------texture6
----------texture7
----------texture8
----------texture9
-----TextureArray3
----------texture10
----------texture11
Then I want to access them like so
MainArray[0,2].name or MainArray[0][2].name ----> “texture2”
I want to be able to add a TextureArray# at the end of the MainArray
I want to be able to delete a TextureArray# & all texture# within the MainArray
I want to be able to add a texture# at the end of the TextureArray#
I want to be able to delete a texture# within the TextureArray#
I first got it working with a single-dimensional array with no trouble. I thought converting it to a multi-dimensional array would be easy. No. The problem is adding and deleting. I have to build a temporary array with an additional value and then copy it back to the MainArray. Not Working like it does in a single-dimensional array. I tried a List with its simple Add & Delete but couldn’t get it to work at all. As soon as I got to (Texture2D)EditorGUILayout.ObjectField it broke. It said I had too many arguments even though it worked fine with an Array.
How do I go about creating this type of system?
I’ve now started to use a List of Arrays where List calls a new class.
Of course, it still doesn’t work but I am puzzled by the error I am getting.
TextureObjects.cs
using UnityEngine;
using System.Collections;
public class TextureObjects : MonoBehaviour {
public TextureObjects(){
Texture2D[] textureObject = new Texture2D[1];
}
}
MyClass.cs
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
[System.Serializable]
public class MyClass : MonoBehaviour {
[SerializeField]
public List<TextureObjects[]> textureObjects = new List<TextureObjects[]>();
void Start(){
textureObjects.Add (new TextureObjects[1]);
}
}
MyClassEditor.cs
using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomEditor( typeof( MyClass ) )]
[System.Serializable]
public class MyClassEditor : Editor {
public override void OnInspectorGUI(){
serializedObject.Update ();
myClass.textureObjects[z] _= (Texture2D)EditorGUILayout.ObjectField ("", myClass.textureObjects[z]*, typeof(Texture2D), true, GUILayout.Width(100));*_
_*}*_
_*}*_
_*```*_
_*(Note: 'z' loops through the List)*_
_*(Note: 'i' loops through the texture array)*_
_*The error I get on the myClass.textureObjects[z] is:*_
<em>_*No overload method 'ObjectField' takes '5' arguments.*_</em>
_*However, if I just use an array, this same line for ObjectField works without errors*_