Skip to content

Commit

Permalink
Embed shaders bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoco007 committed Jan 7, 2021
1 parent 75e9650 commit 56540cf
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
8 changes: 3 additions & 5 deletions Source/CustomAvatar/CustomAvatar.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,14 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="manifest.json" />
<EmbeddedResource Include="Views\Mirror.bsml" />
<EmbeddedResource Include="Views\Settings.bsml" />
<EmbeddedResource Include="Resources\icon.png" />
<EmbeddedResource Include="Resources\mystery-man.png" />
<EmbeddedResource Include="Resources\ban.png" />
<EmbeddedResource Include="Views\**\*.*" />
<EmbeddedResource Include="Resources\**\*.*" />
</ItemGroup>
<ItemGroup>
<CopyToOutput Include="$(ProjectDir)..\..\Packaging\CustomAvatar\**\*.*" />
</ItemGroup>
<ItemGroup>
<None Remove="Resources\shaders.assets" />
<None Remove="Views\Mirror.bsml" />
</ItemGroup>
<Target Name="Organize" AfterTargets="AfterBuild">
Expand Down
8 changes: 4 additions & 4 deletions Source/CustomAvatar/Utilities/ShaderLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

using System.Collections;
using System.Reflection;
using CustomAvatar.Logging;
using UnityEngine;
using Zenject;
Expand All @@ -25,9 +26,8 @@ namespace CustomAvatar.Utilities
internal class ShaderLoader : IInitializable
{
public bool hasErrors { get; private set; }

public Shader stereoMirrorShader;
public Shader unlitShader;
public Shader stereoMirrorShader { get; private set; }
public Shader unlitShader { get; private set; }

private readonly ILogger<ShaderLoader> _logger;

Expand All @@ -43,7 +43,7 @@ public void Initialize()

private IEnumerator GetShaders()
{
AssetBundleCreateRequest shadersBundleCreateRequest = AssetBundle.LoadFromFileAsync("CustomAvatars/Shaders/customavatars.assetbundle");
AssetBundleCreateRequest shadersBundleCreateRequest = AssetBundle.LoadFromStreamAsync(Assembly.GetExecutingAssembly().GetManifestResourceStream("CustomAvatar.Resources.shaders.assets"));
yield return shadersBundleCreateRequest;

if (!shadersBundleCreateRequest.isDone || !shadersBundleCreateRequest.assetBundle)
Expand Down
1 change: 0 additions & 1 deletion Source/CustomAvatar/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"SiraUtil"
],
"files": [
"CustomAvatars\\Shaders\\customavatars.assetbundle",
"DynamicOpenVR\\Actions\\customavatars.json",
"DynamicOpenVR\\Bindings\\customavatars_knuckles.json"
]
Expand Down

0 comments on commit 56540cf

Please sign in to comment.