Why is it that everytime I try to follow a tutorial or the unity documentation it doesn’t compile?
its like no one attempts to update their tutorials.
I am currently copying this
but it says that GetWindow and window.Show doesn’t exist.
this is my current code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.Runtime.CompilerServices;
public class FoldoutUsage : MonoBehaviour {
bool showPosition = true;
string status = "Select a GameObject";
[MenuItem("Examples/Foldout Usage")]
static void Init() {
FoldoutUsage window = (FoldoutUsage)GetWindow(typeof(FoldoutUsage));
window.Show();
}
}
I am on unity 5.5.1f1 personal and this shouldn’t be happening.
I know it’s frustrating, I feel your pain, but the Unity API continues to evolve and expand, and stuff gets deprecated and obsoleted over time. There is no way for all tutorials and code snippets to ever be updated all at once, since they are scattered about the interwebs everywhere.
Well to be fair to Unity, in this case you used MonoBehavior instead of EditorWindow, which is the root of probably most of your current issues.
Edit: I just went and copy/pasted Unity’s FoldoutUsage example and it works precisely as indicated: makes a menu item under “Examples” and pops open a custom transform position inspector window.
Don’t get frustrated too easily in Unity because you’re coming into a MASSIVE system of amazing complexity and function. You can do almost EVERYTHING you could ever want to do in Unity… you just have to take the time to understand it, and that takes time.
There’s a lot of documentation though… and sometimes it gets missed, or they just haven’t gotten to it yet.
I won’t lie, as a dev, I’d rather them release me new features and wait on documentation corrections, rather than wait on documentation corrections before I get my new feature release.
That’s part of the attraction: there is ALWAYS some new nuance to learn. Good stuff… easily the best engine out there for all-around good times game-makin’ fun.