Unity Prefab The name `mainCamera' does not exist in the current context












1















I am getting the error The name mainCamera' does not exist in the current context for the linetargetPos = (Vector2)mainCamera.main.ScreenToWorldPoint(Input.mousePosition);`. I have search for an answer but cannot find a way to stop this.



using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour {

float speed = 2f;
Vector2 targetPos;

private Rigidbody2D myRigidbody;
private Animator myAnim;

private static bool playerExists;
public GameObject cameraPrefab;

private void Start()
{
myRigidbody = GetComponent<Rigidbody2D>();
myAnim = GetComponent<Animator>();

if(!playerExists){
playerExists = true;
DontDestroyOnLoad(transform.gameObject);
} else {
Destroy(gameObject);
}

targetPos = transform.position;

GameObject mainCamera = (GameObject)Instantiate(cameraPrefab);
}

void Update()
{
if (Input.GetMouseButtonDown(0))
{

targetPos = (Vector2)mainCamera.main.ScreenToWorldPoint(Input.mousePosition);
}
if ((Vector2)transform.position != targetPos)
{
Move();
} else {
myAnim.SetBool("PlayerMoving", false);
}
}









share|improve this question

























  • What is in your CameraPrefab? Is there an enabled camera in there? From the feedback on my answer it seems like you don't have a camera in the scene at all.

    – Ruzihm
    Nov 21 '18 at 1:48











  • I have located the problem after you highlight that it has to be an issue with no active camera in the scene. I still cant find why I either get two cameras without the check or none with it.

    – Keith Power
    Nov 21 '18 at 10:36






  • 1





    Update gets called every frame, so on the 2nd frame, no matter how many cameras you actually have at the game start, on the second frame you'll have one camera that gets that update gets called, cameraExists is true, and then that camera gets destroyed. Does cameraPrefab exist in the scene at game start? If so, you don't need to Instantiate it again.

    – Ruzihm
    Nov 21 '18 at 15:03
















1















I am getting the error The name mainCamera' does not exist in the current context for the linetargetPos = (Vector2)mainCamera.main.ScreenToWorldPoint(Input.mousePosition);`. I have search for an answer but cannot find a way to stop this.



using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour {

float speed = 2f;
Vector2 targetPos;

private Rigidbody2D myRigidbody;
private Animator myAnim;

private static bool playerExists;
public GameObject cameraPrefab;

private void Start()
{
myRigidbody = GetComponent<Rigidbody2D>();
myAnim = GetComponent<Animator>();

if(!playerExists){
playerExists = true;
DontDestroyOnLoad(transform.gameObject);
} else {
Destroy(gameObject);
}

targetPos = transform.position;

GameObject mainCamera = (GameObject)Instantiate(cameraPrefab);
}

void Update()
{
if (Input.GetMouseButtonDown(0))
{

targetPos = (Vector2)mainCamera.main.ScreenToWorldPoint(Input.mousePosition);
}
if ((Vector2)transform.position != targetPos)
{
Move();
} else {
myAnim.SetBool("PlayerMoving", false);
}
}









share|improve this question

























  • What is in your CameraPrefab? Is there an enabled camera in there? From the feedback on my answer it seems like you don't have a camera in the scene at all.

    – Ruzihm
    Nov 21 '18 at 1:48











  • I have located the problem after you highlight that it has to be an issue with no active camera in the scene. I still cant find why I either get two cameras without the check or none with it.

    – Keith Power
    Nov 21 '18 at 10:36






  • 1





    Update gets called every frame, so on the 2nd frame, no matter how many cameras you actually have at the game start, on the second frame you'll have one camera that gets that update gets called, cameraExists is true, and then that camera gets destroyed. Does cameraPrefab exist in the scene at game start? If so, you don't need to Instantiate it again.

    – Ruzihm
    Nov 21 '18 at 15:03














1












1








1








I am getting the error The name mainCamera' does not exist in the current context for the linetargetPos = (Vector2)mainCamera.main.ScreenToWorldPoint(Input.mousePosition);`. I have search for an answer but cannot find a way to stop this.



using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour {

float speed = 2f;
Vector2 targetPos;

private Rigidbody2D myRigidbody;
private Animator myAnim;

private static bool playerExists;
public GameObject cameraPrefab;

private void Start()
{
myRigidbody = GetComponent<Rigidbody2D>();
myAnim = GetComponent<Animator>();

if(!playerExists){
playerExists = true;
DontDestroyOnLoad(transform.gameObject);
} else {
Destroy(gameObject);
}

targetPos = transform.position;

GameObject mainCamera = (GameObject)Instantiate(cameraPrefab);
}

void Update()
{
if (Input.GetMouseButtonDown(0))
{

targetPos = (Vector2)mainCamera.main.ScreenToWorldPoint(Input.mousePosition);
}
if ((Vector2)transform.position != targetPos)
{
Move();
} else {
myAnim.SetBool("PlayerMoving", false);
}
}









share|improve this question
















I am getting the error The name mainCamera' does not exist in the current context for the linetargetPos = (Vector2)mainCamera.main.ScreenToWorldPoint(Input.mousePosition);`. I have search for an answer but cannot find a way to stop this.



using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour {

float speed = 2f;
Vector2 targetPos;

private Rigidbody2D myRigidbody;
private Animator myAnim;

private static bool playerExists;
public GameObject cameraPrefab;

private void Start()
{
myRigidbody = GetComponent<Rigidbody2D>();
myAnim = GetComponent<Animator>();

if(!playerExists){
playerExists = true;
DontDestroyOnLoad(transform.gameObject);
} else {
Destroy(gameObject);
}

targetPos = transform.position;

GameObject mainCamera = (GameObject)Instantiate(cameraPrefab);
}

void Update()
{
if (Input.GetMouseButtonDown(0))
{

targetPos = (Vector2)mainCamera.main.ScreenToWorldPoint(Input.mousePosition);
}
if ((Vector2)transform.position != targetPos)
{
Move();
} else {
myAnim.SetBool("PlayerMoving", false);
}
}






c# unity3d






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 15:45







Keith Power

















asked Nov 20 '18 at 23:31









Keith PowerKeith Power

5,171164896




5,171164896













  • What is in your CameraPrefab? Is there an enabled camera in there? From the feedback on my answer it seems like you don't have a camera in the scene at all.

    – Ruzihm
    Nov 21 '18 at 1:48











  • I have located the problem after you highlight that it has to be an issue with no active camera in the scene. I still cant find why I either get two cameras without the check or none with it.

    – Keith Power
    Nov 21 '18 at 10:36






  • 1





    Update gets called every frame, so on the 2nd frame, no matter how many cameras you actually have at the game start, on the second frame you'll have one camera that gets that update gets called, cameraExists is true, and then that camera gets destroyed. Does cameraPrefab exist in the scene at game start? If so, you don't need to Instantiate it again.

    – Ruzihm
    Nov 21 '18 at 15:03



















  • What is in your CameraPrefab? Is there an enabled camera in there? From the feedback on my answer it seems like you don't have a camera in the scene at all.

    – Ruzihm
    Nov 21 '18 at 1:48











  • I have located the problem after you highlight that it has to be an issue with no active camera in the scene. I still cant find why I either get two cameras without the check or none with it.

    – Keith Power
    Nov 21 '18 at 10:36






  • 1





    Update gets called every frame, so on the 2nd frame, no matter how many cameras you actually have at the game start, on the second frame you'll have one camera that gets that update gets called, cameraExists is true, and then that camera gets destroyed. Does cameraPrefab exist in the scene at game start? If so, you don't need to Instantiate it again.

    – Ruzihm
    Nov 21 '18 at 15:03

















What is in your CameraPrefab? Is there an enabled camera in there? From the feedback on my answer it seems like you don't have a camera in the scene at all.

– Ruzihm
Nov 21 '18 at 1:48





What is in your CameraPrefab? Is there an enabled camera in there? From the feedback on my answer it seems like you don't have a camera in the scene at all.

– Ruzihm
Nov 21 '18 at 1:48













I have located the problem after you highlight that it has to be an issue with no active camera in the scene. I still cant find why I either get two cameras without the check or none with it.

– Keith Power
Nov 21 '18 at 10:36





I have located the problem after you highlight that it has to be an issue with no active camera in the scene. I still cant find why I either get two cameras without the check or none with it.

– Keith Power
Nov 21 '18 at 10:36




1




1





Update gets called every frame, so on the 2nd frame, no matter how many cameras you actually have at the game start, on the second frame you'll have one camera that gets that update gets called, cameraExists is true, and then that camera gets destroyed. Does cameraPrefab exist in the scene at game start? If so, you don't need to Instantiate it again.

– Ruzihm
Nov 21 '18 at 15:03





Update gets called every frame, so on the 2nd frame, no matter how many cameras you actually have at the game start, on the second frame you'll have one camera that gets that update gets called, cameraExists is true, and then that camera gets destroyed. Does cameraPrefab exist in the scene at game start? If so, you don't need to Instantiate it again.

– Ruzihm
Nov 21 '18 at 15:03












1 Answer
1






active

oldest

votes


















3














You're getting that particular error because mainCamera is a local variable defined in Start. It is out of scope where you try to reference it in Update. You probably meant to define it as a field in your class, so you could reference it with mainCamera anywhere in your class. To do that you should do this instead:



// ...

private Rigidbody2D myRigidbody;
private Animator myAnim;

private static bool playerExists;
public GameObject cameraPrefab;
public GameObject mainCamera; // add this line

private void Start()
{
myRigidbody = GetComponent<Rigidbody2D>();
myAnim = GetComponent<Animator>();

if(!playerExists){
playerExists = true;
DontDestroyOnLoad(transform.gameObject);
} else {
Destroy(gameObject);
}

targetPos = transform.position;

mainCamera = (GameObject)Instantiate(cameraPrefab); // use mainCamera field
mainCamera.tag = "MainCamera"; // tell Unity that it is your main camera.
}

// ...


But anyway, Camera.main is a static property of the Camera class, so you should access it through the Camera class anyway.



You should use this in Update instead:



targetPos = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition);





share|improve this answer


























  • I was using targetPos = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition); until I made the camera a prefab. Then I was getting Object reference not set to an instance of an object

    – Keith Power
    Nov 20 '18 at 23:45











  • Unfortunatly I now get the error Type UnityEngine.GameObject' does not contain a definition for 'main' and no extension method 'main' of type 'UnityEngine.GameObject' could be found. Are you missing an assembly reference? when I use targetPos = (Vector2)mainCamera.main.ScreenToWorldPoint(Input.mousePosition);

    – Keith Power
    Nov 21 '18 at 0:02













  • That means you don't have a main camera. If mainCamera is actually supposed to be the main camera, and the prefab isn't already set to have "MainCamera" as its tag, then you need to do that in script. I edited my answer to include that in the first code block.

    – Ruzihm
    Nov 21 '18 at 0:04













  • I have update the code but when I run the game I get the message on screen saying No Cameras Rendering using targetPos = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition); No errors in the code showing

    – Keith Power
    Nov 21 '18 at 0:13











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403186%2funity-prefab-the-name-maincamera-does-not-exist-in-the-current-context%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














You're getting that particular error because mainCamera is a local variable defined in Start. It is out of scope where you try to reference it in Update. You probably meant to define it as a field in your class, so you could reference it with mainCamera anywhere in your class. To do that you should do this instead:



// ...

private Rigidbody2D myRigidbody;
private Animator myAnim;

private static bool playerExists;
public GameObject cameraPrefab;
public GameObject mainCamera; // add this line

private void Start()
{
myRigidbody = GetComponent<Rigidbody2D>();
myAnim = GetComponent<Animator>();

if(!playerExists){
playerExists = true;
DontDestroyOnLoad(transform.gameObject);
} else {
Destroy(gameObject);
}

targetPos = transform.position;

mainCamera = (GameObject)Instantiate(cameraPrefab); // use mainCamera field
mainCamera.tag = "MainCamera"; // tell Unity that it is your main camera.
}

// ...


But anyway, Camera.main is a static property of the Camera class, so you should access it through the Camera class anyway.



You should use this in Update instead:



targetPos = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition);





