• 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
1
Question by Pratyu5h · Aug 07, 2018 at 08:22 PM · guibuttonscenescene-changeserializedobject

SerializedObject target has been destroyed. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

As soon as I click on the "Keyboard" button in my scene it takes me to scene(1) and enables MovementKeyboard script as I wanted, but the MovementKeyboard never runs becasue of the error SerializedObject target has been destroyed. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr). I have rebuild all the lightings but still in gives the same error as soon as the scene changes.

Script of button --

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.SceneManagement;
 
 public class ControlKeyboard : MonoBehaviour {
 
     public MovementKeyboard ControlKEYBOARD;
 
     // Use this for initialization
     void Start () {
         
     }
     
     // Update is called once per frame
     void Update () {
         
     }
 
     public void ButtonKeyboard()
     {
         ControlKEYBOARD = ControlKEYBOARD.GetComponent<MovementKeyboard>();
         ControlKEYBOARD.enabled = true;
 
         SceneManager.LoadScene(1);
     }
 }
 


MovementKeyboard Script attached to player-

 public class MovementKeyboard : MonoBehaviour {
 
     public Rigidbody rbKeyboard;
     public float SidewaysForceKeyboard = 500f;
     public float ForwardForceKeyboard = 8000f;
     // Use this for initialization
     void Start () {
         
     }
     
     // Update is called once per frame
     void FixedUpdate ()
     {
         //Forward Movement
         rbKeyboard.AddForce(0, 0, ForwardForceKeyboard * Time.deltaTime);
 
         //right movement
         if (Input.GetKey("d"))
         {
             rbKeyboard.AddForce(SidewaysForceKeyboard * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
         }
 
         //Left Movement
         if (Input.GetKey("a"))
         {
             rbKeyboard.AddForce(-SidewaysForceKeyboard * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
         }
     }
 }


Please help me out. Thankyou I have also attached the screenshots of the editor before and after clicking the button.alt text

alt text

1.png (209.5 kB)
2.png (191.7 kB)
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

7 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by khooroko · Aug 10, 2018 at 01:30 AM

You may have enabled the MovementKeyboard in the original scene before loading scene(1), and when you load a scene normally all the objects in the previous scene are destroyed. Take a look at https://docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html. I think you just need to add that one line to the MovementKeyboard script (or any other script you attach to the player).

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
avatar image
0

Answer by jonc113 · Oct 05, 2018 at 12:55 AM

I had this error. I deleted my Library folder and let the game rebuild it. Problem went away.

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 umangindianic · Apr 23, 2019 at 06:35 AM 0
Share

It really works for me.

avatar image
5

Answer by nathanwick · Dec 27, 2018 at 10:20 PM

I had the same problem. It's an editor error. I closed the editor and reopened it. Then everything was normal again.

Comment
Add comment · Show 2 · 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 Jacobsc · Jan 12, 2020 at 09:06 PM 0
Share

I have tried this many times, nothing happens

avatar image mokhabadi · Mar 16, 2020 at 09:59 AM 0
Share

in my case, this error comes from nowhere and gone after this classic general-purpose solution! thanks!

avatar image
0

Answer by renren30 · Apr 21, 2020 at 10:56 AM

For me the NavMeshAgent caused the problem. If the "Stopping Distance" was set to 0 Unity showed this error. After i set it to 0.1 it worked without error.

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
avatar image
1

Answer by Sackstand · Jun 18, 2020 at 07:26 AM

sorry for Necro this Thread.

I had the same problem and a restart from Unity helps. But from time to time it came back. After a lot of testing around i found my problem. I use a wireless Keyboard and Mouse. every time when i get out of range or getting close to it the input delay raises and unity start to throw this error. even when i get back in range. only a restart will help until you lose connection again.

maybe this info will help someone.

testet with Unity 2019.3.14.f1

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
  • 1
  • 2
  • ›

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

200 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 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

How to get Rect from scene Button ? 1 Answer

Using UI.Button to Load Another Scene? (using outdated tutorial video) 1 Answer

making and integrating Visual novel element in 3d game? 2 Answers

load level with gui button nested in a toggled window!!! 0 Answers

Change to scene based on current scene 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges