with minimal use of the scene editor?
Alot of game tutorials/walkthrough I’ve seen are using the editor to load in scenes while building intergral parts of their game objects and such.
but, instead, I wanted to know if there exists tutorials where the the dev is taught how to instantiate whole working simple game loops out of scripts. Kind of like in other game engines. I could possibly figure it out myself, but there is a lot of ways to go about doing this and i get codeblocked in my head trying to go through all of them… so would I like to know some standard techniques for what most unity scenes require to be considered competent gameplay scenes. I have done the same in the past with any other game making language as a personal rule.
eveery youtube video and documentation ive searched for and then watched always makes use of the scene editor in some intergral way of managing their game objects, this does not interest me, because I know how to work off the scene editor already. I’m more interested in being able to control or being shown how to manage blank objects I instantiate and keep track of all of the created objects through the use of scripts kind of like a blank screen being passed logic in some other language but using unity.
i apologise if this came off as rude, i appreciate the scene editor Unity technologies gave us and I just wish to make use of it through code to strengthen my development ability as I end up being reliant on prefabbed scenes and cant make stronger games/apps.
My friend, I highly encourage this way of doing things. In fact, I do this for many of my projects, but I have not made any tutorials. I prefer coding rather than clicking and dragging, and Unity is an AMAZING engine to work inside of, once you understand how it all fits together.
For example, here is a almost-all-scripts pong solitaire game I wrote:
You can see each commit in the git repository and see how it was built up over the life of its development.
Other than that, just tinker! Don’t be afraid of being code-blocked… try stuff, try little stuff, throw it away, make bigger stuff, go nuts. Unity is awesome for this. Don’t get hung up worrying about how to break it up. Just write stuff, learn from it, write better stuff, break it up more logically.
You probably want a text tutorial rather then a YouTube one. YouTube tends to be a visual medium, and attracts those that use visual things like the scene view.
The actual process is fairly simple
void CreateAThing (){
GameObject newThing = new GameObject ("The thing");
newThing.transform.position = new Vector3 (1,2,1);
newThing.AddComponent<RigidBody>();
MyComponent myComponent = newThing.AddComponent<MyComponent>();
myComponent.SomeMethod(17);
}
I’m not saying I support the idea. Just that its trivially easy to do. But each to their own.
I personally do almost everything via drag and drop in the inspector. If you have serialisation set to text then this is just as easy to follow in source control. At least for the small scale projects I work on.
That makes alot of sense, I guess I’ll just take your advice and not be afraid to throw away and rewrite whole sets of logical classes to get what I want and learn by doing.
Thats actually pretty much where I am at or what Im doing right now, so I guess I can work from here and see what happens or what I can do.
There is no “void main()” style entry point lurking in the API though, right? Getting up and running still requires a minimum of one script on a scene object with at least one Update call, true?
You can make an empty scene with one game object and one script and spin it all up from there: create the camera, create the objects, display the GUI, etc.
That’s a little wasteful of your time however. I’d start with at least a camera with some handy skybox settings and a directional light, most likely, unless you’re doing 2D, which means you don’t need the dir light.
I always make a game object called “0scripts” (zero to make it sort to the top in alpha order) and then put one script on that, and that script spins everything else up.
If you make your Start() function actually an IEnumerator (rather than a void), then you can write your entire game in that one function and you don’t even need to use Update.
// put all public references you want to set up in the editor here
IEnumerator Start()
{
// declare variables
// load any assets with Resources.Load (they have to be under a Resources/ folder!)
// create needed game objects
while(true)
{
// do one frame of processing of your game
// let unity show and process everything!
yield return null;
}
}
void OnGUI()
{
// use GUI.Label to display anything you need like score, lives, etc.
}
Yeah I asked out of curiosity. My scenes are typically pretty empty but I wondered how far it could be taken. I used to do a lot of abstract D3D graphics.