C# Namespaces in Unity! - Intermediate Scripting Tutorial

preview_player
Показать описание
Namespaces allow you to organize your classes and prevent any unwanted clutter. In this video, you will learn to use existing namespaces and create new namespaces for your scripts!

Рекомендации по теме
Комментарии
Автор

I find it interesting that you derive most of your scripts from MonoBehavior. But if you remove the UnityEngine namespace, you can't derive from Monobehavior anymore.
So Mono is a class in the UnityEngine nameSpace.
Interesting when you want multiple objects to for example, be an entity, but each is different. So you derive from classes all under the nameSpace entity.
Such as
entity: creature > human > NPC.
entity: machine > human > player.
Both are dynamic objects players and things in the game interact with but;
One is a living being affected by diseases and fatique, has human stats and movement and is controlled by an AI.
Other is an autonomous creation impervious by viruses but detrimental to water and doesn't recover, has constant but changeable stats based on parts, machine movement and is controlled by a player.

magnusm
Автор

summary by bing ai:
Namespaces are like containers for classes that help organize scripts and avoid conflicts.
The using keyword allows you to use anything within the specified namespace in your script.
You can put a class in a namespace by surrounding it with the namespace syntax, starting with the keyword namespace followed by the namespace’s name.
There are several ways to access classes from a specific namespace, including using a using directive at the top of your script, using the dot operator, or putting the class you are writing into the namespace you need access to.
It’s important to be careful when using namespaces to avoid ambiguous definitions.

makcings
Автор

Now how do you find existing namespaces?
I heard about the Object Browser in Visual Studio, it's empty for me though.

Broockle
Автор

ngl but i have no clue what hes doing.

tartaglia
Автор

All these videos have "in Unity" in the title, yet this is the first one that involves Unity in any way and only for a brief moment, making them really generic scripting tutorials of which there are already many. It would make more sense to introduce a concept and then show how it could be used in actual (professional) Unity development, instead of just a simplistic example that is unlikely to be scalable for anything more than a dinky 2D side-scroller. There are already many other (better) tutorials on C# and calling this level of scripting "intermediate" is generous.

pearz
Автор

Silly C#, Java does this so much better with package -- I guess you gotta use what you have.

BlackJar