Hey Everyone!
To start off, i’m kinda new to serializedobjects and properties.
I´ve got this weird problem where i want to get an array from a GUI. The syntax is as following in the GUI script.
#pragma strict
import App;
var apps : App[];
Then when I try to access that array of Apps using the following code:
class GUIEditor extends Editor {
//Apps
var apps : SerializedProperty;
function OnEnable () {
// Setup the SerializedProperties
Debug.Log(serializedObject.FindProperty("apps"));
apps = serializedObject.FindProperty("apps");
}
}
As soon as i try to print out the value of apps using Debug.Log(), Null gets returned, even-though the variable exists.
You guys have any idea on why it does that and how to fix it?
EDIT:
Code for the class App.cs
using UnityEngine;
using System.Collections;
public class App {
private string app_name = "undifined";
private Texture2D icon;
private Texture2D background;
private bool show = false;
public App() {
}
public bool Show {
get { return show; }
set { show = value;}
}
public string Name {
get { return app_name; }
set { app_name = value; }
}
public Texture2D Icon {
get { return icon; }
set { icon = value; }
}
public Texture2D Background {
get { return background; }
set { background = value; }
}
}
What is App? is it a type that can be serialized by Unity? Without your custom editor, does the apps array show up in the inspector? If not App is probably not serializable.
– Bunny83App is a custom class. When I display the apps array in the inspector it does work, but i want to do things a little bit easier for other people, hence the custom editor
– LesPaul