0

I am developing a new game on Unity called HOMEMADE - House Designer. I am new to Unity and C#, so I and started testing some things. Quickly, I learned how to use buttons, toggles and other GameObjects. I developed a really nice menu for my game. I started making the script and making the connections between the functions. I was doing good, everything was working well, music, music volume, the menus... but then I tried to put a click sound on my buttons. I don't know what I did, my C# compiler does not show any errors, and my unity Console just says:

"Unity Cannot reparent window to suggested parent. Window will not automatically close. UnityEditor.EditorGUI:PropertyField (UnityEngine.Rect,UnityEditor.SerializedProperty,UnityEngine.GUIContent)"

I don't know why does it say that, I don't even know WHY it does that. The only thing am I 100% sure of is that my buttons stopped working. I have a Highlighted and a Pressed color for all of them. Both were working, but now they don't. I can't click on the buttons or open the menus, I literally can't do a single thing. I just look for my Main Menu, try to reset Unity and even my PC, but nothing works. I spent 2 weeks working on this project and learning how to use Unity and code in C#. This project is really important to me, I just want it to start working again. Please help me if you have any idea, every ideas are good at this point.

This is my script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using UnityEngine.Audio;

public class HOMEMADE : MonoBehaviour
{
    //assossiations
    [SerializeField] private GameObject CreateNewDesignMenu;
    [SerializeField] private GameObject LoadDesignMenu;
    [SerializeField] private GameObject CreateNew3DModelMenu;
    [SerializeField] private GameObject Load3DModelMenu;
    [SerializeField] private GameObject OptionsMenu;
    [SerializeField] private GameObject ContinueCreateNewDesignMenu;
    [SerializeField] private GameObject ErrorMessageCNDM;
    [SerializeField] private GameObject Mountains;
    [SerializeField] private GameObject Forest;
    [SerializeField] private GameObject City;
    [SerializeField] private GameObject BrickWall;
    [SerializeField] private GameObject Sky;
    [SerializeField] private GameObject Grass;
    [SerializeField] private GameObject Dirt;
    [SerializeField] private GameObject Sand;
    [SerializeField] private GameObject Snow;
    [SerializeField] private GameObject Street;
    [SerializeField] private GameObject Park;
    [SerializeField] private GameObject Dawn;
    [SerializeField] private GameObject Noon;
    [SerializeField] private GameObject Dusk;
    [SerializeField] private GameObject Night;
    [SerializeField] private GameObject FOVSlider;
    [SerializeField] private GameObject MovementSpeedSlider;
    [SerializeField] private GameObject SensitivitySlider;
    [SerializeField] private GameObject ShadingEffectsOn;
    [SerializeField] private GameObject ShadingEffectsOff;
    [SerializeField] private GameObject QuitGameErrorMessage;

    //turn off panels
    public void Start()
    {
        CreateNewDesignMenu.SetActive(false);
        LoadDesignMenu.SetActive(false);
        CreateNew3DModelMenu.SetActive(false);
        Load3DModelMenu.SetActive(false);
        OptionsMenu.SetActive(false);
        QuitGameErrorMessage.SetActive(false);
        //ContinueCreateNewDesignMenu.SetActive(false);
        //ErrorMessageCNDM.SetActive(false);
    }


    // 1.- Create New Design
    public void CreateNewDesign()
    {
        CreateNewDesignMenu.SetActive(true);
        OptionsMenu.SetActive(false);
        QuitGameErrorMessage.SetActive(false);
    }

    public void CloseCreateNewDesign()
    {
        CreateNewDesignMenu.SetActive(false);
    }

    public void GetInputs()
    {

    }

    public void CloseContinueCreateNewDesign()
    {
        ContinueCreateNewDesignMenu.SetActive(false);
    }

    public void CloseErrorMessageCNDM()
    {
        ErrorMessageCNDM.SetActive(false);
    }

    // 2.- Load Design
    public void LoadDesign()
    {
        LoadDesignMenu.SetActive(true);
        OptionsMenu.SetActive(false);
        QuitGameErrorMessage.SetActive(false);
    }

    public void CloseLoadDesign()
    {
        LoadDesignMenu.SetActive(false);
    }


    // 3.- Create New 3D Model
    public void CreateNew3DModel()
    {
        CreateNew3DModelMenu.SetActive(true);
        OptionsMenu.SetActive(false);
        QuitGameErrorMessage.SetActive(false);
    }

    public void CloseCreateNew3DModel()
    {
        CreateNew3DModelMenu.SetActive(false);
    }



    // 4.- Load 3D Model
    public void Load3DModel()
    {
        Load3DModelMenu.SetActive(true);
        OptionsMenu.SetActive(false);
        QuitGameErrorMessage.SetActive(false);
    }

    public void CloseLoad3DModel()
    {
        Load3DModelMenu.SetActive(false);
    }



    // 5.- Options
    public void Options()
    {
        OptionsMenu.SetActive(true);
        QuitGameErrorMessage.SetActive(false);
    }

    public void CloseOptions()
    {
        OptionsMenu.SetActive(false);
    }



    // 6.- Quit Game
    public void QuitGame()
    {
        QuitGameErrorMessage.SetActive(true);
        OptionsMenu.SetActive(false);
    }

    public void QuitGameYes()
    {
        Application.Quit();
    }

    public void QuitGameNo()
    {
        QuitGameErrorMessage.SetActive(false);
    }


    //set volume    

    private GameObject MusicVolumeSlider;

    public void OnMusicValueChange(float newMusicValue)
    {
        GetComponent<AudioSource>().volume = newMusicValue;
        Debug.Log(GetComponent<AudioSource>().volume);
    }
}

I tried to add sound to my Main Menu buttons but it did not work, it just broke my entire script.

  • 1
    It sounds like an error in Unity's inspector. Have you added or created any custom editor scripts? Also, can you please include the full stack trace of the error? – Louis Ingenthron Feb 16 '23 at 19:00
  • As with previous comment, I don't think the error comes from the code you showed us ... – derHugo Feb 16 '23 at 19:04
  • I will try to get the error again and copy paste it here. – CleanLikeIce Feb 16 '23 at 19:07
  • I am not sure but I think I do not have any custom editor scripts. – CleanLikeIce Feb 16 '23 at 19:09
  • Again this is not related to the code you show .. it is possible that this is more a general Unity glitch about trying to apply a certain window layout but maybe a window type is missing etc .. it will most probably disappear if you do [Clean up](https://stackoverflow.com/questions/56267842/cleaning-up-and-migrating-existing-unity-project-into-new-one-or-another-pc) your project (backups!) - you can also just try and delete the Library folder which is where those layouts are stored (among other dynamic created compilations and things) – derHugo Feb 17 '23 at 07:42

0 Answers0