- Home /
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.
add "[ExecuteInEdit$$anonymous$$ode]" to CameraFollower
Your answer
 
 
             Follow this Question
Related Questions
Instantiating Prefabs through Editor Script 1 Answer
CustomEditor for 2 List to look like dictionary 1 Answer
Updating object on inspector value changes in editor 1 Answer
How to Draw in Scene View "unconditionally"? 0 Answers
How do I make child classes in a list editable from the Inspector? 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                