Trying to understand "types" like GameObject, etc

Hello - I’m a beginner, if there’s a beginners page please point me in that direction!

I’ve been examining/dabbling in code for years; I understand why 3 is of type int, why “cup” is a string, and why ‘difficulty myDifficulty’ inherits enum when ‘enum difficulty;’

but one thing that I’ve never really understood, especially now with c# in unity, is

what is the type ‘GameObject’ - what happens when I assign a variable type GameObject… ie, GameObject cube;

another example

You write a class called ‘Orientation’ and assign it to a cube, it creates rotation for z axis, then in another class you refer to it by creating a variable of type ‘Orientation’, ie, Orientation spinAmount;

so now spinAmount is type Orientation… my problem is that I don’t understand how ‘Orientation’ is a type.

What is the purpose of having these (to me) obscure types? Can you make anything a type? I always assumed ‘types’ were like int - a number (and absolute -or- predefined)

Are there things that can’t be ‘types’?

Hopefully that made sense and someone else has had this same feeling? Thanks for any insight

Read any programming book, or web page(?) about making and using classes (or structs or any datatype.) It’s a really nice trick that we invented long before Unity or C#.

Very short example. Suppose all pickups have a cost, weight, icon and a prefab when you drop them. We can set that up:

class PlayerItem {
  int cost;
  float weight;
  Texture2D icon;
  Transform prefab;
}

PlayerItem chicken = new PlayerItem();

Chicken now has all four variables, bundled together. chicken.cost and so on. Of course, you still have to set them. But way nicer than having to make all four chickenCost, chickenWeight … variables yourself. There also are some extra magic words that seem redundant – if you declare an int, it auto-makes the int; but if you declare a chicken, you also have to make(new) the chicken? Yeah, C# is just like that.

I’ll try this and try to be as concise as possible since you understand programming and just need to get over this 'lil hump.

GameObjects are unity objects you create in your Scenes. You go to Create > GameObject to make an empty one with nothing in it. In your inspector you can see you can set Tags to it for a reference point like ‘Player’ and then layers if you want to customize how it interacts with other colliders and such. You could set the tag to ‘Player’ for instance.

Then let’s say you want to reference your player GameObject somewhere else. You can do that anywhere with

GameObject Player = GameObject.FindGameObjectWithTag("Player");

this is just like setting up a reference to anything, like:

int count = 1;

Everything in your Scene is housed in a GameObject, and then you can add scripts to those GameObjects to do whatever you want.

To answer the second part of your question, the purpose of these ‘obscure’ types is that you get to define what it does because the type is the piece of code that you created. This is the beauty of generic types because you get to make whatever you want!

You name every script you add to your GameObjects, and then you can reference those too. See how I set up a reference to the player GameObject up there? Now you could access your ‘Orientation’ script and set your spinAmount or whatever you want.

Orientation orient = Player.GetComponent<Orientation>();

float spin = orient.spinAmount;