mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-21 23:58:49 -05:00
Speedup Atom Generation (#275)
* Speedup Atom Generation This simple change will speed up atom generation via an AtomGenerator. The whole thing will only take 10 seconds instead of +1 minute. * Update the changelog
This commit is contained in:
parent
85bbaa03bb
commit
907cf70918
@ -6,6 +6,12 @@
|
||||
💅 = Polish
|
||||
🚀 = New features
|
||||
|
||||
# 4.4.4 (TODO: UPDATE THE DATE ON MERGE DAY)
|
||||
|
||||
## 🏃♀ Performance
|
||||
|
||||
- [#276](https://github.com/unity-atoms/unity-atoms/issues/276) This AtomGenerator has been improved to take no longer than about a single reimport. ([@Casey-Hofland](https://github.com/Casey-Hofland))
|
||||
|
||||
# 4.4.3 (Mars 7, 2021)
|
||||
|
||||
## 🐛 Bug fixes
|
||||
|
@ -23,6 +23,35 @@ The reason for this project structure is that we want to include examples in the
|
||||
- use the local pacakges in the example repo
|
||||
- referencing this git repo in another project's manifest file
|
||||
|
||||
### Smooth Workflow
|
||||
|
||||
The github layout makes it difficult to contribute to Atoms from inside a Unity project. However, there are a few steps one can take to alleviate this issue.
|
||||
|
||||
1. Clone the atoms repository and place it where you want your Unity project to be.
|
||||
2. Create a new Unity project (name it whatever, it won't matter) and wait for Unity to load.
|
||||
3. Close Unity and drag all the files of your newly created Unity project inside your atoms repository.
|
||||
4. Inside the Unity Hub, add the atoms repository to your Projects and open it.
|
||||
5. Inside Unity, go to Edit > Preferences > External Tools. Toggle "Embedded Packages" and click the "Regenerate Project Files" button.
|
||||
|
||||
You now have the atoms repository inside a Unity project and can easily make changes to it. However, this approach will lead to all kinds of changes in the repository you don't want to push (for example the Assets folder). So we will take a couple of extra steps to supress those.
|
||||
|
||||
1. Open your repository folder and enable hidden items to be shown (this may be dependant on your OS).
|
||||
2. Go to .git > info > exclude.
|
||||
3. Paste the following:
|
||||
```
|
||||
/[Aa]ssets/
|
||||
/[Ll]ogs/
|
||||
/[Pp]roject[Ss]ettings/
|
||||
/[Uu]ser[Ss]ettings/
|
||||
|
||||
manifest.json
|
||||
packages-lock.json
|
||||
```
|
||||
|
||||
Now your Atoms contributing experience will be as smooth as butter on ice.
|
||||
|
||||
If you are still confused, you can also [watch this step-by-step](https://youtu.be/BV22qR921Sw) guide on how to set it up.
|
||||
|
||||
## Style Guide
|
||||
|
||||
### Language Usage
|
||||
|
@ -47,40 +47,49 @@ namespace UnityAtoms.Editor
|
||||
|
||||
Directory.CreateDirectory(baseWritePath);
|
||||
|
||||
Scripts.Clear();
|
||||
var t = GenerationOptions;
|
||||
var idx = 0;
|
||||
while (t > 0)
|
||||
try
|
||||
{
|
||||
if (t % 2 == 1)
|
||||
AssetDatabase.StartAssetEditing();
|
||||
|
||||
Scripts.Clear();
|
||||
var t = GenerationOptions;
|
||||
var idx = 0;
|
||||
while (t > 0)
|
||||
{
|
||||
var atomType = AtomTypes.ALL_ATOM_TYPES[idx];
|
||||
if (t % 2 == 1)
|
||||
{
|
||||
var atomType = AtomTypes.ALL_ATOM_TYPES[idx];
|
||||
|
||||
templateVariables["VALUE_TYPE_NAME"] = atomType.IsValuePair ? $"{capitalizedValueType}Pair" : capitalizedValueType;
|
||||
var valueType = atomType.IsValuePair ? $"{capitalizedValueType}Pair" : baseTypeAccordingNested;
|
||||
templateVariables["VALUE_TYPE"] = valueType;
|
||||
templateVariables["VALUE_TYPE_NAME_NO_PAIR"] = capitalizedValueType;
|
||||
templateVariables["VALUE_TYPE_NAME"] = atomType.IsValuePair ? $"{capitalizedValueType}Pair" : capitalizedValueType;
|
||||
var valueType = atomType.IsValuePair ? $"{capitalizedValueType}Pair" : baseTypeAccordingNested;
|
||||
templateVariables["VALUE_TYPE"] = valueType;
|
||||
templateVariables["VALUE_TYPE_NAME_NO_PAIR"] = capitalizedValueType;
|
||||
|
||||
var resolvedRelativeFilePath = Templating.ResolveVariables(templateVariables: templateVariables,
|
||||
toResolve: atomType.RelativeFileNameAndPath);
|
||||
var targetPath = Path.Combine(baseWritePath, resolvedRelativeFilePath);
|
||||
var resolvedRelativeFilePath = Templating.ResolveVariables(templateVariables: templateVariables,
|
||||
toResolve: atomType.RelativeFileNameAndPath);
|
||||
var targetPath = Path.Combine(baseWritePath, resolvedRelativeFilePath);
|
||||
|
||||
var newCreated = !File.Exists(targetPath);
|
||||
var newCreated = !File.Exists(targetPath);
|
||||
|
||||
Generator.Generate(new AtomReceipe(atomType, valueType), baseWritePath, templates,
|
||||
templateConditions, templateVariables);
|
||||
Generator.Generate(new AtomReceipe(atomType, valueType), baseWritePath, templates,
|
||||
templateConditions, templateVariables);
|
||||
|
||||
if (newCreated) AssetDatabase.ImportAsset(targetPath);
|
||||
var ms = AssetDatabase.LoadAssetAtPath<MonoScript>(targetPath);
|
||||
Scripts.Add(ms);
|
||||
if (newCreated) AssetDatabase.ImportAsset(targetPath);
|
||||
var ms = AssetDatabase.LoadAssetAtPath<MonoScript>(targetPath);
|
||||
Scripts.Add(ms);
|
||||
}
|
||||
else
|
||||
{
|
||||
Scripts.Add(null);
|
||||
}
|
||||
|
||||
idx++;
|
||||
t >>= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Scripts.Add(null);
|
||||
}
|
||||
|
||||
idx++;
|
||||
t >>= 1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
AssetDatabase.StopAssetEditing();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user