Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Eroor in code Unity 5.6.7f1

Discussion in 'Scripting' started by UncleRus, Jun 22, 2021.

  1. UncleRus

    UncleRus

    Joined:
    Jan 12, 2021
    Posts:
    19
    Code (CSharp):
    1. using System;
    2. using System.Linq;
    3. using System.Reflection;
    4. using UnityEngine;
    5. using UnityEditor;
    6. using UnityEngine.EventSystems;
    7. using Object = UnityEngine.Object;
    8.  
    9. namespace CnControls
    10. {
    11.     /// <summary>
    12.     /// Some helping and guiding info trying to fix some common CNControls setup mistakes
    13.     /// </summary>
    14.     [InitializeOnLoad]
    15.     public class AdditionaHelpingGuidance
    16.     {
    17.         static AdditionaHelpingGuidance()
    18.         {
    19.             EditorApplication.playModeStateChanged += PlaymodeStateChanged;
    20.         }
    21.  
    22.     22    private static void OnPlaymodeStateChanged(UnityEditor.PlayModeStateChange state)
    23.         {
    24.             // If we've just changed our mode to a playmode
    25.             if (EditorApplication.isPlaying && EditorApplication.isPlayingOrWillChangePlaymode)
    26.             {
    27.                 var types = from t in Assembly.GetAssembly(typeof(SimpleButton)).GetTypes()
    28.                             where
    29.                                 t.IsClass
    30.                                 && t.Namespace == "CnControls"
    31.                                 && t.IsSubclassOf(typeof(MonoBehaviour))
    32.                             select t;
    33.  
    34.                 // If there are any CnControls on the scene
    35.                 bool shouldCheckForErrors = types.Any(type => Object.FindObjectOfType(type));
    36.  
    37.                 if (shouldCheckForErrors)
    38.                 {
    39.                     CheckForEventSystemPresence();
    40.                 }
    41.             }
    42.         }
    43.  
    44.         private static void CheckForEventSystemPresence()
    45.         {
    46.             var eventSystem = Object.FindObjectOfType<EventSystem>();
    47.  
    48.             if (eventSystem == null)
    49.             {
    50.                 ErrorPopupWindow.ShowWindow();
    51.             }
    52.         }
    53.     }
    54. }
    55.  
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,321
    Is there a question you're asking? Do you want devs to guess the "Error" or the problem?

    Please try to put some effort into describing what your issue is so that other devs don't have to guess what is wrong.
     
  3. UncleRus

    UncleRus

    Joined:
    Jan 12, 2021
    Posts:
    19
    Assets/UnitZ/Standard Assets/CNControls/Editor/AdditionaHelpingGuidance.cs(22,58): error CS0234: The type or namespace name `PlayModeStateChange' does not exist in the namespace `UnityEditor'. Are you missing an assembly reference?
     
  4. Kurt-Dekker and MelvMay like this.
  5. UncleRus

    UncleRus

    Joined:
    Jan 12, 2021
    Posts:
    19
    аd what i can do
     
  6. JoNax97

    JoNax97

    Joined:
    Feb 4, 2016
    Posts:
    611
    You could update to a more recent version of Unity (the one your using is over 4 years old).
    That way you will probably find more up-to-date code samples.

    It's recommend either of the LTS versions, 2019.4 or 2020.3
     
  7. UncleRus

    UncleRus

    Joined:
    Jan 12, 2021
    Posts:
    19
    Ok thanks
     
  8. daniel999

    daniel999

    Joined:
    Mar 15, 2014
    Posts:
    6
    i have the same error cs0246 the type or name plamodestatechange could not be found . are you missing an assembly reference?

    private static void PlaymodeStateChanged(PlayModeStateChange state)
     

    Attached Files:

  9. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,965
    Which Unity release are you on?
     
  10. daniel999

    daniel999

    Joined:
    Mar 15, 2014
    Posts:
    6
    i have two versions of unity 5.6.7f1
    unity 2022.2.18f1
     
  11. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,965
    Unity 5.6.7 doesn't have that feature. You really shouldn't be using that version unless you have an old project that is built on it that can't be upgraded. Try creating a copy of the project (just in case something goes wrong with the upgrade) and opening the copy with the new release. That error should go away.
     
  12. Ryiah likes this.
  13. daniel999

    daniel999

    Joined:
    Mar 15, 2014
    Posts:
    6
    already open the project in unity 2022.2.18f1 but now i get more errors
     

    Attached Files:

  14. Don't know what UnitZ is, so you're on your own. Try to find who wrote it and try to find documentation and support. But I have the suspicion that this uses UNet which is Unity's defunct networking solution. You will need to rewrite most of it to a modern and working networking solution.
     
  15. daniel999

    daniel999

    Joined:
    Mar 15, 2014
    Posts:
    6
    thank you :(
     
  16. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,965
  17. daniel999

    daniel999

    Joined:
    Mar 15, 2014
    Posts:
    6
    I'm already downloading the version of unity 2017.4 let's see if it works
     
  18. daniel999

    daniel999

    Joined:
    Mar 15, 2014
    Posts:
    6
    si me funciono en esta version muchas gracias :)