Browse Source

Converted tabs to spaces in new files

master
Zach Vinless 8 years ago
parent
commit
5f677602c5
  1. 2
      Assets/Fungus/Scripts/Editor/FlowchartWindow.cs
  2. 182
      Assets/Fungus/Scripts/Editor/FungusEditorResources.cs
  3. 70
      Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs

2
Assets/Fungus/Scripts/Editor/FlowchartWindow.cs

@ -473,7 +473,7 @@ namespace Fungus.EditorUtils
GUI.color = new Color(1f, 1f, 1f, alpha);
}
if (GUI.Button(rect, FungusEditorResources.PlayBig as Texture, new GUIStyle()))
if (GUI.Button(rect, FungusEditorResources.PlayBig, new GUIStyle()))
{
SelectBlock(flowchart, b);
}

182
Assets/Fungus/Scripts/Editor/FungusEditorResources.cs

@ -10,105 +10,105 @@ using System.Collections.Generic;
namespace Fungus.EditorUtils
{
internal static partial class FungusEditorResources
{
private static Dictionary<string, Texture2D> textures = new Dictionary<string, Texture2D>();
static FungusEditorResources()
{
LoadTexturesFromNames();
}
internal static partial class FungusEditorResources
{
private static Dictionary<string, Texture2D> textures = new Dictionary<string, Texture2D>();
static FungusEditorResources()
{
LoadTexturesFromNames();
}
private static void LoadTexturesFromNames()
{
var baseDirectories = AssetDatabase.FindAssets("\"Fungus Editor Resources\"").Select(
guid => AssetDatabase.GUIDToAssetPath(guid)
).ToArray();
foreach (var name in resourceNames)
{
LoadTexturesFromGUIDs(AssetDatabase.FindAssets(name + " t:Texture2D", baseDirectories));
}
}
private static void LoadTexturesFromNames()
{
var baseDirectories = AssetDatabase.FindAssets("\"Fungus Editor Resources\"").Select(
guid => AssetDatabase.GUIDToAssetPath(guid)
).ToArray();
foreach (var name in resourceNames)
{
LoadTexturesFromGUIDs(AssetDatabase.FindAssets(name + " t:Texture2D", baseDirectories));
}
}
private static void LoadAllTexturesInFolder()
{
var rootGuid = AssetDatabase.FindAssets("\"Fungus Editor Resources\"")[0];
var root = AssetDatabase.GUIDToAssetPath(rootGuid);
LoadTexturesFromGUIDs(AssetDatabase.FindAssets("t:Texture2D", new [] { root }));
}
private static void LoadAllTexturesInFolder()
{
var rootGuid = AssetDatabase.FindAssets("\"Fungus Editor Resources\"")[0];
var root = AssetDatabase.GUIDToAssetPath(rootGuid);
LoadTexturesFromGUIDs(AssetDatabase.FindAssets("t:Texture2D", new [] { root }));
}
private static void LoadTexturesFromGUIDs(string[] guids)
{
var paths = guids.Select(guid => AssetDatabase.GUIDToAssetPath(guid)).OrderBy(path => path.ToLower().Contains("/pro/"));
foreach (var path in paths)
{
if (path.ToLower().Contains("/pro/") && !EditorGUIUtility.isProSkin)
{
return;
}
var texture = AssetDatabase.LoadAssetAtPath(path, typeof(Texture2D)) as Texture2D;
textures[texture.name] = texture;
}
}
private static void LoadTexturesFromGUIDs(string[] guids)
{
var paths = guids.Select(guid => AssetDatabase.GUIDToAssetPath(guid)).OrderBy(path => path.ToLower().Contains("/pro/"));
foreach (var path in paths)
{
if (path.ToLower().Contains("/pro/") && !EditorGUIUtility.isProSkin)
{
return;
}
var texture = AssetDatabase.LoadAssetAtPath(path, typeof(Texture2D)) as Texture2D;
textures[texture.name] = texture;
}
}
[MenuItem("Tools/Fungus/Utilities/Update Editor Resources Script")]
private static void GenerateResourcesScript()
{
textures.Clear();
LoadAllTexturesInFolder();
[MenuItem("Tools/Fungus/Utilities/Update Editor Resources Script")]
private static void GenerateResourcesScript()
{
textures.Clear();
LoadAllTexturesInFolder();
var guid = AssetDatabase.FindAssets("FungusEditorResources t:MonoScript")[0];
var relativePath = AssetDatabase.GUIDToAssetPath(guid).Replace("FungusEditorResources.cs", "FungusEditorResourcesGenerated.cs");
var absolutePath = Application.dataPath + relativePath.Substring("Assets".Length);
using (var writer = new StreamWriter(absolutePath))
{
writer.WriteLine("// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).");
writer.WriteLine("// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)");
writer.WriteLine("");
writer.WriteLine("using UnityEngine;");
writer.WriteLine("");
writer.WriteLine("namespace Fungus.EditorUtils");
writer.WriteLine("{");
writer.WriteLine("\tinternal static partial class FungusEditorResources");
writer.WriteLine("\t{");
writer.WriteLine("\t\tprivate static readonly string[] resourceNames = new [] {");
foreach (var pair in textures)
{
writer.WriteLine("\t\t\t\"" + pair.Key + "\",");
}
var guid = AssetDatabase.FindAssets("FungusEditorResources t:MonoScript")[0];
var relativePath = AssetDatabase.GUIDToAssetPath(guid).Replace("FungusEditorResources.cs", "FungusEditorResourcesGenerated.cs");
var absolutePath = Application.dataPath + relativePath.Substring("Assets".Length);
using (var writer = new StreamWriter(absolutePath))
{
writer.WriteLine("// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).");
writer.WriteLine("// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)");
writer.WriteLine("");
writer.WriteLine("using UnityEngine;");
writer.WriteLine("");
writer.WriteLine("namespace Fungus.EditorUtils");
writer.WriteLine("{");
writer.WriteLine(" internal static partial class FungusEditorResources");
writer.WriteLine(" {");
writer.WriteLine(" private static readonly string[] resourceNames = new [] {");
foreach (var pair in textures)
{
writer.WriteLine(" \"" + pair.Key + "\",");
}
writer.WriteLine("\t\t};");
writer.WriteLine("");
writer.WriteLine(" };");
writer.WriteLine("");
foreach (var pair in textures)
{
var name = pair.Key;
var pascalCase = string.Join("", name.Split(new [] { '_' }, StringSplitOptions.RemoveEmptyEntries).Select(
s => s.Substring(0, 1).ToUpper() + s.Substring(1)).ToArray()
);
writer.WriteLine("\t\tpublic static Texture2D " + pascalCase + " { get { return GetTexture(\"" + name + "\"); } }");
}
foreach (var pair in textures)
{
var name = pair.Key;
var pascalCase = string.Join("", name.Split(new [] { '_' }, StringSplitOptions.RemoveEmptyEntries).Select(
s => s.Substring(0, 1).ToUpper() + s.Substring(1)).ToArray()
);
writer.WriteLine(" public static Texture2D " + pascalCase + " { get { return GetTexture(\"" + name + "\"); } }");
}
writer.WriteLine("\t}");
writer.WriteLine("}");
}
writer.WriteLine(" }");
writer.WriteLine("}");
}
AssetDatabase.ImportAsset(relativePath);
}
AssetDatabase.ImportAsset(relativePath);
}
private static Texture2D GetTexture(string name)
{
Texture2D texture;
if (!textures.TryGetValue(name, out texture))
{
Debug.LogWarning("Texture \"" + name + "\" not found!");
}
return texture;
}
}
private static Texture2D GetTexture(string name)
{
Texture2D texture;
if (!textures.TryGetValue(name, out texture))
{
Debug.LogWarning("Texture \"" + name + "\" not found!");
}
return texture;
}
}
}