share|improve this answer


























  • I was using targetPos = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition); until I made the camera a prefab. Then I was getting Object reference not set to an instance of an object

    – Keith Power
    Nov 20 '18 at 23:45











  • Unfortunatly I now get the error Type UnityEngine.GameObject' does not contain a definition for 'main' and no extension method 'main' of type 'UnityEngine.GameObject' could be found. Are you missing an assembly reference? when I use targetPos = (Vector2)mainCamera.main.ScreenToWorldPoint(Input.mousePosition);

    – Keith Power
    Nov 21 '18 at 0:02













  • That means you don't have a main camera. If mainCamera is actually supposed to be the main camera, and the prefab isn't already set to have "MainCamera" as its tag, then you need to do that in script. I edited my answer to include that in the first code block.

    – Ruzihm
    Nov 21 '18 at 0:04













  • I have update the code but when I run the game I get the message on screen saying No Cameras Rendering using targetPos = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition); No errors in the code showing

    – Keith Power
    Nov 21 '18 at 0:13
















3














You're getting that particular error because mainCamera is a local variable defined in Start. It is out of scope where you try to reference it in Update. You probably meant to define it as a field in your class, so you could reference it with mainCamera anywhere in your class. To do that you should do this instead:



// ...

private Rigidbody2D myRigidbody;
private Animator myAnim;

