2016.8.14 孙广东
第一种方式:
本文参考: http://wiki.unity3d.com/index.php?title=SetPivot
Pivot (锚点), 熟悉 UGUI肯定熟悉 锚点,
锚点就是 对象的位置中心点, 缩放和旋转的中心!!!
/*
* Version: 1.0
* Author: Yilmaz Kiymaz (@VoxelBoy)
* Purpose: To be able to change the pivot of Game Objects
* without needing to use a separate 3D application.
* License: Free to use and distribute, in both free and commercial projects.
* Do not try to sell as your own work. Simply put, play nice
* Contact: VoxelBoy on Unity Forums
*/
using UnityEngine;
using UnityEditor;
public class SetPivot : EditorWindow
{
Vector3 p; //Pivot value -1..1, calculated from Mesh bounds
Vector3 last_p; //Last used pivot
GameObject obj; //Selected object in the Hierarchy
MeshFilter meshFilter; //Mesh Filter of the selected object
Mesh mesh; //Mesh of the selected object
Collider col; //Collider of the selected object
bool pivotUnchanged; //Flag to decide when to instantiate a copy of the mesh
[MenuItem("GameObject/Set Pivot")] //Place the Set Pivot menu item in the GameObject menu
static void Init()
{
SetPivot window = (SetPivot)EditorWindow.GetWindow(typeof(SetPivot));
window.RecognizeSelectedObject(); //Initialize the variables by calling RecognizeSelectedObject on the class instance
window.Show();
}
void OnGUI()
{
if (obj)
{
if (mes