Tanoda
TagCloud.cs
Go to the documentation of this file.
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.IO;
5using System.Linq;
6using UnityEngine;
7
8public class TagCloud : MonoBehaviour
9{
10 public List<string> tags = new List<string>();
11 public string filePath;
12
13 public void Save()
14 {
15#if !UNITY_WEBGL
16 File.WriteAllLines(filePath + ".tag", tags);
17#else
19#endif
20 }
21
22 public bool SearchHelp(string value)
23 {
24 if (tags.Count == 0)
25 TryLoad();
26
27 foreach (var t in tags)
28 {
29 if (t.Contains(value))
30 {
31 return true;
32 }
33 }
34 return false;
35 }
36
37 public void Load()
38 {
39#if UNITY_WEBGL
40 //filePath = filePath.Replace('\\', '/');
41 //tags = File.ReadAllLines(filePath + ".tag").ToList();
42 tags = GlobalTagManager.instance.GetTags(filePath).ToList();
43#else
44 tags = File.ReadAllLines(filePath + ".tag").ToList();
45#endif
46 }
47
48 public void TryLoad()
49 {
50 try
51 {
52 Load();
53 }
54 catch (Exception)
55 {
56 //Debug.Log(filePath + ".tag not found, or could not access it!");
57 tags = GlobalTagManager.instance.GetTags(filePath).ToList();
58 }
59 }
60}
bool SearchHelp(string value)
Definition: TagCloud.cs:22
void Save()
Definition: TagCloud.cs:13
void TryLoad()
Definition: TagCloud.cs:48
List< string > tags
Definition: TagCloud.cs:10
void Load()
Definition: TagCloud.cs:37
string filePath
Definition: TagCloud.cs:11