private static bool playerExists;
public GameObject cameraPrefab;
public GameObject mainCamera; // add this line

private void Start()
{
myRigidbody = GetComponent<Rigidbody2D>();
myAnim = GetComponent<Animator>();

if(!playerExists){
playerExists = true;
DontDestroyOnLoad(transform.gameObject);
} else {
Destroy(gameObject);
}

targetPos = transform.position;

mainCamera = (GameObject)Instantiate(cameraPrefab); // use mainCamera field
mainCamera.tag = "MainCamera"; // tell Unity that it is your main camera.
}

// ...


But anyway, Camera.main is a static property of the Camera class, so you should access it through the Camera class anyway.



You should use this in Update instead:



targetPos = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition);





share|improve this answer


























  • I was using targetPos = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition); until I made the camera a prefab. Then I was getting Object reference not set to an instance of an object

    – Keith Power
    Nov 20 '18 at 23:45











  • Unfortunatly I now get the error Type UnityEngine.GameObject' does not contain a definition for 'main' and no extension method 'main' of type 'UnityEngine.GameObject' could be found. Are you missing an assembly reference? when I use targetPos = (Vector2)mainCamera.main.ScreenToWorldPoint(Input.mousePosition);

    – Keith Power
    Nov 21 '18 at 0:02













  • That means you don't have a main camera. If mainCamera is actually supposed to be the main camera, and the prefab isn't already set to have "MainCamera" as its tag, then you need to do that in script. I edited my answer to include that in the first code block.

    – Ruzihm
    Nov 21 '18 at 0:04













  • I have update the code but when I run the game I get the message on screen saying No Cameras Rendering using targetPos = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition); No errors in the code showing

    – Keith Power
    Nov 21 '18 at 0:13














