I'm trying to build a Unity game, and keep getting the error:
Assets\charaterselection.cs(34,9): error CS0103: The name 'PrefabUtility' does not exist in the current context
The issue is I imported UnityEditor, I'm not sure what's going on
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEditor;using UnityEngine.SceneManagement;public class charaterselection : MonoBehaviour{public SpriteRenderer sr;public List<Sprite> skins = new List<Sprite>();private int selecectedSkin;public GameObject player;public void Next(){selecectedSkin=selecectedSkin+1;if (selecectedSkin== skins.Count){selecectedSkin=0;}sr.sprite= skins[selecectedSkin];}public void back(){selecectedSkin = selecectedSkin - 1;if (selecectedSkin < 0){selecectedSkin = skins.Count - 1;}sr.sprite = skins[selecectedSkin];}public void play(){PrefabUtility.SaveAsPrefabAsset(player, "Assets/Players/FROGY.prefab");SceneManager.LoadScene(1);}}
Best Answer
Thank you guys for your help, I literately just made a file called "Editor" and it worked.