Unity 5 Editor Scripting C#: Move GameObject

preview_player
Показать описание
In this Unity tutorial I show an Editor extension for moving GameObject to special Spawning points. The extension is programmed with a Untiy C# Script that I copied to a comment of this video, you can use it as you like for free.

Рекомендации по теме
Комментарии
Автор

Here is the C# Script:

using UnityEngine;
using System.Collections;
using UnityEditor;

public class MoveGameObject : MonoBehaviour {


static void menuCommand)
{
if (Selection.gameObjects.Length != 2)
return;

// Last selected object
GameObject go = Selection.activeGameObject;
GameObject other = null;

// Get the object to move to
foreach (GameObject nextObj in Selection.gameObjects)
{
if (go != nextObj)
{
other = nextObj;
break;
}
}

// Set the position of the last selected object
go.transform.position = other.transform.position;
}
}

JayAnAm
visit shbcf.ru