Browse Source

Editor button textures now loaded in OnEnable()

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

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

@ -31,6 +31,21 @@ namespace Fungus
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)
{
serializedObject.Update();
@ -246,16 +261,13 @@ namespace Fungus
GUI.FocusControl("dummycontrol");
Event.current.Use();
}
// Up Button
Texture2D upIcon = Resources.Load("Icons/up") as Texture2D;
if (GUILayout.Button(upIcon))
{
SelectPrevious();
}
// Down Button
Texture2D downIcon = Resources.Load("Icons/down") as Texture2D;
if (GUILayout.Button(downIcon))
{
SelectNext();
@ -264,14 +276,12 @@ namespace Fungus
GUILayout.FlexibleSpace();
// Add Button
Texture2D addIcon = Resources.Load("Icons/add") as Texture2D;
if (GUILayout.Button(addIcon))
{
ShowCommandMenu();
}
// Duplicate Button
Texture2D duplicateIcon = Resources.Load("Icons/duplicate") as Texture2D;
if (GUILayout.Button(duplicateIcon))
{
Copy();
@ -279,7 +289,6 @@ namespace Fungus
}
// Delete Button
Texture2D deleteIcon = Resources.Load("Icons/delete") as Texture2D;
if (GUILayout.Button(deleteIcon))
{
Delete();

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

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

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

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

Loading…
Cancel
Save