Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by Chaosgod_Esper · Dec 08, 2014 at 08:44 AM · errorbuttoninspectoreditorwindow

Opening a EditorWindow via Inspector == Error?

Hey there..

I´ve created a greater EditorWindow, which should be the AllInOne Editor for 4-5 Scripts of my Scene Setup Object.

So now, every of these 4-5 Scripts will get such an Inspector override attached:

 [CustomEditor(typeof(Sys_Vocab))]
 public class Sys_VocabEditor : Editor 
 {
     public override void OnInspectorGUI()
     {
         if(GUILayout.Button("Open Vocab Editor")){
             File.WriteAllText("crml.dat", (2).ToString());
             EditorWindow.GetWindowWithRect(typeof(Editor_Scene_Setup), new Rect(0, 0, 800, Screen.height));
             GUIUtility.ExitGUI();
         }
     }
 }

This should open the EditorWindow, and show the Script depending Stuff by asking what ID "private int EditorFenster;" is set to.

EditorFenster is set by reading out "crml.dat", which is filled with only the ID integer by the Inspector overrides.

The Problem: If i open the EditorWindow via my Topmenü Setting (GameObject > Create Other > Scene_Setup), everything runs fine! When clicking the Button in the Inspector, i get this: alt text

Any idea what could be wrong here, and how to solve that Error Stuff?

TESTPROJECT TO REPRODUCE THE PROBLEM: link text

Comment
Add comment · Show 7
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
avatar image Chaosgod_Esper · Dec 10, 2014 at 05:59 PM 0
Share

anyone? This Problem is really annoying..

avatar image Vurawid · Dec 11, 2014 at 01:46 AM 0
Share

The error you have highlighted in the screenshot happens on line 285 and is most likely caused by the NullReferenceException error on line 281 of the Editor_Scene_Setup script. Do you know how to debug code using $$anonymous$$onoDevelop?

avatar image Chaosgod_Esper · Dec 11, 2014 at 09:51 AM 0
Share

yes But the object in that line isn't null, cause i'm checking for that in that line..

And the highlighted error doesn't appear when calling the window from GameObject > Create Other > Scene_Setup

Both Errors only appear when calling the Window from the custom Inspectors..

avatar image Klarax · Dec 11, 2014 at 11:17 AM 0
Share

try resetting the window layouts. might have something to do with this. some layouts in unity pop up with errors.

avatar image Chaosgod_Esper · Dec 11, 2014 at 07:00 PM 0
Share

same error with default layout, game layout or any of the other window layouts..

Show more comments

2 Replies

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

Answer by Vurawid · Dec 13, 2014 at 06:33 AM

The error has to do with trying to show the Vocabs section right away in the EditorWindow. It is a simple enough fix. Setup the code to run through OnGUI 2 or 3 times in Editor_Scene_Setup with EditorFenster=0 prior to reading from the crml.dat file. I tested it out and the errors went away in the test project by doing this.

Updated now that I have time to share more details... here are changes I made. Also improved upon the original solution I did.

  • Removed this section of code from OnGUI: if (File.Exists("crml.dat")) { ... }

  • private bool m_IsInitialized = false; private Nullable m_StartingEditorFenster = null; public void SetStartEditorFenster(int editorFenster) { m_IsInitialized = false; m_StartingEditorFenster = editorFenster; }

  • if (m_IsInitialized == true) { if (m_StartingEditorFenster.HasValue) { EditorFenster = m_StartingEditorFenster.Value; m_StartingEditorFenster = null; } } m_IsInitialized = true;

  • Changed the code in Sys_VocabEditor. Note something similar needs to be done for Sys_LanguageEditor...

    public override void OnInspectorGUI() { if(GUILayout.Button("Open Vocab Editor")){ Editor_Scene_Setup thisWindow = (Editor_Scene_Setup)EditorWindow.GetWindowWithRect(typeof(Editor_Scene_Setup), new Rect(0, 0, 800, Screen.height)); thisWindow.SetStartEditorFenster (2); GUIUtility.ExitGUI(); } }

Comment
Add comment · Show 1 · 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
avatar image Chaosgod_Esper · Dec 14, 2014 at 03:41 PM 0
Share

O$$anonymous$$AY...

I managed to get rid of the NullReference..

But the "ArgumentException" Error is still appearing.

avatar image
0

Answer by Chaosgod_Esper · Dec 15, 2014 at 08:01 AM

OKAY

Found a Solution for the ArgumentException Error. I needed to place the File Reader as last step in OnGUI, so OnGUI runs first with EditorFenster as 0, and sets itself via File readout to the new value.

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

28 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

Related Questions

Android Build Error,Android Gradle Build Error 1 Answer

"The name does not exist in the current context" error 1 Answer

HELP! is this a Bug in the game engine? 1 Answer

Use of the inspector along with a custom editorwindow 1 Answer

How do I prevent an error when opening a scene from an EditorWindow? 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