Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Bug "Script" components have editable field

Discussion in 'Editor & General Support' started by Kaivian, Jun 9, 2021.

  1. Kaivian

    Kaivian

    Joined:
    Jan 18, 2018
    Posts:
    23
    upload_2021-6-9_10-34-18.png

    In the above example, you can see that the script field in AI Destination Setter can be edited, and HealthDisplay cannot be edited (default). I consider it a bug that it can be edited, as a mis-click on the "target" button will erase all the set fields in the component, which frustrated me a lot as a beginner (didn't know what was happening), and as an advanced user, I find annoying.

    I have found there's two cases where this happens. The first are for custom classes that inherit and extend monobehaviour. The second is when the script employs any kind of custom editor code at all.

    This results in a lot of scripts with this bug, especially those in asset packages or made by advanced users (for people who aren't necessarily adept at unity).

    To fix this bug, I think the editor should be changed so that in these circumstances, the script field is still read only. Another option, which would actually clean up the editor, is to totally eliminate the script field. As is, you can currently right click the header and select "edit script." This component does that:

    upload_2021-6-9_10-44-47.png

    Btw, these components are from the very popular A* pathfinding project store asset.

    I have seen this problem in many popular assets.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    18,423
    After you mis-click, can you restore the fields by re-dragging the proper original script onto the above slot?

    It used to be that you could always drag fresh scripts into this slot, which was actually super-useful.

    Or what about a good old CTRL-Z to back up and undo?

    Otherwise, please consider using source control in order to guard and protect your hard-earned work.

    Personally I use git because it is free and there are tons of tutorials out there to help you set it up.

    As far as configuring Unity to play nice with git, keep this in mind:

    https://forum.unity.com/threads/prefab-links-keep-getting-dumped-on-git-pull.646600/#post-7142306

    Here's how I use git in one of my games, Jetpack Kurt:

    https://forum.unity.com/threads/2-steps-backwards.965048/#post-6282497

    Using fine-grained source control as you work to refine your engineering:

    https://forum.unity.com/threads/whe...grammer-example-in-text.1048739/#post-6783740

    Share/Sharing source code between projects:

    https://forum.unity.com/threads/your-techniques-to-share-code-between-projects.575959/#post-3835837

    Setting up the right .gitignore file:

    https://forum.unity.com/threads/removing-il2cpp_cache-from-project.1084607/#post-6997067

    Generally setting Unity up (includes above .gitignore concepts):

    https://thoughtbot.com/blog/how-to-git-with-unity
     
  3. Kaivian

    Kaivian

    Joined:
    Jan 18, 2018
    Posts:
    23
    So I'm talking about if you changed fields from their default. Like, lets say you have a script that has an array of game objects. Maybe it's every npc in the scene. You're using this to avoid "find" calls that cause slowdowns. If you mess up this script, now you need to drag 20 npcs back into the array. This is just an example I came up with, so don't get too caught up on the details.

    I think the skipping the steps of "remove component" and dragging a script into the inspector, for the rare case you want to replace one script, doesn't warrant the problems this can cause. It also doesn't fit the workflow of every other component. Want to replace a sphere collider with a capsule collider? You remove the sphere, then add a capsule collider with the inspector.

    It doesn't seem to repopulate values in scripts totally.

    Yup, I use git, but you're still talking about spending 5-10 minutes quitting everything, pulling the scene file, and then restarting Unity. It's not a super long time, but it's a real annoyance. Also, I'm taking into consideration new Unity users who are more likely to not understand how things got messed up, how to fix them, and are 10 times more likely to be using assets that have this "bug."
     
    Kurt-Dekker likes this.
unityunity