小编Ben*_*mil的帖子

我一直得到异常功能'插值字符串'不能使用,因为它不是C#4.0语言的一部分?

首先,我在视觉工作室中遇到了错误.所以我点击了包含错误的行并选择修复它以将visual studio目标更改为csharp 6

using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;

public class PrefabReplace : EditorWindow
{
    [SerializeField] private GameObject prefab;

    [MenuItem("Tools/Prefab Replace")]
    static void CreateReplaceWithPrefab()
    {
        EditorWindow.GetWindow<PrefabReplace>();
    }

    private void OnGUI()
    {
        prefab = (GameObject)EditorGUILayout.ObjectField("Prefab", prefab, typeof(GameObject), false);

        if (GUILayout.Button("Replace"))
        {
            var selection = Selection.gameObjects.ToList();

            if (prefab != null && selection.Count > 0)
            {
                for (var i = selection.Count - 1; i >= 0; --i)
                {
                    var selected = selection[i];
                    var prefabType = PrefabUtility.GetPrefabType(prefab);
                    GameObject …
Run Code Online (Sandbox Code Playgroud)

c# unity-game-engine

2
推荐指数
1
解决办法
2197
查看次数

如何比较预制件和GameObject?

prefab = (GameObject)EditorGUILayout.ObjectField("Prefab", prefab, typeof(GameObject), false);

        GUI.enabled = false;
        var selection = Selection.objects.OfType<GameObject>().ToList();
        for (var i = selection.Count - 1; i >= 0; --i)
        {
            selectedObject = selection[i];
            if (prefab != null && selection.Count > 0
                && prefab != selectedObject)
                GUI.enabled = true;
        }
        if (GUILayout.Button("Replace"))
        {
            selection = Selection.objects.OfType<GameObject>().ToList();

            if (prefab != null && selection.Count > 0)
            {
                for (var i = selection.Count - 1; i >= 0; --i)
                {
                    var selected = selection[i];
                    SceneManager.SetActiveScene(SceneManager.GetSceneByName(selected.scene.name));

                    var prefabType = PrefabUtility.GetPrefabType(prefab); …
Run Code Online (Sandbox Code Playgroud)

c# unity-game-engine

1
推荐指数
1
解决办法
1447
查看次数

标签 统计

c# ×2

unity-game-engine ×2