using System;

class Program
{
    static void Main(string[] args)
    {
        int a = 5;
        int b = 10;
        
        Console.WriteLine($"Before Swap: a = {a}, b = {b}");
        Swap(ref a, ref b);
        Console.WriteLine($"After Swap: a = {a}, b = {b}");
        
        string x = "hello";
        string y = "world";
        
        Console.WriteLine($"Before Swap: x = {x}, y = {y}");
        Swap(ref x, ref y);
        Console.WriteLine($"After Swap: x = {x}, y = {y}");
    }
    
    static void Swap<T>(ref T lhs, ref T rhs)
    {
        T temp;
        temp = lhs;
        lhs = rhs;
        rhs = temp;
    }
}

 

https://docs.unity3d.com/ScriptReference/EditorWindow.html

 

Unity - Scripting API: EditorWindow

Create your own custom editor window that can float free or be docked as a tab, just like the native windows in the Unity interface. Editor windows are typically opened using a menu item.

docs.unity3d.com

 

 

 

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

public class BlockSwapWindow : EditorWindow
{
    [MenuItem("Window/Block Swap Window")]
    
    public static void ShowWindow()
    {
        GetWindow<BlockSwapWindow>("Block Swap Window");
    }

    private void OnGUI()
    {
        GUILayout.Label("Swap Blocks", EditorStyles.boldLabel);
    }
}

 

 

 

https://docs.unity3d.com/ScriptReference/GUILayout.Label.html

 

Unity - Scripting API: GUILayout.Label

Labels have no user interaction, do not catch mouse clicks and are always rendered in normal style. If you want to make a control that responds visually to user input, use a Box control Label in the Game View.

docs.unity3d.com

https://docs.unity3d.com/ScriptReference/EditorGUILayout.IntField.html

 

Unity - Scripting API: EditorGUILayout.IntField

Success! Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable. Close

docs.unity3d.com

 

 

 

 

using Codice.Client.BaseCommands.Filters;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class BlockSwapWindow : EditorWindow
{
    private int row1;
    private int col1;
    private int row2;
    private int col2;
    [MenuItem("Window/Block Swap Window")]
    
    public static void ShowWindow()
    {
        GetWindow<BlockSwapWindow>("Block Swap Window");
    }

    private void OnGUI()
    {
        GUILayout.Label("Swap Blocks", EditorStyles.boldLabel);

        row1 = EditorGUILayout.IntField("Row 1", row1);
        col1 = EditorGUILayout.IntField("Column 1", col1);
        row2 = EditorGUILayout.IntField("Row 2", row2);
        col2 = EditorGUILayout.IntField("Column 2", col2);
    }
}

 

 

using Codice.Client.BaseCommands.Filters;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEditor;
using UnityEngine;

public class BlockSwapWindow : EditorWindow
{
    private int row1;
    private int col1;
    private int row2;
    private int col2;
    [MenuItem("Window/Block Swap Window")]
    
    public static void ShowWindow()
    {
        GetWindow<BlockSwapWindow>("Block Swap Window");
    }

    private void OnGUI()
    {
        GUILayout.Label("Swap Blocks", EditorStyles.boldLabel);

        row1 = EditorGUILayout.IntField("Row 1", row1);
        col1 = EditorGUILayout.IntField("Column 1", col1);
        row2 = EditorGUILayout.IntField("Row 2", row2);
        col2 = EditorGUILayout.IntField("Column 2", col2);

        //버튼 UI추가
        if (GUILayout.Button("Swap"))
        {
            //Board.instance.SwapBlocks(row1, col1, row2, col2);
            Debug.Log($"Swapped blocks at [{row1}, {col1} ane [{row2}, {col2}]");
        }

    }

}

+ Recent posts