BGC Tools
Static Public Member Functions | Static Private Member Functions | Static Private Attributes
BGC.IO.ResourceInfo Class Reference
Collaboration diagram for BGC.IO.ResourceInfo:
Collaboration graph
[legend]

Static Public Member Functions

static List< string > ListFiles (string path, bool shallow=true)
 
static bool Exists (string path)
 

Static Private Member Functions

static void InitializeResourceInfo ()
 

Static Private Attributes

static List< string > resources
 
static int length
 

Detailed Description

Definition at line 11 of file ResourceInfo.cs.

Member Function Documentation

◆ Exists()

static bool BGC.IO.ResourceInfo.Exists ( string  path)
inlinestatic

Definition at line 47 of file ResourceInfo.cs.

48  {
50  bool exists = false;
51  if (string.IsNullOrEmpty(path) == false)
52  {
53  for (int i = 0; i < length; ++i)
54  {
55  if (resources[i].Equals(path, StringComparison.Ordinal))
56  {
57  exists = true;
58  break;
59  }
60  }
61  }
62 
63  return exists;
64  }
static void InitializeResourceInfo()
Definition: ResourceInfo.cs:66
static List< string > resources
Definition: ResourceInfo.cs:13

◆ InitializeResourceInfo()

static void BGC.IO.ResourceInfo.InitializeResourceInfo ( )
inlinestaticprivate

Definition at line 66 of file ResourceInfo.cs.

References LightJson.JsonValue.AsJsonArray, LightJson.JsonArray.Count, BGC.IO.ResourceInfoConstructor.JsonFileStoragePath, LightJson.Serialization.JsonReader.Parse(), and BGC.IO.ResourceInfoConstructor.ResourceInfoFile.

67  {
68  if (resources == null)
69  {
70  #if UNITY_EDITOR
71  if (Resources.Load<TextAsset>(ResourceInfoConstructor.JsonFileStoragePath) == null)
72  {
73  ResourceInfoConstructor.ConstructResourceInfoFile();
74  }
75  #endif
76 
77  resources = new List<string>();
78 
79  TextAsset text = Resources.Load<TextAsset>(ResourceInfoConstructor.ResourceInfoFile);
80  Assert.IsNotNull(text);
81 
82  JsonArray json = JsonReader.Parse(text.text).AsJsonArray;
83  Assert.IsNotNull(json);
84 
85  length = json.Count;
86  for (int i = 0; i < length; ++i)
87  {
88  resources.Add(json[i].AsString);
89  }
90  }
91  }
Represents an ordered collection of JsonValues.
Definition: JsonArray.cs:11
static List< string > resources
Definition: ResourceInfo.cs:13
JsonArray AsJsonArray
This value as an JsonArray.
Definition: JsonValue.cs:155
Represents a reader that can read JsonValues.
Definition: JsonReader.cs:13
int Count
The number of values in this collection.
Definition: JsonArray.cs:16
Here is the call graph for this function:

◆ ListFiles()

static List<string> BGC.IO.ResourceInfo.ListFiles ( string  path,
bool  shallow = true 
)
inlinestatic

Definition at line 16 of file ResourceInfo.cs.

References BGC.IO.ResourceInfoConstructor.CharPathSeparator.

17  {
19  List<string> paths = new List<string>();
20 
21  if (path == null)
22  {
23  return null;
24  }
25 
26  int directoryCount = path.Split(ResourceInfoConstructor.CharPathSeparator).Length;
27  string filePath;
28  int resourceDirectoryCount;
29 
30  for (int i = 0; i < length; ++i)
31  {
32  filePath = resources[i];
33 
34  if (filePath.Contains(path))
35  {
36  resourceDirectoryCount = filePath.Split(ResourceInfoConstructor.CharPathSeparator).Length;
37  if (directoryCount == resourceDirectoryCount || shallow == false)
38  {
39  paths.Add(filePath);
40  }
41  }
42  }
43 
44  return paths;
45  }
static void InitializeResourceInfo()
Definition: ResourceInfo.cs:66
static List< string > resources
Definition: ResourceInfo.cs:13

Field Documentation

◆ length

int BGC.IO.ResourceInfo.length
staticprivate

Definition at line 14 of file ResourceInfo.cs.

◆ resources

List<string> BGC.IO.ResourceInfo.resources
staticprivate

Definition at line 13 of file ResourceInfo.cs.


The documentation for this class was generated from the following file: