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 sumeetkhobare · Jun 14, 2015 at 11:39 PM · unityeditoreditorwindoweditorgui

Changed data through EditorWindow isn't persistent.

Hello,

I am using a custom script to show an EditorWindow which will display the data of one script attached to GameObjects.

 using UnityEngine;
 using UnityEditor;
 using System.Collections;
 
 public class ShowLevelData : EditorWindow {
 
     private GameObject go;
     private Level level;
     // Add menu named "My Window" to the Window menu
     [MenuItem ("Window/Show Level Data")]
     static void Init () {
         // Get existing open window or if none, make a new one:
         ShowLevelData window = (ShowLevelData)EditorWindow.GetWindow (typeof (ShowLevelData));
         window.position = new Rect(150,150,113,149);
         window.minSize = new Vector2(113,149);
         window.ShowPopup();
     }
 
     void OnSelectionChange(){
         go = Selection.activeGameObject;
         level = go.GetComponent<Level>();
         Repaint();
     }
 
     void OnGUI () {
         if(level){
             level.level = EditorGUILayout.IntField("Level Number",level.level);
             EditorGUILayout.BeginVertical ();
             EditorGUILayout.LabelField("1  2  3  4  5  6  7");
             for(int i = 0;i<7;i++)
             {
                 EditorGUILayout.BeginHorizontal();
                 for(int j=0;j<7;j++)
                 {
                     level.levelData[i,j] = EditorGUILayout.Toggle (level.levelData[i,j]);
                 }
                 EditorGUILayout.LabelField(""+i);
                 EditorGUILayout.EndHorizontal();
             }
             EditorGUILayout.EndVertical();
         }
     }
 }
 

This script shows a two-dimensional array in my other script 'Level' attached to a GameObject in my scene. There are multiple objects with this script attached to them. So whenever I select them and have this window open, I can see the two dimensional array.alt text

The changes I make to this is present as far as I don't close Unity. Once I close Unity and restart, its gone. Same is for any other property of the script I change,(for example, the level number).

I can see it updated in the inspector once I change it, but even if I save the scene, the changes don't stay if I close Unity.

Does any one know how to fix this?

capture.png (5.2 kB)
Comment
Add comment · Show 1
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 sumeetkhobare · Jun 16, 2015 at 07:11 PM 0
Share

can anyone answer this?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Jun 16, 2015 at 08:16 PM

Well, your "levelData" array seems to be a multidimensional array. However the Unity serializer doesn't support those. If you want this data to be saved, use structures / types which are supported or save it on your own into a file.

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

22 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

Related Questions

Can't See all content of Editor 0 Answers

How do I draw curves in a custom editor window? 1 Answer

SearchableEditorWindow 2 Answers

Custom Editor fields listed below script variables 1 Answer

Any way to attach a bit of code to individual UI Windows [Editor] 1 Answer


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