• 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 DreamontGames · Jan 03, 2014 at 05:48 AM · c#editorserializationenumpopup

Big Problem Serializing

I Have 2 classes, one extends from Editor and other extends from MonoBehaviour.

And I use first class for setup preferences on second, and all works fine... in play mode.. i already read about Serialize and i used [System.Serializable] or [SerializedField] but any works.. For Example when i press play button mi first "EnumPopup" returns to "0" (or first element)

here my 2 classes:

part of my first class

 using UnityEngine;
     using System.Collections;
     using UnityEditor;
     
     [CustomEditor(typeof(CameraFollower))]
     [System.Serializable]
     public class CameraManager : Editor 
     {
         public float xXmin= -20.56028f;                    // It refers to the minimum position left of the screen to which you want the camera can move.
         public float xXmax = 675.6122f;                    // It refers to the minimum position right of the screen to which you you want the camera can move.
         public float yYmin = -24f;                    // Refers to the minimun height to wich you want the camera can move.
         public float yYmax = -2f;                    // Refers to the maximum height to wich you want the camera can move.
         public ArrayList Exmin = new ArrayList();
         public ArrayList Exmax = new ArrayList();
         public ArrayList Eymin = new ArrayList();
         public ArrayList Eymax = new ArrayList();
     
         public float newXmin;
         public float newXmax;
         public float newYmin;
         public float newYmax;
     
          public enum scriptmode{ Free=0, Basic_Limitations=1, Limits_and_Exceptions=2 }
     
          public scriptmode modebase  ; // = scriptmode.Basic_Limitations;
     
     
          public enum entry{ Down, Up }
     
          public entry exentry; //= entry.Down;
     
     
         void Awake()
         {
             //modebase = new SerializedObject(modebase);
             saveinfo();
         }
         public override void OnInspectorGUI()
         {
             //EditorGUIUtility.LookLikeInspector();
             GUILayout.BeginVertical();
     
              modebase = (scriptmode) EditorGUILayout.EnumPopup("Camera Script Mode",modebase);
             //EditorGUILayout.PropertyField(modebase);
             GUILayout.EndVertical();
 

part of my second class

  using UnityEngine;
             using System.Collections;
             
             
             public class CameraFollower : MonoBehaviour 
             {
                 // ----------------------------- Basic Variables for Basic Function of Script ------------------------------------------------
                 private float playerPosx;           // Float to store X coordinate of the current position of the player.
                 private float playerPosy;           // Float to store Y coordinate of the current position of the player.
                 public Transform player;            // Transform to Refer at Player Position.
                 public float Xmin;                    // It refers to the minimum position left of the screen to which you want the camera can move.
                 public float Xmax;                    // It refers to the minimum position right of the screen to which you you want the camera can move.
                 public float Ymin;                    // Refers to the minimun height to wich you want the camera can move.
                 public float Ymax;                    // Refers to the maximum height to wich you want the camera can move.
                 public bool result;                // Bool for result of this function.
                 public int mode =0;                    // Follower Mode 0 = Free Follow || 1 = Basic Limitations || 2.- Limitations whit exceptons enabled
                 // -------------------------- Variables for Manage Exceptions ----------------------------------------------------
             
                 public float[,] excords;
                 public bool actiexcept=false;
             
                 void Awake ()
                 {
                     player = GameObject.FindGameObjectWithTag("Player").transform;
                 }
             
                 void FixedUpdate ()
                 {
                     if (mode == 0)
                     {
                         transform.position = new Vector3(playerPosx, playerPosy, transform.position.z);
                         //Debug.Log("Mode Free");
                     }
         
     
 

Some ideas? thanks for help.

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 Hamdullahshah · Jan 03, 2014 at 06:50 AM 0
Share

add "[ExecuteInEdit$$anonymous$$ode]" to CameraFollower

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

18 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

Related Questions

Instantiating Prefabs through Editor Script 1 Answer

Help with Missing Monobehaviours and Asset Serialization? 0 Answers

CustomPreview example? 1 Answer

How can an editor script know when another script was removed from the project? 1 Answer

Internal Compiler Error trying to use NSubstitute 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