3












3








3







You're getting that particular error because mainCamera is a local variable defined in Start. It is out of scope where you try to reference it in Update. You probably meant to define it as a field in your class, so you could reference it with mainCamera anywhere in your class. To do that you should do this instead:



// ...

private Rigidbody2D myRigidbody;
private Animator myAnim;

private static bool playerExists;
public GameObject cameraPrefab;
public GameObject mainCamera; // add this line

private void Start()
{
myRigidbody = GetComponent<Rigidbody2D>();
myAnim = GetComponent<Animator>();

if(!playerExists){
playerExists = true;
DontDestroyOnLoad(transform.gameObject);
} else {
Destroy(gameObject);
}

targetPos = transform.position;

mainCamera = (GameObject)Instantiate(cameraPrefab); // use mainCamera field
mainCamera.tag = "MainCamera"; // tell Unity that it is your main camera.
}

// ...


But anyway, Camera.main is a static property of the Camera class, so you should access it through the Camera class anyway.



You should use this in Update instead:



targetPos = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition);





share|improve this answer















You're getting that particular error because mainCamera is a local variable defined in Start. It is out of scope where you try to reference it in Update. You probably meant to define it as a field in your class, so you could reference it with mainCamera anywhere in your class. To do that you should do this instead:



// ...

private Rigidbody2D myRigidbody;
private Animator myAnim;

private static bool playerExists;
public GameObject cameraPrefab;
public GameObject mainCamera; // add this line

private void Start()
{
myRigidbody = GetComponent<Rigidbody2D>();
myAnim = GetComponent<Animator>();

if(!playerExists){
playerExists = true;
DontDestroyOnLoad(transform.gameObject);
} else {
Destroy(gameObject);
}

targetPos = transform.position;

mainCamera = (GameObject)Instantiate(cameraPrefab); // use mainCamera field
mainCamera.tag = "MainCamera"; // tell Unity that it is your main camera.
}

