Top.Mail.Ru
Ответы

Нужна помощь. Ошибка CS0246.

Сделал игру, всё работало, решил сделать заставку. При первом же запуске ничего не получилось, вылезла та самая ошибка CS0246, которая уже надоела. Посмотрел консоль и увидел ошибку в плагине, который создаёт сам Unity и который я не трогал.

Текст ошибки: error CS0246: Assets\FastMesh\Scripts\SceneViewText.cs(27,33): error CS0246: The type or namespace name 'SceneView' could not be found (are you missing a using directive or an assembly reference?).

И да, я знаю, как он переводится, но в интернете не нашёл информации о том, какая директива нужна для SceneView. Видел лишь где-то UnityEditor, но после его добавления ничего не изменилось.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
 using System; 
using System.Collections; 
using System.Collections.Generic; 
using UnityEngine; 
using UnityEditor; 
 
namespace FastMesh_Example 
{ 
    [ExecuteInEditMode] 
    public class SceneViewText : MonoBehaviour 
    { 
        public bool isShow = true; 
        string text2 = "These 3D models, all created with \"Fast Mesh - 3D Asset Creation Tool\" (click)";  
        Color backgroundColor = Color.white; 
        Color textColor = Color.black;  
     
        private void OnEnable() 
        { 
            SceneView.duringSceneGui += OnSceneGUI; 
        } 
     
        private void OnDisable() 
        { 
            SceneView.duringSceneGui -= OnSceneGUI; 
        } 
     
        private void OnSceneGUI(SceneView sceneView) 
        { 
            if (isShow == false) return; 
             
            Handles.BeginGUI(); 
            GUIStyle style = new GUIStyle(GUI.skin.label); 
            style.alignment = TextAnchor.MiddleCenter; 
            style.fontSize = 20; 
            style.normal.textColor = textColor; 
            style.wordWrap = true; 
     
            float width = 420f; 
            float height = 50f; 
            float x = (sceneView.position.width - width) / 2f; 
            // float y = (sceneView.position.height - height) / 2f; 
            float y = 10f; 
     
            GUI.color = backgroundColor; 
            GUI.DrawTexture(new Rect(x - 10, y - 10, width + 20, height + 20), Texture2D.whiteTexture); 
            GUI.color = Color.white; 
             
            if (GUI.Button(new Rect(x, y, width, height), text2, style)) 
            { 
                Application.OpenURL("https://assetstore.unity.com/packages/slug/288711"); 
            } 
     
            // GUILayout.BeginArea(new Rect(x, y, width, height)); 
            // GUILayout.Label(text, style); 
            // GUILayout.EndArea(); 
            Handles.EndGUI(); 
        } 
    } 
} 
По дате
По рейтингу
Аватар пользователя
Мастер
9мес

Тебе на stack overflow. Тут тебе вряд ли помогут

Аватар пользователя
Мастер
9мес

В Unity 2018 года нет SceneView, поэтому и не видит

Аватар пользователя
Искусственный Интеллект
9мес

Ввв. Мыкрфaк. Сом