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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

What's the matter with your Prefab Editor?

Discussion in 'General Discussion' started by JGameMaker92, Sep 23, 2022.

Thread Status:
Not open for further replies.
  1. JGameMaker92

    JGameMaker92

    Joined:
    Oct 15, 2014
    Posts:
    85
    I'm sorry my missing scripts are offending you so much, but does this really must mean that we continue to halt development until all of these red errors are satisfied and dealt with? Why wouldn't they just let me save and come back later and deal with it? Maybe it's not the only thing in my project. It must be something truly awful if it can't continue to function without my input. To tell me that saving is straight up "not allowed"???!
    and continue to trap me here within the Prefab Edit Mode until I get this figured out? I feel like I'm being held hostage by the Prefab Editor.




    Screen Shot 2022-09-23 at 4.05.14 AM.png

    Screen Shot 2022-09-23 at 3.41.30 AM.png
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,196
    Yep.

    I wonder how you work with code? I mean you can't just tell the compiler "ignore this syntax error I'll fix it later" and it'll be like "Ah, okay. I'll just make an educated guess.".
     
  3. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,594
    Fix the missing script. Or remove it from prefab.
     
  4. JGameMaker92

    JGameMaker92

    Joined:
    Oct 15, 2014
    Posts:
    85
    The prefab should still be able to be saved even with errors.. because sometimes you can’t even get them all at once. And if the prefab isn’t even in the scene then you should still be able to press Play. It’s just being an unnecessary pain.
     
  5. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,337
    Can't exactly be done, because classes attached to the prefab determine what data should be saved. The variables you serialize are determined by the attached scripts. No scripts, no variables.
     
  6. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,802
    This is literally never how Unity has worked. If you have compile errors in a script you're not using you can't hit play either. Just fix your prefabs.
     
  7. DragonCoder

    DragonCoder

    Joined:
    Jul 3, 2015
    Posts:
    1,493
    Think Unity actually gives you a chance here to restore the editor-set variables of those scripts that are missing. When you manage to fix the issue, they are restored from memory somewhere "sometimes".
    Of course they could alternatively just kick out / disable the invalid scripts with a warning, but well, they decided against that.

    Btw. do we need a "Venting about Unity" thread for cases like those? :D
     
  8. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,519
    Because that would be highly likely to lose data, regularly.

    Stuff which is marked "Missing" still has data attached to it which was saved before it went missing. That data can no longer be worked with because the metadata (which is a part of the compiled code) isn't there to know how to serialize it again. In other words, if it did let you save then anything "missing" would probably deleted, reset to a default / empty state, or corrupted.

    Compile errors are everyday mistakes, so it'd be really bad if Unity didn't prevent them from losing serialised data. And that error needs to be fixed anyway. So it makes a lot of sense to get you to either fix the error now (usually only takes a few seconds once you're in the swing of things) so you can continue working with the existing data, or explicitly delete the component (indicating that it's "missing" because you didn't want it anyway).
     
    DragonCoder likes this.
  9. JGameMaker92

    JGameMaker92

    Joined:
    Oct 15, 2014
    Posts:
    85
    No, rule number one of programming is you don’t interrupt the navigator from where they’re trying to go. It’s putting the creative process in a colossal arm lock until problems get fixed and it’s also slowing down process. Most of the time the error occurs from trying to import things from one project into another and I can’t fix any of them if it won’t let me out of the Prefab Editor to see my project as a whole. I wouldn’t be so quick to make excuses for their bad logic. They designed it that way on purpose, but it’s making things more of a struggle

     
  10. JGameMaker92

    JGameMaker92

    Joined:
    Oct 15, 2014
    Posts:
    85
    Absolutely! They need better threads on here. I’m sure people have LOTS to complain about.
     
  11. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    6,015
    If someone is about navigate themselves off a cliff, one would imagine you try to stop them.

    Plenty of good reasons why it is the way it is have been explained. Some rambling rhetoric doesn't really override that.

    Just remove the component or assign it the correct script asset and move on.
     
    lmbarns, ontrigger, Ryiah and 4 others like this.
  12. JGameMaker92

    JGameMaker92

    Joined:
    Oct 15, 2014
    Posts:
    85
    It’s never just one component and you know that. It’s a big tangled mess of interconnected assets, if your project ever gets anywhere off the ground. Being stuck in the Prefab Editor isn’t helping anyone. There could still be ways of solving the errors without locking the users inside of the Prefab Editor interface without being able to save! What if I fixed a few of the errors and want to save the prefab and come back later and fix the rest? It doesn’t let me. Also this is a forum so these are the things we talk about.

     
  13. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,886
    Thing is nobody else really complains about this because its a trivial issue to solve. Just fix your problems instead of ranting and arguing here
     
    Ryiah likes this.
  14. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    6,015
    I don't know that, sorry. I've never even encountered this functionality of the editor, and I seldom if ever have missing script issues.

    It honestly sounds like your project could do with some better organisation.

    Also why do you are you putting quotes after your responses?
     
    Ryiah likes this.
  15. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    763
    Why do you have so many missing script and compilation errors anyway?
     
  16. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,337
    Not really.
    The number 1 rule is to give navigator enough tools to prevent himself from doing something stupid.
    There's a reason why strongly typed languages exist, and why you can't directly assign a string to an int in C#.

    That sounds like a fundamental design problem in this particular project, to be honest.

    Also, as a rule of the thumb, in unity project you never work on prefabs while there are still compile errors.

    Also the reason why you can't hit play with compile errors is because C# is not an interpreted language. For the game to run, it has to build a library or a dll. And a dll cannot be built when there are compile errors.
     
  17. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,519
    It is not. It is also not a rule of interactive design, or design in general. To the contrary, thoughtful constraints are often considered to be highly effective design, and a lack of them is often confusing or error prone.

    Script errors don't require you to leave the prefab editor. You need to fix the code, which is typically in a separate application, e.g. Visual Studio.

    If you solve them when they appear then you won't reach this point.

    You mentioned importing stuff, so suggestion number one there is to make sure it compiles in the target Unity version before you import it with other stuff. Only after everything works individually do you add one more at a time, fixing each integration compile error as you go.

    Number two is that if there really are a huge number of compile errors, I'd be reconsidering what's going on and solving the underlying cause. We've no info on the cause, so can't suggest where to start with that. For example, if the packages do work individually, what is causing incompatibilities when integrated?

    In any case, the Prefab Editor issues are a symptom. The problem is broader, and you need to address the cause. Even if you could change things as you desire, it'd just blow up more somewhere else.
     
    Ryiah likes this.
  18. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    if you want to work fast and not get hung up on details like this, try visual scripting. It's more user friendly.
     
  19. JGameMaker92

    JGameMaker92

    Joined:
    Oct 15, 2014
    Posts:
    85
    Maybe this is a complex user case that many of you haven’t had a chance to run into yet, and I’m sorry I haven’t done the best job of explaining the full situation yet, but when trying to import your prefabs from other projects into a new project where you are often missing a large amount of dependent files, this makes it a world of pain. Obviously I’m not denying that compiler errors need to be dealt with, what I’m saying is that it would be much easier if it didn’t trap me in the Prefab Editor until they get sorted out.
     
  20. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,185
    Doubtful, but if it is the case that there is a problem you need to (a) determine the steps that cause the problem to appear, and (b) submit a bug report with that information. Creating multiple threads saying how you believe things should be is not going to solve your problems.
     
  21. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,802
    This is not a complex use case at all, you're just refusing to listen to what anyone has told you.
     
  22. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,185
    Quoting this again to report that I tried to replicate the problem you're having and I'm not able to do so. I created a new project in Unity 2021.3, created a GameObject with a script on it, created a prefab out of it, opened the prefab editor, and deleted the script. It showed the missing message on the GO. I was able to exit the prefab editor.
     
  23. JGameMaker92

    JGameMaker92

    Joined:
    Oct 15, 2014
    Posts:
    85
    Here’s the best quality gif I was able to fit in here of the problem. Basically I have to exit out of the editor in order to be able to get out of Prefab Editor mode once I start editing a prefab with missing scripts. I’m not trying to even do anything that complicated I just want to get out of prefab mode. It won’t let me save and the only way out of it is to discard changes

    2C0F7C96-ADAD-4DDB-ABA5-C31168DF79D1.gif
     
  24. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,185
    Okay, with the demonstration I was able to replicate the error message, but I'm able to exit prefab mode just fine by clicking "Discard Changes".

    If you want to exit prefab mode and save any changes you can create a new script and drag it into the field that says "missing" for each of these scripts. Just be aware like everyone else has said you will lose any non-default changes you made to those Inspectors.
     
  25. JGameMaker92

    JGameMaker92

    Joined:
    Oct 15, 2014
    Posts:
    85
    That’s what I’m saying. This is why it’s so frustrating. Imagine you have multiple prefabs that require a lot of complex fixes but you can’t even switch to the different prefabs without losing the fixes you’ve already applied. Now imagine it takes you all night to work on it and you can’t even save it
     
  26. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,185
    Sorry, but I can't imagine it because the error is happening as soon as I make any adjustments to the prefab while autosave is enabled and in the very rare event that I disable autosave I'm constantly saving manually. If I need to make lengthy adjustments to a prefab I will perform at least one intermediary check-in to version control too.
     
  27. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    you migrated a bunch of stuff, got messages about dependency problems, ignored that, didn't test anything, and then made hours worth of edits before trying to save?
     
  28. JGameMaker92

    JGameMaker92

    Joined:
    Oct 15, 2014
    Posts:
    85
    I am trying to migrate several prefabs that I have working in a different project into a new project, such as my player controller and multiplayer network setup. It’s pretty complex and all tied together. I am saying I’m not able to get very far because the Prefab Editor is locking me in there until I fix dependency issues on one prefab. The specific problem here is the Prefab Editor not allowing me to save after making changes because there is still a few missing scripts, which I mean it takes time to figure out all the scripts I need and to get them into the new project.

    Copying things between different Unity projects is a whole another difficult topic in itself and that’s why I put it in a different thread. And yes it should be much simpler.
    https://forum.unity.com/threads/cop...iple-instances-of-unity.1341197/#post-8469743
     
    Last edited: Sep 27, 2022
  29. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,185
    How are you trying to migrate them?
     
  30. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,802
    When you write tightly coupled code, you lose the ability to easily move it between projects. This is not a Unity problem, this is an architecture problem on your end...

    ...which leads to things like this. You need to fix your prefabs and you also need to account for manageable code yourself. Unity isn't going to be a silver bullet, nor is it the problem here. The problem is that you've made a codebase that is going to be inherently difficult to work with.
     
    Ryiah likes this.
  31. JGameMaker92

    JGameMaker92

    Joined:
    Oct 15, 2014
    Posts:
    85
    It’s a really difficult process. Especially when your project gets complex. That’s why I made a whole another thread trying to suggest ideas that would make migration between projects easier. But I wanted to keep this thread about the specific Prefab Editor issue because it is problematic in some scenarios and I’m sharing my scenario.
     
  32. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,185
    That's just it. It's only a difficult process if you architected your project to be that way.
     
  33. JGameMaker92

    JGameMaker92

    Joined:
    Oct 15, 2014
    Posts:
    85
    I’m not going to stop myself from trying to do something ambitious with Unity. The Prefab Editor issue is a general use case that anybody who tries to do what I did could have problems with it too. Yes, the main part of the problem could have been just from trying to move things into a new project. Honestly, maybe it would have just been easier to just keep everything within project it was already in to avoid migration issues altogether. I still think Unity needs improvement and those things need to be voiced.
     
  34. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,185
    There is no one in this thread saying that you shouldn't make something ambitious. It's just important to understand that such a project requires you to approach it differently than you would a project that is intended to be simple.

    For ideas on how you can approach a large project I recommend reading up on enterprise software development as the techniques and practices they employ are designed to painlessly transition code between projects.
     
    Last edited: Sep 27, 2022
  35. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,802
    Which one is it? You can't have it both ways.

    This isn't a problem with the prefab editor, this is a problem with how you have structured your projects without considering code maintenance and portability.
     
  36. JGameMaker92

    JGameMaker92

    Joined:
    Oct 15, 2014
    Posts:
    85
    I would need some kind of link to be able to find what you’re talking about but I think it’s something Unity developers could make easier on us. Large project migrations get messy.


    There IS a problem with the Prefab Editor. Putting my specific use case aside you can see it fundamentally doesn’t allow prefab saving if there is any missing scripts on a prefab and you are basically stuck inside the Prefab Editor until it gets resolved. You can’t access any other part of your Hierarchy or Scene View. And if you don’t have time to get it all fixed at once you have no ability to save the fixes that you’ve already made.
     
  37. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,185
    Last edited: Sep 27, 2022
  38. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,802
    This has literally already been covered.

     
  39. JGameMaker92

    JGameMaker92

    Joined:
    Oct 15, 2014
    Posts:
    85
    So if you’re being given the options of not being able to save or to discard all changes.. what exactly is being accomplished? You either have to satisfy every error before ever being able to leave the Prefab Editor again or it puts you right back to where you were when you started
     
  40. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,802
    Yeah, because "where you were started" was the last known valid entry/exit point. The errors are there because they need to be resolved. That's why they're errors and not warnings. You are locked into the current prefab state until they're fixed because otherwise you can ship with non-functional prefabs and sometimes code, which the engine is trying to make sure does not happen.

    Just like how a project doesn't compile with errors, prefabs will not save with them. This is literally why I said this:

     
    neginfinity likes this.
  41. JGameMaker92

    JGameMaker92

    Joined:
    Oct 15, 2014
    Posts:
    85
    It’s a design flaw. It doesn’t even let you access your other prefabs or see the rest of your project. These errors could be fixed in a manner without trapping the user in this Prefab Editor window. They’re still valid issues and they should still be fixed, and obviously we’re not shipping games with compiler errors. Honestly though.. a few missing scripts shouldn’t cause such a fuss, they could be just be yellow warnings instead of red errors. Restricting me from being able to see other parts of my project is kinda what irritates me the most.
     
  42. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,185
    No. Unity's editor functions off of serialization and you can't serialize anything if you don't have the class definition from the script. Trying to save the prefab without it is impossible.
     
    Last edited: Sep 27, 2022
  43. JGameMaker92

    JGameMaker92

    Joined:
    Oct 15, 2014
    Posts:
    85
    But it’s not hurting anything if it’s not even there doing anything. It’s just a missing reference that requires so much manual time to fix. I don’t see why it’s holding up the whole Prefab Editor
     
  44. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,185
    It's holding it up because no one who understands how the editor works would want it to do otherwise.
     
  45. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,802
    It's not a flaw at all, it is the same thing as not being able to enter play mode if you have a script with compiler errors even when it's not in use.

    It does if you discard the changes that cause the problem.

    Yes, because the editor doesn't let you.

    No, they should be errors because it means that the prefabs are not going to be able to properly function.

    Yeah, well, suck it up, buttercup. You have been repeatedly told what the problem is, how to fix it, and how to avoid it in the future. In all of these explanations, you have also been told how this isn't the fault of Unity but the fault of how you have architected your project and how you are trying to force the editor to do things that it isn't meant to do or even remotely designed to do.

    You are being inconvenienced because you refuse to use the editor as intended, and that is in no way the editor's fault.
     
  46. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,337
    It is by design.
    -----
    Prefab depend on serialization.
    Serialization depends on code.
    ALL code has to be compiled.
    Therefore ALL code has to be valid.

    Nobody is trying to stop you from doing something ambitious, people suggest that there are certainly better ways to approach it, likely structuring your code better.

    Generally moving a controller from one project to another should not be a huge problem, and even if it somehow is, then you can just clone the whole project via version control as a new one, then remove things you don't need till you get the bare-bones template.

    "It is all interconnected to the point where I end up with errors in prefab editor" is not a common scenario at all.

    Speaking of which, you ARE using version control, right?
     
  47. JGameMaker92

    JGameMaker92

    Joined:
    Oct 15, 2014
    Posts:
    85
    Some people can’t see passed the way things have always been done. I would welcome other people’s input or frustrations with the Prefab Editor. I can’t be the only one annoyed by it. I’d hope that we could imagine things running more smoothly than the way they currently are.
     
  48. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,185
    On the contrary we're very critical here on these forums thanks to the mistakes that they've done in the past but this isn't one of them. We're also not just "some". We've all been saying you're misunderstanding how and why it works the way it does.

    No. You don't welcome our input. You've repeatedly told all of us that we're incorrect. What you've been wanting this entire time is for everyone to agree with you. We're not going to agree with you though for the simple reason that you're not correct.
     
    Last edited: Sep 27, 2022
  49. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,802
    You can't be the only one annoyed by it? Buddy, there are a billion threads on this forum that are about people being annoyed by things that Unity does and the people in this thread have started a LOT of them. The issue here is that you absolutely refuse to see that this is a pebkac issue.
     
    Ryiah likes this.
  50. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,337
    No, that's not what this is about.

    The situation is like this:
    You're using the wrong end of a hammer and keep insisting that you know what you're doing. Despite anything people tell you.

    The best scenario in your case would be to break down your problems into manageable pieces and ask people for advice. For example, "how do I decouple class X from Y". "How can I port player controller onto a new project".

    At the moment it seems that your project's codebase is a huge mess. That is fine. Everybody wrote a huge mess before. The thing is you're supposed to learn how to fix it and make it manageable, and not assume "this is just how it always is", because that's just not true, and that's not how it is "supposed" to be.

    Alternatively you could try to seek someone to train you in using unity and C# programming.

    The point is to improve your skill, and not get stuck blaming the tool. And to improve your skill, you have to learn the tool properly.
     
    Ryiah likes this.
Thread Status:
Not open for further replies.