In this gorgeous attempt, a picture shall be included in a js-script instead of placing it as a 2nd file in the script’s folder. A nifty thing when giving a script to someone else. The problem maybe is the proper usage of unitys texture-functions.
A png shall be drawn as a logo in a window in unity’s editor, using base64. This is the summary of that code:
//Import .Net-base64-functions:
import System; //base64
import System.Text; //base64
class wintitle extends EditorWindow {
@MenuItem("MyMenu/Start")
static function Init() {
var window = GetWindow(wintitle);
window.position = Rect(300, 200, 210, 300);
window.Show();
}//end static function
//Prepare logo
var logobase64 : String = [some base64-stuff];
var dummy : boolean;
var logoloaded : boolean = false;
var logoraw : Object;
var logotex : Object;
function OnGUI() {
// Convert logo only once
if (!logoloaded){
logoraw = Convert.FromBase64String (logobase64);
logotex = new Texture2D (200, 102, TextureFormat.ARGB32, false);
logoloaded = true;
}//endif
logotex.LoadImage(logoraw);
dummy = EditorGUILayout.Button(GUIContent.image(logotex));
}//end ongui
}//endclass
What it should to: Conveting base64 (the png-file) into raw. Then convert raw into a Texture2D. Finally draw a button with that texture in the window.
The compiler says:
BCE0020: An instance of type ‘UnityEngine.GUIContent’ is required to access non static member ‘image’.
How do I correct the error?