Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Lvl1Lasagna · Jun 12, 2021 at 03:32 AM · editoreditor-scriptingeditorwindowcompilercompiler error

Is it possible to get Unity to compile specific scripts even if it can't compile the entire project because of errors.

I've been doing a lot of experimentation with different ways to create a custom event system and the one I am currently on is definitely the most promising if I can just get this last bit to work.

I have a custom editor script that allows you to create and manage events. Adding an event here creates a scriptable object that just holds the name of the event. alt text alt text

I'm using scriptable objects here so that theoretically two people could be working at the same time on different machines and create totally different events. They could then merge what they were working on and receive no problems from the event manager here because it parses through the scriptable objects and generates the initial list based on those when the custom editor window is opened. Whereas otherwise, they would be editing the same file and causing merge conflicts.


When that editor window saves from an auto-save or the save button, all the scriptable objects are parsed and a C# file is generated/updated that is just filled with those event names as constant event IDs.

 public static class EventIDList
 {
     public const string Aim = "Aim";
     public const string AimLook = "AimLook";
     public const string AimLookVertical = "AimLookVertical";
     public const string Attack = "Attack";
     public const string Jump = "Jump";
     public const string Movement = "Movement";
     public const string Sprint = "Sprint";
     public const string Zoom = "Zoom";
 }

This file is ignored in the version control for the reason I talked about above about preventing merge conflicts. This file is meant to be generated by the event manager from those scriptable objects. However, if after pulling from another machine I realized that the script I had wrote to actually create this file was not being executed.

 [InitializeOnLoad]
 public static class InitializeEventList
 {
     static InitializeEventList()
     {
         CreateFile();
     }
     public void CreateFile() { ... }
 }

Apparently if a Unity project has compiler errors before it is launched it won't run these InitializeOnLoad scripts. The compiler errors are because many scripts are referencing the EventIDList script but that file hasn't been generated yet because of the compiler errors (bit of a cyclic problem).


So in theory, if I could get unity to compile specific files even if it can't compile the entire project, I could get it to compile the necessary scripts to generate the file. Then after the file is generated all other compiler errors would go away.

capture.png (22.3 kB)
capture.png (8.7 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Lvl1Lasagna · Jun 12, 2021 at 05:12 AM

I posted this on reddit as well and it was solved over there by u/SilentSin26 using Assembly Definition Files. https://www.reddit.com/r/Unity3D/comments/nxxqa0/is_it_possible_to_have_unity_compile_some_files/h1hfg0y/?context=3

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

212 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to make my scene object reference survive the button play 1 Answer

Editor Int sliders affecting each other 0 Answers

How do I allow users to resize columns in custom editor windows? 0 Answers

How to Undo a bool on an EditorWindow 1 Answer

Unity Android Build Publishing Settings are not saved When changed with Preset or by script 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges