Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Trendsetter123 · Jun 15, 2019 at 03:44 PM · serializationloadsave datatoggle button

Using save options to create saves for toggle buttons, but won't compile!

hey everybody, I read a bit about how Serialization works, and have tried every path to saving toggle states from scene to scene, (new toggles per scene, but when going back to the old scenes it deletes). I had to make a file, where it is calling the Editor. Now I can't figure out how to do this. I read it online, so dont judge to hard.

The errors are all directives errors. which include "Editor, CustomEditorAttribute, CustomEditor, SerializedProperty", saying the type or namespace (name) could not be found.

There is one error that is linked to an override method, it is for overriding the controls to save from scene to scene. It reads ECAAnimRecorderEditor.OnInspectorGUI() : no suitable method to override.

Here is the code

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using System.IO;
 using System.Runtime.Serialization;
 [CustomEditor(typeof(ECAAnimRecorder))]
 public class ECAAnimRecorderEditor : Editor
 {
     private ECAAnimRecorderEditor ecaRecorder;
     public SerializedProperty propAutoSave;
 
     void OnEnable()
     {
         propAutoSave = serializedObject.FindProperty("file");
     }
 
     public override void OnInspectorGUI()
     {
         evaRecorder = ((ECAAnimRecorder)this.target);
         serializedObject.Update();
         EditorGUILayout.PropertyField(propAutoSave, new GUIContent("Auto Save"));
     }
 }




and code for button bool im trying to retrieve ( im trying to set up an array after to save and load all values at once)

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 using System.IO;
 using System.Runtime.Serialization;
 [System.Serializable]
 public class ECAAnimRecorder : MonoBehaviour
 {
     public AudioSource audio;
     public string clip;
     public AudioClip a;
     public bool file;
 
     
     public void OnChangeValue()
 
     {
        bool onoffSwitch = gameObject.GetComponent<Toggle>().isOn;
 
         if (onoffSwitch)
         {
 
             AudioSource audio = gameObject.AddComponent<AudioSource>();
             AudioClip a = Resources.Load(clip) as AudioClip;
             audio.PlayOneShot(a);
             bool file = true;
 
         }
         else
 
             bool file = false;
 
 
 
 
 
     }
   
 
 
   
 
         
 
 
 }



If anybody understands saving toggles with serialization. Anyone at all, please help.

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

Answer by Trendsetter123 · Jun 15, 2019 at 04:42 PM

now I am getting an error saying "Cannot implicitly convert type "ECAAnimRecorder" to "ECAAnimRecorderEditor".. here is my updated code. it happens at (20,24), which is where ecaRecorder = ((ECAAnimRecorder)this.target);

ECAAnimRecorderEditor

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using System.IO;
 using System.Runtime.Serialization;
 using UnityEditor;
 [CustomEditor(typeof(ECAAnimRecorder))]
 public class ECAAnimRecorderEditor : Editor
 {
     private ECAAnimRecorderEditor ecaRecorder;
     public SerializedProperty propAutoSave;
 
     void OnEnable()
     {
         propAutoSave = serializedObject.FindProperty("file");
     }
 
     public override void OnInspectorGUI()
     {
         ecaRecorder = ((ECAAnimRecorder)this.target);
         serializedObject.Update();
         EditorGUILayout.PropertyField(propAutoSave, new GUIContent("Auto Save"));
     }
 }


ECAAnimRecorder

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 using System.IO;
 using System.Runtime.Serialization;
 [System.Serializable]
 public class ECAAnimRecorder : MonoBehaviour
 {
     public AudioSource audio;
     public string clip;
     public AudioClip a;
     public bool file;
 
     
     public void OnChangeValue()
 
     {
        bool onoffSwitch = gameObject.GetComponent<Toggle>().isOn;
 
         if (onoffSwitch)
         {
 
             AudioSource audio = gameObject.AddComponent<AudioSource>();
             AudioClip a = Resources.Load(clip) as AudioClip;
             audio.PlayOneShot(a);
             file = true;
 
         }
         else
 
             file = false;
 
 
 
 
 
     }
   
 
 
   
 
         
 
 
 }
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

110 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

Related Questions

Saving system tutorial / Load through main menu 1 Answer

Proper way to save Terrain for save game feature? 1 Answer

Save and load serialization problem 0 Answers

Add an array to a class that has been Serialized with BinaryFormatter 1 Answer

Error when loading saved date : SerializationException: End of Stream encountered before parsing was completed. 2 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