aboutsummaryrefslogtreecommitdiff
path: root/Assets/Packages/Lean/Localization/Scripts/LeanPrefab.cs
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@gmail.com>2019-11-03 18:31:04 -0500
committerAndrew Lee <alee14498@gmail.com>2019-11-03 18:31:04 -0500
commite8dd5d4fd406e6e6b710cbe85309f6870bccc37a (patch)
treedb0e99cfdbefb1625d66d07631f43565ae8ff41f /Assets/Packages/Lean/Localization/Scripts/LeanPrefab.cs
parent20b14c9a89821e6592bf25bed9329a5abe20495c (diff)
downloadUnicity-e8dd5d4fd406e6e6b710cbe85309f6870bccc37a.tar.gz
Unicity-e8dd5d4fd406e6e6b710cbe85309f6870bccc37a.tar.bz2
Unicity-e8dd5d4fd406e6e6b710cbe85309f6870bccc37a.zip
Remove everything
Diffstat (limited to 'Assets/Packages/Lean/Localization/Scripts/LeanPrefab.cs')
-rw-r--r--Assets/Packages/Lean/Localization/Scripts/LeanPrefab.cs176
1 files changed, 0 insertions, 176 deletions
diff --git a/Assets/Packages/Lean/Localization/Scripts/LeanPrefab.cs b/Assets/Packages/Lean/Localization/Scripts/LeanPrefab.cs
deleted file mode 100644
index 1507767..0000000
--- a/Assets/Packages/Lean/Localization/Scripts/LeanPrefab.cs
+++ /dev/null
@@ -1,176 +0,0 @@
-using UnityEngine;
-using System.IO;
-using System.Collections.Generic;
-
-namespace Lean.Localization
-{
- [System.Serializable]
- public class LeanPrefab
- {
- public Object Root;
-
- [SerializeField]
- private List<LeanSource> sources;
-
- [System.NonSerialized]
- private int buildingCount;
-
- [System.NonSerialized]
- private bool buildingModified;
-
- private static List<LeanSource> tempSources = new List<LeanSource>();
-
- public List<LeanSource> Sources
- {
- get
- {
- if (sources == null)
- {
- sources = new List<LeanSource>();
- }
-
- return sources;
- }
- }
-
- public bool RebuildSources()
- {
- if (sources == null)
- {
- sources = new List<LeanSource>();
- }
-
- if (Root != null)
- {
- if (Root is LeanSource)
- {
- buildingCount = 0;
- buildingModified = false;
-
- AddSource((LeanSource)Root);
-
- return FinalizeBuild();
- }
- else if (Root is GameObject)
- {
- buildingCount = 0;
- buildingModified = false;
-
- FindFromGameObject(((GameObject)Root).transform);
-
- return FinalizeBuild();
- }
-#if UNITY_EDITOR
- else // Folder
- {
- var rootPath = UnityEditor.AssetDatabase.GetAssetPath(Root);
-
- if (string.IsNullOrEmpty(rootPath) == false)
- {
- buildingCount = 0;
- buildingModified = false;
-
- var basePath = Application.dataPath;
- var baseTail = "Assets";
-
- if (basePath.EndsWith(baseTail) == true)
- {
- basePath = basePath.Substring(0, basePath.Length - baseTail.Length);
- }
-
- FindFromFolder(basePath, rootPath);
-
- return FinalizeBuild();
- }
- }
-#endif
- }
-
- return false;
- }
-
- private bool FinalizeBuild()
- {
- for (var i = sources.Count - 1; i >= buildingCount; i--)
- {
- sources.RemoveAt(i); buildingModified = true;
- }
-
- return buildingModified;
- }
-
- private void AddSource(LeanSource source)
- {
- if (buildingCount < sources.Count)
- {
- if (sources[buildingCount] != source)
- {
- sources[buildingCount] = source;
-
- buildingModified = true;
- }
- }
- else
- {
- sources.Add(source);
-
- buildingModified = true;
- }
-
- buildingCount++;
- }
-
- private void FindFromGameObject(Transform prefab)
- {
- prefab.GetComponents(tempSources);
-
- if (tempSources.Count > 0)
- {
- for (var i = 0; i < tempSources.Count; i++)
- {
- AddSource(tempSources[i]);
- }
- }
- else
- {
- for (var i = 0; i < prefab.childCount; i++)
- {
- FindFromGameObject(prefab.GetChild(i));
- }
- }
- }
-#if UNITY_EDITOR
- private void FindFromFolder(string basePath, string rootPath)
- {
- var fullPath = basePath + rootPath;
-
- if (Directory.Exists(fullPath) == true)
- {
- var subFolders = Directory.GetDirectories(fullPath);
-
- for (var i = 0; i < subFolders.Length; i++)
- {
- FindFromFolder(basePath, subFolders[i].Substring(basePath.Length));
- }
-
- var subAssets = Directory.GetFiles(fullPath, "*.prefab");
-
- for (var i = 0; i < subAssets.Length; i++)
- {
- FindFromFolder(basePath, subAssets[i].Substring(basePath.Length));
- }
- }
- // File
- else
- {
- var subGameObject = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(rootPath);
-
- if (subGameObject != null)
- {
- FindFromGameObject(subGameObject.transform);
- }
- }
- }
-#endif
- }
-} \ No newline at end of file