三国卡牌客户端基础资源仓库
yyl
3 天以前 cec146fc3fe287928e075c79ece20a20a9b16b20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//--------------------------------------------------------
//    [Author]:           玩个游戏
//    [  Date ]:           Monday, August 14, 2017
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEditor;
using System;
 
 
[CustomEditor(typeof(CustomImage)), CanEditMultipleObjects]
public class CustomImageEidtor:Editor {
 
    protected virtual void OnSceneGUI() {
        var customImage = (CustomImage)this.target;
        if(customImage.points != null) {
            EditorGUI.BeginChangeCheck();
            for(var i = 0;i < customImage.points.Length;i++) {
                var wh = customImage.points[i];
                var worldposition = customImage.transform.TransformPoint(wh);
                var handlePosition = Handles.PositionHandle(worldposition,Quaternion.identity);
                customImage.points[i] = customImage.transform.InverseTransformPoint(handlePosition);
            }
 
            if(EditorGUI.EndChangeCheck()) {
                customImage.SetVerticesDirty();
            }
 
            EditorUtility.SetDirty(customImage);
        }
 
    }
 
 
}