Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Unity 5 Beta Insights

Discussion in 'Unity 5 Pre-order Beta' started by ImpossibleRobert, May 11, 2014.

  1. numberkruncher

    numberkruncher

    Joined:
    Feb 18, 2012
    Posts:
    953
    On the subject of the == null and != null operators I had a thought. If these were removed perhaps it would make sense to adopt a custom interface like the following:
    Code (csharp):
    1.  
    2. public interface IDestroyable
    3.     bool HasDestroyed { get; }
    4.     void Destroy();
    5. }
    6.  
    Where Object implements this.

    This would be beneficial in situations where interfaces are being used on custom behaviours or scripable objects:
    Code (csharp):
    1.  
    2. public interface ISpaceship : IDestroyable {
    3.     void FireLaser();
    4. }
    5.  
    6. public class Spaceship : MonoBehaviour, ISpaceship {
    7.     public void FireLaser() {
    8.         Debug.Log("Swoosh");
    9.     }
    10. }
    11.  
    12. public void HandleFireInput(ISpaceship ship) {
    13.     if (ship == null || ship.IsDestroyed)
    14.         throw new Exception("Ship was null or destroyed.");
    15.  
    16.     ship.FireLaser();
    17. }
    18.  
    Just a thought...
     
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Since when has Unity been .net though? It's not as if unity's js or Boo is really the same stuff. C# comes from .net, but c# is a language and .net is something optional entirely. Unity uses Mono (and god knows what else coming).
     
    deram_scholzara likes this.
  3. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,659
    I don't really care what naming convention gets used as long as I can configure Resharper to enforce it for me automatically.

    To that end I suggest using whatever naming convention is used by Resharper by default, which IIRC is the .NET standard naming convention.
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Well if everything else is using it I might as well as well for consistency's sake.
     
  5. zRedCode

    zRedCode

    Joined:
    Nov 11, 2013
    Posts:
    131
    i not want to read 8 pages of posts, so if have understanded all in unity 5 instead of writing:
    Code (CSharp):
    1. this.renderer.collider.attachedRigidbody.angularDrag = 0.2f;
    we have to write:
    Code (CSharp):
    1. GetComponent<Renderer>().GetComponent<Collider>().GetComponent<Rigidbody>().angularDrag = 0.2f;
    or wather else? Tell me!
     
  6. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    Yes.

    Not sure whats the logic in your example as isn't the rigidbody in the same object anyways(?) so:

    Code (CSharp):
    1. GetComponent<Rigidbody>().angularDrag = 0.2f;
    But if you access something frequently you should/could cache it anyways instead of calling multiple GetComponent everywhere.
     
  7. Gigiwoo

    Gigiwoo

    Joined:
    Mar 16, 2011
    Posts:
    2,981
    Nesting GetComponent<> is silly. Just ask for the one you want up front.

    Code (CSharp):
    1. GetComponent<Rigidbody>().angularDrag = 0.2f;
    Gigi
     
  8. zRedCode

    zRedCode

    Joined:
    Nov 11, 2013
    Posts:
    131
    if i have a game object attached to an script and i want to modify the first object rigidbody i have to use:
    Code (CSharp):
    1.  firstobject.GetComponent<Rigidbody>().mass = 100;
    or I'm wrong?
     
  9. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    You are right.
     
  10. zRedCode

    zRedCode

    Joined:
    Nov 11, 2013
    Posts:
    131
    ok thanks all!
     
  11. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
  12. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    I did say in the post it was a silly long winded example :D Just to make a point.
     
  13. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,572
    Modularisation sounds great. I remember an app going over the iOS 20MB OTA download limit (when it was 20, not 100) because an update to Unity added Terrain to iOS. That caused another round of optimisation that would have been avoided with this system. It is very welcome with all the new features coming in Unity 5.

    I did have a double take at the wording below. It took a second to realise Lucas was talking about bytes, not finance. Modularisation of buying Unity would be brilliant, but modularisation of builds is also. This has the potential to be my favourite Unity 5 feature.

    EDIT: I just did my first build on an iOS project since updating to 4.5 from 4.3. The app estimated size has grown by 1.3 MB to 29.4. I'm really looking forward to modularisation.
     
    Last edited: Jun 24, 2014
  14. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    I hope that, by modularization, it means the .rigidbody shortcut is kept, I don't want to have to GetComponent and make my code really messy!

    EDIT: I also wish to continue to make wonders with only two lines of code, so removing shortcuts like .rigidbody would increase the line count somewhat, depending on what you're trying to write. basically, don't alienate us please! :D
     
  15. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    AFAIK to achieve proper modularization all those silly shortcuts need to go. Even if code might seem to become larger in lines or generally it also becomes more standard and efficient as people will cache the needed references more than before.
     
  16. judah4

    judah4

    Joined:
    Feb 6, 2011
    Posts:
    256
    the only thing you would have to add is
    Code (CSharp):
    1. public Rigidbody rigidbody;
    2.  
    3. void Start() {
    4.      rigidbody = GetComponent<Rigidbody>();
    5. }
    and all your .rigidbody calls work like before. Not messy at all
     
  17. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,659
    No, those shortcuts are going away. But as judah4 says, it's quite easy to reintroduce them yourself.
     
  18. landon912

    landon912

    Joined:
    Nov 8, 2011
    Posts:
    1,579
    In my opinion x.0 releases should and can contain major changes. If you are not going to make wanted/needed compatibility changes on this type of release we will always be stuck with these stupid decade old issues. X.0 release is when you shouldn't worry about breaking old projects and fix what needs to be fixed. We can update our projects to comply with the changes.
     
  19. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Couldn't disagree more. This is why you extend the base class with your GameBehaviour which extends monobehaviour. You can then replicate the unity functionality 1:1 pretty much and everyone is happier. You only need to do that extra typing once, then all your stuff is as it was before - perhaps better.

    For instance I have a SCache class which does all the typical caching of components that I need on a regular basis for a sprite with physics.

    Typing one line more is never a reason not to do something, come on, that's just bizarre :)
     
    Ryiah likes this.
  20. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Ok, I will stop... I just found the .rigidbody shortcut more convenient... :(
     
  21. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,659
    They are convenient, but they're inconsistent (why .rigidbody and not .rigidbody2D, for example?) and they make it much harder to modularize the code, which means your builds are larger and slower. Convenience comes at a price!
     
  22. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Yes, that is agreed. I also wouldn't mind a faster runtime library... but with Xamarin being so difficult with Unity, from what I heard, mono is probably going to stay the way it is. Also sorry that it's off-topic, but... :D
     
  23. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's not anything to do with Mono. As for "stay the way it is," no.

    --Eric
     
    GeneBox likes this.
  24. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,123
    Any idea when the preorder people get accesso the beta? I preordered a long time ago and would really like to show a client something i ahve done before except in web gl.
     
  25. ImpossibleRobert

    ImpossibleRobert

    Joined:
    Oct 10, 2013
    Posts:
    531
  26. srmojuze

    srmojuze

    Joined:
    Mar 18, 2013
    Posts:
    127
    Yes I want Beta! HaHa so looking forward to it, preordered and all that. Going to Unite Melbourne next week, see (some) of y'all there. Cheers :)
     
  27. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
  28. Zeblote

    Zeblote

    Joined:
    Feb 8, 2013
    Posts:
    1,102
    "several days ago" in august...

    All other versions up to b9 were leaked too, obviously.
     
  29. ImpossibleRobert

    ImpossibleRobert

    Joined:
    Oct 10, 2013
    Posts:
    531
  30. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,123
    oh F*** yes. Pardon my language lol
     
    shkar-noori likes this.
  31. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374


    And a sense of humor :)
     
    Last edited: Oct 27, 2014
  32. SaraCecilia

    SaraCecilia

    Joined:
    Jul 9, 2014
    Posts:
    675
  33. SaraCecilia

    SaraCecilia

    Joined:
    Jul 9, 2014
    Posts:
    675
  34. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,315
    its not public but can we have some feedback from users on low end platforms like mobile for example ?
    Can we expect to run new lighting or new standard shader with decent perfs?
     
  35. SaraCecilia

    SaraCecilia

    Joined:
    Jul 9, 2014
    Posts:
    675
    I expect feedback from users will show up in the 5.0 beta forum: http://forum.unity3d.com/forums/unity-5-pre-order-beta.72/

    You can always go ahead and post questions there already to find out information before you start using 5.0
     
  36. ImpossibleRobert

    ImpossibleRobert

    Joined:
    Oct 10, 2013
    Posts:
    531
    The "public" part was more referring to the link itself instead of who can actually activate it as they were talking about leaked files above :)
     
  37. Freezy

    Freezy

    Joined:
    Jul 15, 2012
    Posts:
    234
    I love the removal of the .component accessors, I used to override those non-cached innocent looking little devils with the new keyword which checks if the cache is null and the returns the component (if available)).
    Code (CSharp):
    1.  
    2.  
    3. public Rigidbody _rigidbody = null;
    4. public new Rigidbody rigidbody { get { if(_rigidbody == null) _rigidbody = base.rigidbody; return _rigidbody;}}
    5.  
    6.  
    No more of that thank you very much :p

    The awake, start, custom setup / init way of setting your own reference also works nicely, but sometimes you just want to protect your self from accidental code completion idiocy.
     
    shkar-noori likes this.