Browse Source

Editor button textures now loaded in OnEnable()

master
chrisgregan 10 years ago
parent
commit
baecdbe2a8
  1. 21
      Assets/Fungus/Flowchart/Editor/BlockEditor.cs
  2. 6
      Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs
  3. 6
      Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs

21
Assets/Fungus/Flowchart/Editor/BlockEditor.cs

@ -31,6 +31,21 @@ namespace Fungus
protected static List<Action> actionList = new List<Action>(); protected static List<Action> actionList = new List<Action>();
protected Texture2D upIcon;
protected Texture2D downIcon;
protected Texture2D addIcon;
protected Texture2D duplicateIcon;
protected Texture2D deleteIcon;
protected virtual void OnEnable()
{
upIcon = Resources.Load("Icons/up") as Texture2D;
downIcon = Resources.Load("Icons/down") as Texture2D;
addIcon = Resources.Load("Icons/add") as Texture2D;
duplicateIcon = Resources.Load("Icons/duplicate") as Texture2D;
deleteIcon = Resources.Load("Icons/delete") as Texture2D;
}
public virtual void DrawBlockName(Flowchart flowchart) public virtual void DrawBlockName(Flowchart flowchart)
{ {
serializedObject.Update(); serializedObject.Update();
@ -247,15 +262,12 @@ namespace Fungus
Event.current.Use(); Event.current.Use();
} }
// Up Button
Texture2D upIcon = Resources.Load("Icons/up") as Texture2D;
if (GUILayout.Button(upIcon)) if (GUILayout.Button(upIcon))
{ {
SelectPrevious(); SelectPrevious();
} }
// Down Button // Down Button
Texture2D downIcon = Resources.Load("Icons/down") as Texture2D;
if (GUILayout.Button(downIcon)) if (GUILayout.Button(downIcon))
{ {
SelectNext(); SelectNext();
@ -264,14 +276,12 @@ namespace Fungus
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
// Add Button // Add Button
Texture2D addIcon = Resources.Load("Icons/add") as Texture2D;
if (GUILayout.Button(addIcon)) if (GUILayout.Button(addIcon))
{ {
ShowCommandMenu(); ShowCommandMenu();
} }
// Duplicate Button // Duplicate Button
Texture2D duplicateIcon = Resources.Load("Icons/duplicate") as Texture2D;
if (GUILayout.Button(duplicateIcon)) if (GUILayout.Button(duplicateIcon))
{ {
Copy(); Copy();
@ -279,7 +289,6 @@ namespace Fungus
} }
// Delete Button // Delete Button
Texture2D deleteIcon = Resources.Load("Icons/delete") as Texture2D;
if (GUILayout.Button(deleteIcon)) if (GUILayout.Button(deleteIcon))
{ {
Delete(); Delete();

6
Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs

@ -26,6 +26,8 @@ namespace Fungus
protected SerializedProperty localizationIdProp; protected SerializedProperty localizationIdProp;
protected SerializedProperty variablesProp; protected SerializedProperty variablesProp;
protected Texture2D addTexture;
protected virtual void OnEnable() protected virtual void OnEnable()
{ {
descriptionProp = serializedObject.FindProperty("description"); descriptionProp = serializedObject.FindProperty("description");
@ -35,6 +37,8 @@ namespace Fungus
saveSelectionProp = serializedObject.FindProperty("saveSelection"); saveSelectionProp = serializedObject.FindProperty("saveSelection");
localizationIdProp = serializedObject.FindProperty("localizationId"); localizationIdProp = serializedObject.FindProperty("localizationId");
variablesProp = serializedObject.FindProperty("variables"); variablesProp = serializedObject.FindProperty("variables");
addTexture = Resources.Load("Icons/add_small") as Texture2D;
} }
public override void OnInspectorGUI() public override void OnInspectorGUI()
@ -150,8 +154,6 @@ namespace Fungus
plusRect.width = plusWidth; plusRect.width = plusWidth;
plusRect.height = plusHeight; plusRect.height = plusHeight;
Texture2D addTexture = Resources.Load("Icons/add_small") as Texture2D;
if (!Application.isPlaying && if (!Application.isPlaying &&
GUI.Button(plusRect, addTexture)) GUI.Button(plusRect, addTexture))
{ {

6
Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs

@ -28,6 +28,8 @@ namespace Fungus
protected int forceRepaintCount; protected int forceRepaintCount;
protected Texture2D addTexture;
[MenuItem("Tools/Fungus/Flowchart Window")] [MenuItem("Tools/Fungus/Flowchart Window")]
static void Init() static void Init()
{ {
@ -48,6 +50,8 @@ namespace Fungus
nodeStyle.contentOffset = Vector2.zero; nodeStyle.contentOffset = Vector2.zero;
nodeStyle.alignment = TextAnchor.MiddleCenter; nodeStyle.alignment = TextAnchor.MiddleCenter;
nodeStyle.wordWrap = true; nodeStyle.wordWrap = true;
addTexture = Resources.Load("Icons/add_small") as Texture2D;
} }
protected virtual void OnInspectorUpdate() protected virtual void OnInspectorUpdate()
@ -147,8 +151,6 @@ namespace Fungus
GUILayout.Space(8); GUILayout.Space(8);
Texture2D addTexture = Resources.Load("Icons/add_small") as Texture2D;
if (GUILayout.Button(new GUIContent(addTexture, "Add a new block"))) if (GUILayout.Button(new GUIContent(addTexture, "Add a new block")))
{ {
Vector2 newNodePosition = new Vector2(50 - flowchart.scrollPos.x, Vector2 newNodePosition = new Vector2(50 - flowchart.scrollPos.x,

Loading…
Cancel
Save