Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Unity OOP /API

Discussion in 'Scripting' started by fau7, Feb 28, 2018.

  1. fau7

    fau7

    Joined:
    Jan 24, 2018
    Posts:
    48
    Hi Unity Community,
    This I my first post. I want to greet everyone around. I have a question in mind that I wanted to share. I made some research but I was not able to find a concrete answer. I would be very happy if I could have a chat about sources for OOP Unity programming techniques and examples. I know that my wish is a bit hollow but having practiced years with OOP that is my safe and productive waters. I would be very happy if you could share your thoughts or experiences about this.
    Thank in advance.
    Cheers
    Fau
     
  2. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,874
    learn SOLID principles and youll be fine
     
  3. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Shame the future of Unity isn't OOP :D Good discussion to think about though (ECS).
     
  4. fau7

    fau7

    Joined:
    Jan 24, 2018
    Posts:
    48
    Actually it would be fantastic to implement inheritnce interfaces encapsulation etc. For example I want to create a GUI library of my own with all the entities extending from Unity’s classes. When I think of C# it should not sound impossible though. I have come across with genius ways to overcome the obstacles. I have hope
    Thank you for the replies hippocoder and Daemonhahn
     
  5. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,900
    One thing you will have to keep in mind: OOP is okay while you're working on low-demand games or low-demand parts of games (menus, once-in-a-while running methods and execution paths), but when it comes to the rendering path and the core gameplay path in an action game or a heavy RTS/TPS game, you will have to break up with the OOP eventually.
    This is because OOP is a huge abstraction and every abstraction will take up considerable amount of CPU time. Eventually you will learn that game programming is messy and you just can do so much about it.
    So do your thing, learn these things, but be ready to drop OOP for performance when the time is right.

    @hippocoder well, this is not true on this way :) C# is a strongly OOP language so you always will see the smaller games in OOP and most of the bigger games will be OOP as well, except for the 'hot-path'.
     
    fau7 likes this.
  6. fau7

    fau7

    Joined:
    Jan 24, 2018
    Posts:
    48
    Yep I have high hopes. ❤️ Unity btw
     
  7. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,378
    I believe the :D is to imply he's being flippant.

    C# is obvsly OOP heavy.

    But at the same time, Unity is implementing some new models that are more data oriented in some ways.
     
    fau7 likes this.
  8. fau7

    fau7

    Joined:
    Jan 24, 2018
    Posts:
    48
    Wow... ❤️ “Unity is implementing some new models”. Could you please open this beautiful sentence..
    Like MVVM.... or so
     
  9. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,900
    Yeah, I suspected that. :D
     
    fau7 likes this.
  10. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,378
    No, data oriented:
    https://en.wikipedia.org/wiki/Data-oriented_design

    They hired some new engineers to optimize the engine in ways using data oriented design:
    https://blogs.unity3d.com/2017/11/0...o-help-democratize-data-oriented-programming/

    Correct me if I'm wrong, but the new Unity Jobs System is supposed to be data oriented.

    MVVM is still rather OOP-ish. It's just an architectual pattern, usually used for UI stuff.
     
    fau7 likes this.
  11. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,900
    Well, if we want to be correct, the Job System is a multi-thread support system. Although the entire setup, including the new Native* types are heavy support of the data-oriented programming.
    And moving away from OOP that's for sure.
     
    fau7 likes this.
  12. fau7

    fau7

    Joined:
    Jan 24, 2018
    Posts:
    48
    Great expectations then
    Thank you for the insightful reply
     
  13. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,378
    That wouldn't be correcting, that'd be more specific. Since it still includes 'data-oriented'. To correct would be to replace my false statement with a correct statement. Basically to say "no, it's not data oriented".

    It'd be like correcting my statement "my Yaris runs on gasoline" by saying "To be correct, your Yaris is intended to transport you around, and it also runs on gasoline." We could easily keep adding on new describers, making it more specific, with out ever changing the correctness of the statements.

    If you want to be pedantic that is.
     
  14. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,900
    Well, then "to be more specific". - BTW, I'm sorry, I'm not a native English speaker, so sometimes I miss these subtle differences. In my native tongue these are almost exchangeable in some fashion.