Skip to content

Commit

Permalink
fixes build
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkSuckerberg committed Mar 14, 2021
1 parent 719afbc commit cf3b3f6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
26 changes: 17 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ jobs:
createRelease:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.createReleaseStep.outputs.upload_url }}
steps:
- name: Create Release
id: createRelease
id: createReleaseStep
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -27,9 +29,12 @@ jobs:
buildForAllSupportedPlatforms:
name: Build for ${{ matrix.targetPlatform }}
runs-on: ubuntu-latest
needs: createRelease
strategy:
fail-fast: false
matrix:
projectPath:
- Blocktest
targetPlatform:
- StandaloneOSX # Build a macOS standalone (Intel 64-bit).
- StandaloneWindows # Build a Windows standalone.
Expand All @@ -42,27 +47,30 @@ jobs:

- uses: actions/cache@v2
with:
path: Library
path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.targetPlatform }}
restore-keys: Library-

- uses: game-ci/unity-builder@v2
id: build
with:
unityVersion: 2020.2.5f1
projectPath: ${{ matrix.projectPath }}
targetPlatform: ${{ matrix.targetPlatform }}

- uses: actions/upload-artifact@v2
with:
name: Build-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
- name: Zip build
run: |
pushd build/${{ matrix.targetPlatform }}
zip -r ../../Build-${{ matrix.targetPlatform }}.zip .
popd
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.createRelease.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: build/${{ matrix.targetPlatform }}
asset_name: Build-${{ matrix.targetPlatform }}
upload_url: ${{ needs.createRelease.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./Build-${{ matrix.targetPlatform }}.zip
asset_name: Build-${{ matrix.targetPlatform }}.zip
asset_content_type: application/zip
2 changes: 1 addition & 1 deletion Blocktest/Assets/Scripts/Block System/BlockManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public Block(int id, string myName, Sprite mySprite, AudioClip place, bool doesS
placeSound = place;
blockSmoothing = doesSmooth;
if(doesSmooth) {
spriteSheet = new SpriteSheet(blockSprite.texture);
spriteSheet = new SpriteSheet("Sprites/" + blockSprite.texture.name);
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions Blocktest/Assets/Scripts/SpriteSheets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,31 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

[System.Serializable]
public class SpriteSheet
{
public Texture2D Texture;

public Dictionary<string, Sprite> spritesDict = new Dictionary<string, Sprite>();

#if UNITY_EDITOR
public SpriteSheet(Texture2D texture)
{
Texture = texture;

string path = AssetDatabase.GetAssetPath(Texture).Replace("Assets/Resources/", null);
Sprite[] sprites = Resources.LoadAll<Sprite>(path.Remove(path.Length - 4));
foreach (Sprite sprite in sprites)
{
spritesDict[sprite.name] = sprite;
}
}
#endif

public SpriteSheet(string texturePath)
{
string path = texturePath.Replace("Assets/Resources/", null);
Sprite[] sprites = Resources.LoadAll<Sprite>(path.Remove(path.Length - 4));
Sprite[] sprites = Resources.LoadAll<Sprite>(path);
foreach (Sprite sprite in sprites)
{
spritesDict[sprite.name] = sprite;
Expand Down

0 comments on commit cf3b3f6

Please sign in to comment.