-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
|
||
namespace nadena.dev.Av3BuildFramework | ||
{ | ||
[System.AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)] | ||
public class DefineAvatarBuildPlugin : System.Attribute | ||
{ | ||
private readonly string _qualifiedName; | ||
private readonly Type _type; | ||
|
||
public DefineAvatarBuildPlugin(string _qualifiedName, Type type) | ||
{ | ||
this._qualifiedName = _qualifiedName; | ||
this._type = type; | ||
} | ||
|
||
public string QualifiedName => _qualifiedName; | ||
public Type Type => _type; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.ComponentModel; | ||
|
||
namespace nadena.dev.Av3BuildFramework | ||
{ | ||
/*public enum ConstraintType | ||
{ | ||
RunsBefore, | ||
RunsAfter | ||
} | ||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)] | ||
public class PluginOrdering : System.Attribute | ||
{ | ||
private string _qualifiedName; | ||
private Type _pluginType; | ||
private ConstraintType _constraintType; | ||
private bool _required; | ||
public PluginOrdering | ||
}*/ | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
|
||
namespace nadena.dev.Av3BuildFramework | ||
{ | ||
public enum Phase | ||
{ | ||
Check, | ||
Generate, | ||
Transform, | ||
Optimize | ||
} | ||
|
||
[AttributeUsage(AttributeTargets.Class)] | ||
public class PluginPhase : System.Attribute | ||
{ | ||
private readonly Phase _phase; | ||
|
||
public PluginPhase(Phase phase) | ||
{ | ||
_phase = phase; | ||
} | ||
|
||
public Phase Phase => _phase; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Linq; | ||
|
||
namespace nadena.dev.build_framework | ||
{ | ||
[System.AttributeUsage(System.AttributeTargets.Assembly)] | ||
public class ExportsPlugin : System.Attribute | ||
{ | ||
public Type PluginType; | ||
|
||
public ExportsPlugin(Type pluginType) | ||
{ | ||
PluginType = pluginType; | ||
} | ||
} | ||
|
||
public abstract class Plugin | ||
{ | ||
public abstract string QualifiedName { get; } | ||
public virtual bool EnableByDefault => true; | ||
|
||
public abstract ImmutableList<PluginPass> Passes { | ||
get; | ||
} | ||
|
||
public virtual ImmutableList<string> RunsBefore => ImmutableList<string>.Empty; | ||
public virtual ImmutableList<string> RunsAfter => ImmutableList<string>.Empty; | ||
public virtual ImmutableList<string> RequiredPlugins => ImmutableList<string>.Empty; | ||
public virtual ImmutableList<string> RequiredPasses => ImmutableList<string>.Empty; | ||
} | ||
|
||
public abstract class PluginPass | ||
{ | ||
public virtual string DisplayName => GetType().Name; | ||
|
||
public virtual ImmutableList<string> RunsBefore => ImmutableList<string>.Empty; | ||
public virtual ImmutableList<string> RunsAfter => ImmutableList<string>.Empty; | ||
|
||
// Type or string | ||
public virtual IImmutableSet<object> CompatibleContexts => ImmutableHashSet<object>.Empty; | ||
public virtual IImmutableSet<Type> RequiredContexts => ImmutableHashSet<Type>.Empty; | ||
|
||
public abstract void Process(BuildContext context); | ||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using nadena.dev.build_framework.util; | ||
using UnityEditor; | ||
using UnityEngine; | ||
using VRC.SDK3.Avatars.Components; | ||
|
||
namespace nadena.dev.build_framework | ||
{ | ||
public class BuildContext | ||
{ | ||
private readonly VRCAvatarDescriptor _avatarDescriptor; | ||
private readonly GameObject _avatarRootObject; | ||
private readonly Transform _avatarRootTransform; | ||
|
||
public VRCAvatarDescriptor AvatarDescriptor => _avatarDescriptor; | ||
public GameObject AvatarRootObject => _avatarRootObject; | ||
public Transform AvatarRootTransform => _avatarRootTransform; | ||
public UnityEngine.Object AssetContainer { get; private set; } | ||
|
||
private Dictionary<Type, object> _contextData = new Dictionary<Type, object>(); | ||
|
||
public T Get<T>() where T : new() | ||
{ | ||
if (_contextData.TryGetValue(typeof(T), out var value)) | ||
{ | ||
return (T) value; | ||
} | ||
|
||
value = new T(); | ||
_contextData[typeof(T)] = value; | ||
return (T) value; | ||
} | ||
|
||
public BuildContext(GameObject obj, string assetRootPath) | ||
: this(obj.GetComponent<VRCAvatarDescriptor>(), assetRootPath) | ||
{ | ||
} | ||
|
||
public BuildContext(VRCAvatarDescriptor avatarDescriptor, string assetRootPath) | ||
{ | ||
_avatarDescriptor = avatarDescriptor; | ||
_avatarRootObject = avatarDescriptor.gameObject; | ||
_avatarRootTransform = avatarDescriptor.transform; | ||
|
||
// Ensure the target directory exists | ||
System.IO.Directory.CreateDirectory(assetRootPath); | ||
|
||
var avatarName = _avatarRootObject.name; | ||
var avatarPath = System.IO.Path.Combine(assetRootPath, avatarName) + ".asset"; | ||
|
||
AssetDatabase.GenerateUniqueAssetPath(avatarPath); | ||
AssetContainer = ScriptableObject.CreateInstance<GeneratedAssets>(); | ||
AssetDatabase.CreateAsset(AssetContainer, avatarPath); | ||
} | ||
|
||
public void Serialize() | ||
{ | ||
foreach (var asset in _avatarRootObject.ReferencedAssets(traverseSaved: false, includeScene: false)) | ||
{ | ||
AssetDatabase.AddObjectToAsset(asset, AssetContainer); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.