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. Dismiss Notice

deleted/change C# code reverts in Visual Studio

Discussion in 'Scripting' started by peterbrinson, Aug 2, 2020.

  1. peterbrinson

    peterbrinson

    Joined:
    Jul 1, 2013
    Posts:
    63
    I'm sure this is an understood situation that I'm new to.

    I updated to 2020.1 and want to get rid of some code in a script I otherwise shouldn't be meddling with - TMPro_Private.cs

    I delete the Debug statement that says this, "Removing unnecessary CanvasRenderer component from text object."

    But when I play in unity, the deleted code literally returns in Visual Studio.

    One clue? -- In visual studio, I 'moved' it into "Assembly-CSharp" and now dozens of functions and variables have the red jagged line under them, even though it I get no errors in the console, and the game runs fine.
     
  2. Dextozz

    Dextozz

    Joined:
    Apr 8, 2018
    Posts:
    488
    It's an internal thing. You really shouldn't ever have the need to mess with that?

    Why would you want to remove that debug statement?
     
  3. peterbrinson

    peterbrinson

    Joined:
    Jul 1, 2013
    Posts:
    63
  4. gnovos

    gnovos

    Joined:
    Apr 29, 2020
    Posts:
    20
    same here. I'm instantiating a prefab that contians a TMP object and I get this message:

    Removing unnecessary CanvasRenderer component from text object.
    UnityEngine.Debug:Log(Object, Object)
    TMPro.TextMeshPro:Awake() (at Library/PackageCache/com.unity.textmeshpro@3.0.1/Scripts/Runtime/TMPro_Private.cs:77)
    UnityEngine.Object:Instantiate(GameObject)​

    followed by an error:


    Destroying components immediately is not permitted during physics trigger/contact, animation event callbacks, rendering callbacks or OnValidate. You must use Destroy instead.
    UnityEngine.Object:DestroyImmediate(Object)
    TMPro.TextMeshPro:Awake() (at Library/PackageCache/com.unity.textmeshpro@3.0.1/Scripts/Runtime/TMPro_Private.cs:78)
    UnityEngine.Object:Instantiate(GameObject)
    ResourceLoader:spawn(String) (at Assets/Scripts/ResourceLoader.cs:53)
    DialogPanel:addDialogBubble(String, String, Transform, Boolean) (at Assets/Scripts/DialogPanel.cs:161)
    WebTrap:OnTriggerEnter(Collider) (at Assets/Scripts/WebTrap.cs:23)​
     
  5. bazkie_bumpercar

    bazkie_bumpercar

    Joined:
    Jul 11, 2019
    Posts:
    9
    I get this too, after updating unity. Prefabs with TMPro elements have a parent 'canvas renderer' object inside them, that isn't necessary in my case (because it's the type of TMPro object that renders in the game world, not inside the UI canvas).

    I got rid of it by fiddling around a bit with the assets, I'm not sure how but after instancing/deleting the assets and clicking around some more, the canvas renderer parent object disappeared, as well as the debug messages. Hope you get this to work too..