Search Unity

Programmer in need of Unity guidance.

Discussion in 'Editor & General Support' started by SimtropBuggi, Aug 9, 2013.

  1. SimtropBuggi

    SimtropBuggi

    Joined:
    Feb 15, 2013
    Posts:
    98
    I'm a pretty experienced programmer with 15 years of coding under my belt and I find myself simply lost in Unity. It's too visual.

    I'm used to code. Objects, hierarchy, functions, and procedures.

    Dragging and dropping an object into the proper window is all well and good, but what goes on under the hood? How can I access these objects? What holds the base objects in the hierarchy? Is there some root object I can look at?

    I'm not understanding the Object Model of the big picture. Yes I can drag components onto objects which is handy, but my game will be 99% run time and only 1% pre-defined objects. Mainly the UI and a blank scene with a Load function that loads what is needed.

    My game is a city sim so nothing will be 'pre-made', however I'm at a loss at how to access the root of the scene. Any help would be appreciated.
     
  2. roxIndie

    roxIndie

    Joined:
    Oct 14, 2012
    Posts:
    28
    Yes, you can create your scenes from code, if you need them to be completely random, but it will make the scenes heavier to run as you loose the ability to bake lightmaps, navmeshes and Occlusion maps for the scene.

    Anyways I would recommend that you learn how Unity works before attempting to do everything from code. Start with some tutorials or less ambitious projects first, and when you get the hang of the GameObject, Prefab and Component systems, return to your current project.

    As to accessing the root of the scene you can use the GameObject searches or have a Manager that all instanced GO's report to.
     
    Last edited: Aug 9, 2013
  3. Sessional

    Sessional

    Joined:
    Apr 21, 2013
    Posts:
    45
    I was kind of in your boat Simtrop, granted I have no where near 15 years, I've only been programming in my free time for 5 and am now starting a 3rd year of college in computer science.

    A book I found VERY useful http://www.amazon.com/Unity-3-x-Game-Development-Essentials/dp/1849691444/ref=dp_ob_title_bk

    This got me started and now I'm good to go.

    As for the "root", you don't necessarily need to do such a thing. I do a thing where I make an object at 0,0 and call it origin - this then runs some functions that I need to run at level load and generally contains a data structure to hold on to the rest of my dynamically generated objects - this allows me to get to and from everything quite simply.

    Also. GameObject.Find and other similar methods are extremely useful in getting access to an "origin" object from other objects. I find that generally if you can do something in programming unity has some way of getting it done, some of which are much simpler then I'm used to with programming.
     
  4. XGundam05

    XGundam05

    Joined:
    Mar 29, 2012
    Posts:
    473
    The other thing to look into would be articles on Component Entity Systems (CES), because that's how Unity handles things. It's quite elegant after you get over the initial hurdle of "but...but...where's my deep, convoluted inheritance?!"
     
  5. SimtropBuggi

    SimtropBuggi

    Joined:
    Feb 15, 2013
    Posts:
    98
    Thanks for the reference to the book! I will be picking up a copy as soon as I can afford it.

    So much to learn, so little (free) time.