// ...


But anyway, Camera.main is a static property of the Camera class, so you should access it through the Camera class anyway.



You should use this in Update instead:



targetPos = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition);






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 21 '18 at 0:05

























answered Nov 20 '18 at 23:34









RuzihmRuzihm

3,71611627




3,71611627













  • I was using targetPos = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition); until I made the camera a prefab. Then I was getting Object reference not set to an instance of an object

    – Keith Power
    Nov 20 '18 at 23:45











  • Unfortunatly I now get the error Type UnityEngine.GameObject' does not contain a definition for 'main' and no extension method 'main' of type 'UnityEngine.GameObject' could be found. Are you missing an assembly reference? when I use targetPos = (Vector2)mainCamera.main.ScreenToWorldPoint(Input.mousePosition);

    – Keith Power
    Nov 21 '18 at 0:02













  • That means you don't have a main camera. If mainCamera is actually supposed to be the main camera, and the prefab isn't already set to have "MainCamera" as its tag, then you need to do that in script. I edited my answer to include that in the first code block.

    – Ruzihm
    Nov 21 '18 at 0:04













  • I have update the code but when I run the game I get the message on screen saying No Cameras Rendering using targetPos = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition); No errors in the code showing

    – Keith Power
    Nov 21 '18 at 0:13



















  • I was using targetPos = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition); until I made the camera a prefab. Then I was getting Object reference not set to an instance of an object

    – Keith Power
    Nov 20 '18 at 23:45











  • Unfortunatly I now get the error Type UnityEngine.GameObject' does not contain a definition for 'main' and no extension method 'main' of type 'UnityEngine.GameObject' could be found. Are you missing an assembly reference? when I use targetPos = (Vector2)mainCamera.main.ScreenToWorldPoint(Input.mousePosition);

    – Keith Power
    Nov 21 '18 at 0:02













  • That means you don't have a main camera. If mainCamera is actually supposed to be the main camera, and the prefab isn't already set to have "MainCamera" as its tag, then you need to do that in script. I edited my answer to include that in the first code block.

    – Ruzihm
    Nov 21 '18 at 0:04













  • I have update the code but when I run the game I get the message on screen saying No Cameras Rendering using targetPos = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition); No errors in the code showing

    – Keith Power
    Nov 21 '18 at 0:13

















I was using targetPos = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition); until I made the camera a prefab. Then I was getting Object reference not set to an instance of an object

– Keith Power
Nov 20 '18 at 23:45





I was using targetPos = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition); until I made the camera a prefab. Then I was getting Object reference not set to an instance of an object

– Keith Power
Nov 20 '18 at 23:45













Unfortunatly I now get the error Type UnityEngine.GameObject' does not contain a definition for 'main' and no extension method 'main' of type 'UnityEngine.GameObject' could be found. Are you missing an assembly reference? when I use targetPos = (Vector2)mainCamera.main.ScreenToWorldPoint(Input.mousePosition);

– Keith Power
Nov 21 '18 at 0:02







Unfortunatly I now get the error Type UnityEngine.GameObject' does not contain a definition for 'main' and no extension method 'main' of type 'UnityEngine.GameObject' could be found. Are you missing an assembly reference? when I use targetPos = (Vector2)mainCamera.main.ScreenToWorldPoint(Input.mousePosition);

– Keith Power
Nov 21 '18 at 0:02















That means you don't have a main camera. If mainCamera is actually supposed to be the main camera, and the prefab isn't already set to have "MainCamera" as its tag, then you need to do that in script. I edited my answer to include that in the first code block.

– Ruzihm
Nov 21 '18 at 0:04







That means you don't have a main camera. If mainCamera is actually supposed to be the main camera, and the prefab isn't already set to have "MainCamera" as its tag, then you need to do that in script. I edited my answer to include that in the first code block.

– Ruzihm
Nov 21 '18 at 0:04















I have update the code but when I run the game I get the message on screen saying No Cameras Rendering using targetPos = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition); No errors in the code showing

– Keith Power
Nov 21 '18 at 0:13





I have update the code but when I run the game I get the message on screen saying No Cameras Rendering using targetPos = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition); No errors in the code showing

– Keith Power
Nov 21 '18 at 0:13




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403186%2funity-prefab-the-name-maincamera-does-not-exist-in-the-current-context%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini