HELP PLEASE FASTER!!!

My code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using Photon.Pun;
using System.IO;
using System;

public class RoomManager : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        if (instance)
        {
            Destroy(gameObject);
            return;
        }
        DontDestroyOnLoad(gameObject);
        instance = this;
       
    }

    public override void OnEnable(1)
    {
        base.OnEnable(1);
        SceneManagement.sceneLoaded += OnSceneLoaded;
    }

    private void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
    {
        if(scene.buildIndex == 1)
        {
            PhotonNetwork.Instantiate(Path.Combine("PhotonPrefabs","PlayerManager"), Vector3.zero, Quaternion, identity);
        }
    }

    public override void OnDisable(0)
    {
        base.OnDisable(0);
    }
}

And give error in console:
Assets\Scripts\RoomManager.cs(24,35): error CS1001: Identifier expected
Assets\Scripts\RoomManager.cs(38,36): error CS1001: Identifier expected

PLEASE HELP FASTER!!!

It tells you Line 24, Column 35 and Line 38, Column 36.

Why are you putting in a “0” or “1” when defining methods? That’s not valid C#. You’re also not overriding anything so you don’t need to specify that nor do you need to call the base.

1 Like

Sorry but its my error(I tried to do this)
My code now:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using Photon.Pun;
using System.IO;
using System;

public class RoomManager : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        if (instance)
        {
            Destroy(gameObject);
            return;
        }
        DontDestroyOnLoad(gameObject);
        instance = this;
      
    }

    public override void OnEnable()
    {
        base.OnEnable();
        SceneManagement.sceneLoaded += OnSceneLoaded;
    }

    private void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
    {
        if(scene.buildIndex == 1)
        {
            PhotonNetwork.Instantiate(Path.Combine("PhotonPrefabs","PlayerManager"), Vector3.zero, Quaternion, identity);
        }
    }

    public override void OnDisable()
    {
        base.OnDisable();
    }
}

Errors:
Assets\Scripts\RoomManager.cs(24,26): error CS0115: ‘RoomManager.OnEnable()’: no suitable method found to override
Assets\Scripts\RoomManager.cs(38,26): error CS0115: ‘RoomManager.OnDisable()’: no suitable method found to override

Stop stabbing in the dark… read the documentation
You dont need to override them

Which is why I said the following:

In the very least, read the replies please.

Thanks.

1 Like

Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using Photon.Pun;
using System.IO;
using System;

public class RoomManager : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        if (instance)
        {
            Destroy(gameObject);
            return;
        }
        DontDestroyOnLoad(gameObject);
        instance = this;
       
    }

    public override void OnEnable()
    {
        SceneManagement.sceneLoaded += OnSceneLoaded;
    }

    private void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
    {
        if(scene.buildIndex == 1)
        {
            PhotonNetwork.Instantiate(Path.Combine("PhotonPrefabs","PlayerManager"), Vector3.zero, Quaternion, identity);
        }
    }
}

Error:

Assets\Scripts\RoomManager.cs(24,26): error CS0115: ‘RoomManager.OnEnable()’: no suitable method found to override

You’ve been told three times now that you don’t need to override those methods. Now the compiler is telling you the same.

Please see the code of conduct about low effort posting: https://discussions.unity.com/t/940149

Sorry but i’m newbie in CS codes. Can you give me right code from this code?

You don’t know how to remove the “override” keyword and you want me to copy your code, remove them and paste it for you? That’s not what the forums are for, sorry.

I would recommend using the docs to search how to use them as they mostly give code examples: https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnEnable.html

I’m Deleted override from code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using Photon.Pun;
using System.IO;
using System;

public class RoomManager : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        if (instance)
        {
            Destroy(gameObject);
            return;
        }
        DontDestroyOnLoad(gameObject);
        instance = this;
      
    }

    public void OnEnable()
    {
        SceneManagement.sceneLoaded += OnSceneLoaded;
    }

    private void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
    {
        if(scene.buildIndex == 1)
        {
            PhotonNetwork.Instantiate(Path.Combine("PhotonPrefabs","PlayerManager"), Vector3.zero, Quaternion, identity);
        }
    }
}

Errors:
Assets\Scripts\RoomManager.cs(14,13): error CS0103: The name ‘instance’ does not exist in the current context
Assets\Scripts\RoomManager.cs(20,9): error CS0103: The name ‘instance’ does not exist in the current context
Assets\Scripts\RoomManager.cs(26,9): error CS0103: The name ‘SceneManagement’ does not exist in the current context
Assets\Scripts\RoomManager.cs(33,100): error CS0119: ‘Quaternion’ is a type, which is not valid in the given context
Assets\Scripts\RoomManager.cs(33,112): error CS0103: The name ‘identity’ does not exist in the current context

I’m dumb. Help me.

You’re not dumb but you seem to be guessing at how to write code which isn’t the best approach.

“instance” doesn’t exist in the code as the compiler states. How am I supposed to fix it? I didn’t write this code so I have no idea what it’s supposed to look like. I know you want answers but there is no answer here.

The forums are not here to write code for you. If you copied this code from somewhere such as a tutorial then you’re missing the point of a tutorial which is to teach you something so if that’s the case, please go back to the tutorial and follow it again.

1 Like

You have not defined a class variable called instance, with the level of struggle please find a basic c# tutorial, that explains classes, properties, fields, methods, scope and well, try the learn c# in 24 hours or something book

Note, every error gives you a line number… your first duty is to read the error, look up the error and see how it applies to the line.

I have an instance class in the entire game code

thats not what I said…

I’m Russian I’m Using Translator sorry.

You have no variable called instance
as for SceneManagement, thats because the class is not called that, hence, please read documentation

Search Unity Learn and click on the first link