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

Ghost script is freaking me out.

Discussion in 'Scripting' started by TAMgames, Oct 21, 2014.

  1. TAMgames

    TAMgames

    Joined:
    Oct 9, 2014
    Posts:
    5
    This is one of the weirdest things I've ever encountered, maybe somebody can tell me why this is happening.

    TLDR; A permanently deleted script still runs even after rebooting. Why?

    I'm building a Rougelike and the script that runs to procedurally generate a new level was giving me problems. I'll call this the Original Script a Method in the script wouldn't execute an ELSE, it would just skip it like it wasn't there even if I made the IF condition explicitly false.

    Right away what was really weird about this was that I was copying and pasting part of the method in the Original Script from another old script and that part of the method (the IF{} ELSE{} part) was unchanged except for the variable names. I used MonoDevelope to Clean and Rebuild it, I checked around here and stackoverflow to see if other people had the same problem (with an un-executed ELSE), messed with it so that it would only logically execute the ELSE and never the IF. No matter what I did I couldn't get it to execute the ELSE condition.

    I eventually busted out graph paper, put all the variables down and ran through the script step by step to see why it wasn't working but as far as I could tell it should have worked. I'm not a particularly good programmer but this isn't difficult code.

    In my frustration I just gave up on the whole script. I started over in a new script. I wanted to verify that just that method worked so I rebuilt it in a new script ran it and it worked fine.

    That's when things got weird...

    I disabled the Original Script, the one that didn't work and built a New Script and it worked, no problem.

    I was moving on to the next part of the New Script when I noticed that the Console had output from the Original Script. Before I gave up on the Original Script I had put some Debug.Log output to see why it wasn't getting to the ELSE statement. I thought it was weird that I would still be getting that output even though it was disabled but I just cleared the Console and went in to play mode to make certain the console hadn't somehow retained the old Debug.Log outputs. Once again the console filled up with output from the disabled Original Script.

    So, I removed the Original Script component from the game object it was on and went through the Hierarchy item by item to make sure the Original Script wasn't attached to something else. It isn't. I cleared the Console, went back in to play mode and the Console filled up with the debug output from the Original Script again.

    I'm sure I don't need to cannibalize anything from this script and it's just annoying me at this point so I deleted it, emptied the recycle bin, did a Clean and Rebuild All in MonoDevelope went back in to play mode and... WTF? I'm getting data sent to the Console from a file I deleted!

    Okay, okay... I searched my hard drive for the file name to make sure there's no copy of it floating around in another directory, there isn't. Oh, and maybe it's just floating around in some memory address and this project file loves it so much that it just can't let the Original Script go.

    I rebooted my computer.

    Come back into the project go in to play mode the Console is still getting Debug.Log output from the Original Script. A file I deleted. A Ghost Script.

    So... How do I get rid of this script?
     
  2. DrSnake

    DrSnake

    Joined:
    Oct 17, 2014
    Posts:
    33
    What happens if you double click on this Debug statement in the console? Where does it take you?
     
    TAMgames likes this.
  3. TAMgames

    TAMgames

    Joined:
    Oct 9, 2014
    Posts:
    5
    I realize how dumb I am... *facepalm*

    It was never coming from the "Ghost Script" it's just after 4am and I forgot I had another script sending debug data to the Console.

    Thanks for suggesting that DrSnake.

    Time for sleep now...
     
  4. DrSnake

    DrSnake

    Joined:
    Oct 17, 2014
    Posts:
    33
    Your welcome :)
    Good night.