70
Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs

@ -5,40 +5,40 @@ using UnityEngine;
namespace Fungus.EditorUtils
{
internal static partial class FungusEditorResources
{
private static readonly string[] resourceNames = new [] {
"add",
"add_small",
"delete",
"down",
"duplicate",
"up",
"choice_node_off",
"choice_node_on",
"command_background",
"event_node_off",
"event_node_on",
"play_big",
"play_small",
"process_node_off",
"process_node_on",
};
internal static partial class FungusEditorResources
{
private static readonly string[] resourceNames = new [] {
"add",
"add_small",
"delete",
"down",
"duplicate",
"up",
"choice_node_off",
"choice_node_on",
"command_background",
"event_node_off",
"event_node_on",
"play_big",
"play_small",
"process_node_off",
"process_node_on",
};
public static Texture2D Add { get { return GetTexture("add"); } }
public static Texture2D AddSmall { get { return GetTexture("add_small"); } }
public static Texture2D Delete { get { return GetTexture("delete"); } }
public static Texture2D Down { get { return GetTexture("down"); } }
public static Texture2D Duplicate { get { return GetTexture("duplicate"); } }
public static Texture2D Up { get { return GetTexture("up"); } }
public static Texture2D ChoiceNodeOff { get { return GetTexture("choice_node_off"); } }
public static Texture2D ChoiceNodeOn { get { return GetTexture("choice_node_on"); } }
public static Texture2D CommandBackground { get { return GetTexture("command_background"); } }
public static Texture2D EventNodeOff { get { return GetTexture("event_node_off"); } }
public static Texture2D EventNodeOn { get { return GetTexture("event_node_on"); } }
public static Texture2D PlayBig { get { return GetTexture("play_big"); } }
public static Texture2D PlaySmall { get { return GetTexture("play_small"); } }
public static Texture2D ProcessNodeOff { get { return GetTexture("process_node_off"); } }
public static Texture2D ProcessNodeOn { get { return GetTexture("process_node_on"); } }
}
public static Texture2D Add { get { return GetTexture("add"); } }
public static Texture2D AddSmall { get { return GetTexture("add_small"); } }
public static Texture2D Delete { get { return GetTexture("delete"); } }
public static Texture2D Down { get { return GetTexture("down"); } }
public static Texture2D Duplicate { get { return GetTexture("duplicate"); } }
public static Texture2D Up { get { return GetTexture("up"); } }
public static Texture2D ChoiceNodeOff { get { return GetTexture("choice_node_off"); } }
public static Texture2D ChoiceNodeOn { get { return GetTexture("choice_node_on"); } }
public static Texture2D CommandBackground { get { return GetTexture("command_background"); } }
public static Texture2D EventNodeOff { get { return GetTexture("event_node_off"); } }
public static Texture2D EventNodeOn { get { return GetTexture("event_node_on"); } }
public static Texture2D PlayBig { get { return GetTexture("play_big"); } }
public static Texture2D PlaySmall { get { return GetTexture("play_small"); } }
public static Texture2D ProcessNodeOff { get { return GetTexture("process_node_off"); } }
public static Texture2D ProcessNodeOn { get { return GetTexture("process_node_on"); } }
}
}

Loading…
Cancel
Save