Search Unity

Warning generated at build but not at compilation; Impossible warning; Photon producing warning

Discussion in 'Scripting' started by Pirs01, Jul 20, 2015.

  1. Pirs01

    Pirs01

    Joined:
    Sep 30, 2012
    Posts:
    389
    I'm using Unity 5.0.0f4 Personal and Photon v1.58 (current package at store).

    1. Warning generated at build but not at compilation:
    After editing my game logic code and going back to Unity Editor recompilation does not prodcue any errors or warnings. However if I then build the project it generates a warning. What's up with that? Surely I'm not expected to build the project just to see if there are no warnings for sure?

    2. Impossible warning:
    When building the project the warning generated is:
    Fair enough. So I go to line in question in PhotonClasses.cs:
    Code (CSharp):
    1. public class MonoBehaviour : UnityEngine.MonoBehaviour
    2. {
    3.    new public PhotonView networkView
    4.    {
    and remove the 'new' keyword. Now going back to Editor compilation produces warning (note that in this case warning is produced at compilation and not just at build):
    The warnings are contradictory and thus impossible to fix?

    3. Photon producing warning:
    Warning in question comes with Photon out of the box. Not cool. Then again this seam to be a problem with Unity compiler and not Photon code?
     
    Last edited: Jul 20, 2015
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,297
  3. Pirs01

    Pirs01

    Joined:
    Sep 30, 2012
    Posts:
    389
    I updated to latest Unity release: 5.1.2f1 (64-bit) and the issue persists so I filed a bug report: 'Case 713468'
     
    Last edited: Jul 20, 2015
  4. bboomz

    bboomz

    Joined:
    Aug 4, 2015
    Posts:
    1
    Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonClasses.cs(390,31): warning CS0109: The member `Photon.MonoBehaviour.networkView' does not hide an inherited member. The new keyword is not required

    I have the same problem~
     
  5. wehavethecretes

    wehavethecretes

    Joined:
    Aug 20, 2015
    Posts:
    1
    Me too, just for corroboration.
     
  6. Chris196

    Chris196

    Joined:
    Apr 16, 2015
    Posts:
    6
    I have the same problem. The weird thing is that the error wasnt there at begin. It came after i wrote some code. Did u find a result ?
     
  7. BenHymers

    BenHymers

    Joined:
    Dec 16, 2014
    Posts:
    30
  8. BenHymers

    BenHymers

    Joined:
    Dec 16, 2014
    Posts:
    30
    Official response from Unity: this is intended, because the Unity API changes based on whether you're in editor or building the project. Either don't ever hide a name from something within Unity, or use #pragmas to suppress the warning.

    I think that's a terrible attitude really. Yet another thing that says to me "Unity isn't meant for professionals".
     
  9. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    MonoBehavior is known to be special in Unity. Since it was updated in Unity 5, it is not really surprising that there are warnings when it was used like that.
    Unity could easily avoid that kind of warnings, by reimplementing it from scratch in a more OOP like manner and break all the code that is based on it. Would that be more professional for you?
     
  10. Ziplock9000

    Ziplock9000

    Joined:
    Jan 26, 2016
    Posts:
    360
    So what's the elegant solution?
     
  11. BenHymers

    BenHymers

    Joined:
    Dec 16, 2014
    Posts:
    30
    You misunderstand - I'm not at all talking about the interface of MonoBehaviour (though I do think it was shortsighted to put so much stuff in it in the first place! We all make mistakes though so it's not a big deal). I'm talking about the fact that the Unity API changes within one version of Unity depending on whether you're building for the editor or standalone, which leads to the contradictory warning Pirs01 and I reported above. That inconsistency is what I find unprofessional.

    Ziplock9000, there isn't an elegant solution - either rename the field/property, or suppress the warning with #pragma.
     
    Ziplock9000 likes this.