-
Notifications
You must be signed in to change notification settings - Fork 128
/
FogOfWarEffectEditor.cs
51 lines (45 loc) · 1.58 KB
/
FogOfWarEffectEditor.cs
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(FogOfWarEffect))]
public class FogOfWarEffectEditor : Editor
{
private FogOfWarEffect m_Target;
void OnEnable()
{
m_Target = (FogOfWarEffect) target;
}
public override bool HasPreviewGUI()
{
if (m_Target == null)
return false;
return m_Target.fowMaskTexture != null;
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
EditorGUILayout.Space();
if (GUILayout.Button("预生成地图数据"))
{
ASL.FogOfWar.FOWPregenerationMapData dt = m_Target.GetComponent<ASL.FogOfWar.FOWPregenerationMapData>();
if (!dt)
dt = m_Target.gameObject.AddComponent<ASL.FogOfWar.FOWPregenerationMapData>();
if (dt)
{
dt.width = m_Target.texWidth;
dt.height = m_Target.texHeight;
float deltax = m_Target.xSize / m_Target.texWidth;
float deltaz = m_Target.zSize / m_Target.texHeight;
Vector3 beginpos = m_Target.centerPosition - new Vector3(m_Target.xSize * 0.5f, 0, m_Target.zSize * 0.5f);
dt.GenerateMapData(beginpos.x, beginpos.y, deltax, deltaz, m_Target.heightRange);
}
}
}
public override void DrawPreview(Rect previewArea)
{
base.DrawPreview(previewArea);
if (m_Target != null && m_Target.fowMaskTexture)
GUI.DrawTexture(previewArea, m_Target.fowMaskTexture);
}
}