Skip to content

Commit

Permalink
Merge pull request #1 from omn0mn0m/main
Browse files Browse the repository at this point in the history
Merging to catch up
  • Loading branch information
Nam Tran authored Aug 3, 2022
2 parents 8881812 + 5a9f43b commit 930f55a
Show file tree
Hide file tree
Showing 562 changed files with 57,398 additions and 2,875 deletions.
228 changes: 197 additions & 31 deletions .github/workflows/build.yml

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions .github/workflows/get_license.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Acquire activation file
on:
workflow_dispatch:

jobs:
activation:
name: Request manual activation file 🔑
runs-on: ubuntu-latest
steps:
# Request manual activation file
- name: Request manual activation file
id: getManualLicenseFile
uses: game-ci/unity-request-activation-file@v2
with:
unityVersion: 2019.4.25f1
# Upload artifact (Unity_v20XX.X.XXXX.alf)
- name: Expose as artifact
uses: actions/upload-artifact@v1
with:
name: ${{ steps.getManualLicenseFile.outputs.filePath }}
path: ${{ steps.getManualLicenseFile.outputs.filePath }}
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ jobs:
- uses: actions/setup-python@v2
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
dotnet-version: '6.0.100'
- uses: pre-commit/[email protected]
5 changes: 3 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
hooks:
- id: yamllint
- repo: https://github.com/psf/black
rev: 20.8b1
rev: 22.3.0
hooks:
- id: black
files: ^Support/
Expand All @@ -25,10 +25,11 @@ repos:
args:
- --load-plugins=pylint.extensions.redefined_variable_type,pylint.extensions.bad_builtin
- repo: https://github.com/dotnet/format
rev: "7e343070a0355c86f72bdee226b5e19ffcbac931" # "v5.0.211103"
rev: "aec7996c51c76644de6014bbcce9264d402a8db0"
hooks:
- id: dotnet-format
exclude: ^(Assets/ThirdParty)|(Packages/)
entry: dotnet-format whitespace
args:
- --folder
- --include
156 changes: 88 additions & 68 deletions Assets/Editor/BrushLister.cs
Original file line number Diff line number Diff line change
@@ -1,92 +1,112 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using TiltBrush;
using UnityEditor;
using UnityEngine;
using Valve.Newtonsoft.Json.Utilities;
using Object = UnityEngine.Object;
// Copyright 2021 The Tilt Brush Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

public class BrushLister : MonoBehaviour
namespace TiltBrush
{
private static StringBuilder brushList;
private static List<Guid> deprecated;
private static TiltBrushManifest brushManifest;
private static TiltBrushManifest brushManifestX;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;

[MenuItem("Tilt/Info/Brush Lister")]
static void ListBrushes()
public class BrushLister : MonoBehaviour
{
brushList = new StringBuilder();
private static StringBuilder brushList;
private static List<Guid> deprecated;
private static TiltBrushManifest brushManifest;
private static TiltBrushManifest brushManifestX;

Object[] defaultBrushes = Resources.LoadAll("Brushes", typeof(BrushDescriptor)).ToArray();
var experimentalBrushes = Resources.LoadAll("X/Brushes", typeof(BrushDescriptor)).ToArray();
[MenuItem("Tilt/Info/Brush Lister")]
static void ListBrushes()
{
brushList = new StringBuilder();

brushManifest = AssetDatabase.LoadAssetAtPath<TiltBrushManifest>("Assets/Manifest.asset");
brushManifestX = AssetDatabase.LoadAssetAtPath<TiltBrushManifest>("Assets/Manifest_Experimental.asset");
Object[] defaultBrushes = Resources.LoadAll("Brushes", typeof(BrushDescriptor)).ToArray();
var experimentalBrushes = Resources.LoadAll("X/Brushes", typeof(BrushDescriptor)).ToArray();

deprecated = new List<Guid>();
brushManifest = AssetDatabase.LoadAssetAtPath<TiltBrushManifest>("Assets/Manifest.asset");
brushManifestX = AssetDatabase.LoadAssetAtPath<TiltBrushManifest>("Assets/Manifest_Experimental.asset");

foreach (BrushDescriptor b in defaultBrushes) { if (b.m_Supersedes != null) deprecated.Add(b.m_Supersedes.m_Guid); }
foreach (BrushDescriptor b in experimentalBrushes) { if (b.m_Supersedes != null) deprecated.Add(b.m_Supersedes.m_Guid); }
deprecated = new List<Guid>();

foreach (BrushDescriptor brush in defaultBrushes) { AppendValidBrushString(brush, false); }
foreach (BrushDescriptor brush in experimentalBrushes)
{
try { AppendValidBrushString(brush, true); }
catch (Exception UnassignedReferenceException)
foreach (BrushDescriptor b in defaultBrushes)
{
Debug.Log($"Experimental brush loading error: {UnassignedReferenceException}");
if (b.m_Supersedes != null) deprecated.Add(b.m_Supersedes.m_Guid);
}
foreach (BrushDescriptor b in experimentalBrushes)
{
if (b.m_Supersedes != null) deprecated.Add(b.m_Supersedes.m_Guid);
}
}

Debug.Log($"{brushList}");
}
foreach (BrushDescriptor brush in defaultBrushes) { AppendValidBrushString(brush, false); }
foreach (BrushDescriptor brush in experimentalBrushes)
{
try { AppendValidBrushString(brush, true); }
catch (Exception UnassignedReferenceException)
{
Debug.Log($"Experimental brush loading error: {UnassignedReferenceException}");
}
}

public static string getBrushRowString(BrushDescriptor brush, bool experimental)
{
// Exclude legacy brushes
if (brush.m_SupersededBy != null) return "";
var brushScripts = sniffBrushScript(brush);
string prefabName = brush.m_BrushPrefab != null ? brush.m_BrushPrefab.name : "";
string materialName = brush.Material != null ? brush.Material.name : "";
string shaderName = brush.Material != null ? brush.Material.shader.name : "";
string manifest = "";
if (brushManifest.Brushes.Contains(brush) && brushManifestX.Brushes.Contains(brush))
{
manifest = "both";
Debug.Log($"{brushList}");
}
else if (brushManifest.Brushes.Contains(brush))

public static string getBrushRowString(BrushDescriptor brush, bool experimental)
{
manifest = "Default";
// Exclude legacy brushes
if (brush.m_SupersededBy != null) return "";
var brushScripts = sniffBrushScript(brush);
string prefabName = brush.m_BrushPrefab != null ? brush.m_BrushPrefab.name : "";
string materialName = brush.Material != null ? brush.Material.name : "";
string shaderName = brush.Material != null ? brush.Material.shader.name : "";
string manifest = "";
if (brushManifest.Brushes.Contains(brush) && brushManifestX.Brushes.Contains(brush))
{
manifest = "both";
}
else if (brushManifest.Brushes.Contains(brush))
{
manifest = "Default";
}
else if (brushManifestX.Brushes.Contains(brush))
{
manifest = "Experimental";
}
return $"{brush.m_Description}\t{brush.m_AudioReactive}\t{prefabName}\t{materialName}\t{shaderName}\t{brushScripts}\t{experimental}\t{brush.m_SupersededBy}\t{manifest}";
}
else if (brushManifestX.Brushes.Contains(brush))

public static string sniffBrushScript(BrushDescriptor brush)
{
manifest = "Experimental";
GameObject prefab = brush.m_BrushPrefab;
if (prefab == null) return "";
var componentNames = new List<string>();
foreach (MonoBehaviour c in prefab.GetComponents<MonoBehaviour>())
{
if (c.GetType() == typeof(MeshFilter) || c.GetType() == typeof(Transform) || c.GetType() == typeof(MeshRenderer)) continue;
componentNames.Add(c.GetType().ToString().Replace("TiltBrush.", ""));
}
return string.Join(",", componentNames);
}
return $"{brush.m_Description}\t{brush.m_AudioReactive}\t{prefabName}\t{materialName}\t{shaderName}\t{brushScripts}\t{experimental}\t{brush.m_SupersededBy}\t{manifest}";
}

public static string sniffBrushScript(BrushDescriptor brush)
{
GameObject prefab = brush.m_BrushPrefab;
if (prefab == null) return "";
var componentNames = new List<string>();
foreach (MonoBehaviour c in prefab.GetComponents<MonoBehaviour>())
public static void AppendValidBrushString(BrushDescriptor brush, bool experimental)
{
if (c.GetType() == typeof(MeshFilter) || c.GetType() == typeof(Transform) || c.GetType() == typeof(MeshRenderer)) continue;
componentNames.Add(c.GetType().ToString().Replace("TiltBrush.", ""));
if (deprecated.Contains(brush.m_Guid)) return;
var rowString = getBrushRowString(brush, experimental);
if (rowString != "") brushList.AppendLine($"{rowString}");
}
return string.Join(",", componentNames);
}

public static void AppendValidBrushString(BrushDescriptor brush, bool experimental)
{
if (deprecated.Contains(brush.m_Guid)) return;
var rowString = getBrushRowString(brush, experimental);
if (rowString != "") brushList.AppendLine($"{rowString}");
}

}
67 changes: 67 additions & 0 deletions Assets/Editor/BrushTagger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright 2021 The Tilt Brush Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Collections.Generic;
using System.Linq;
using UnityEditor;


namespace TiltBrush
{
public class BrushTagger
{
[MenuItem("Tilt/Rewrite Brush Tags")]
private static void TagBrushes()
{
var whiteboardBrushes = new List<string>
{
"Marker",
"TaperedMarker",
"SoftHighlighter",
"CelVinyl",
"Dots",
"Icing",
"Toon",
"Wire",
"MatteHull",
"ShinyHull",
"UnlitHull",
};

TiltBrushManifest brushManifest = AssetDatabase.LoadAssetAtPath<TiltBrushManifest>("Assets/Manifest.asset");
TiltBrushManifest brushManifestX = AssetDatabase.LoadAssetAtPath<TiltBrushManifest>("Assets/Manifest_Experimental.asset");

var guids = AssetDatabase.FindAssets("t:BrushDescriptor");
foreach (var guid in guids)
{
string path = AssetDatabase.GUIDToAssetPath(guid);
BrushDescriptor brush = AssetDatabase.LoadAssetAtPath<BrushDescriptor>(path);

brush.m_Tags = new List<string>();

EditorUtility.SetDirty(brush);

if (whiteboardBrushes.Contains(brush.DurableName)) brush.m_Tags.Add("whiteboard");
if (brushManifest.Brushes.Contains(brush)) brush.m_Tags.Add("default");
if (brushManifestX.Brushes.Contains(brush)) brush.m_Tags.Add("experimental");
if (brush.m_AudioReactive) brush.m_Tags.Add("audioreactive");

if (brush.m_BrushPrefab == null) continue;
if (brush.m_BrushPrefab.GetComponent<HullBrush>() != null) brush.m_Tags.Add("hull");
if (brush.m_BrushPrefab.GetComponent<GeniusParticlesBrush>() != null) brush.m_Tags.Add("particle");
if (brush.m_BrushPrefab.GetComponent<ParentBrush>() != null) brush.m_Tags.Add("broken");
}
}
}
}
3 changes: 3 additions & 0 deletions Assets/Editor/BrushTagger.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Assets/Editor/BuildTiltBrush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,15 @@ static void CommandLine()
// set externally?
i++;
}
else if (args[i] == "-androidTargetSdkVersion")
{
// Not supported in Open Brush (added to game-ci in https://github.com/game-ci/unity-builder/pull/298)
// By default, this field has no value, but if set, we need to skip it
if (!args[i + 1].StartsWith("-"))
{
i++;
}
}
else if (args[i] == "-androidVersionCode")
{
PlayerSettings.Android.bundleVersionCode = Int32.Parse(args[++i]);
Expand Down
23 changes: 16 additions & 7 deletions Assets/Editor/GlTF_EditorExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ private static void ExportBrushStrokes_gltf1()
binary: false,
doExtras: true,
gltfVersion: 1,
includeLocalMediaContent: false);
includeLocalMediaContent: false,
selfContained: true
);
}

[MenuItem("Tilt/glTF/Export Brush Strokes to glb v1", false, 3)]
Expand All @@ -111,7 +113,9 @@ private static void ExportBrushStrokes_glb1()
binary: true,
doExtras: false,
gltfVersion: 1,
includeLocalMediaContent: true);
includeLocalMediaContent: true,
selfContained: true
);
}

[MenuItem("Tilt/glTF/Export Brush Strokes to glTF v1", true)]
Expand Down Expand Up @@ -207,6 +211,14 @@ private static Dictionary<Guid, BrushDescriptor> GetBrushes()
cat.Add(desc.m_Guid, desc);
}

TiltBrushManifest experimentalManifest = AssetDatabase.LoadAssetAtPath<TiltBrushManifest>(
"Assets/Manifest_Experimental.asset");

foreach (BrushDescriptor desc in experimentalManifest.UniqueBrushes())
{
cat[desc.m_Guid] = desc;
}

return cat;
}

Expand Down Expand Up @@ -321,12 +333,9 @@ private static void GenerateShaders(string manifestPath, string exportRoot)
{
return null;
}
else if (values.Count > 1)
{
throw new ExportException(
"{0}: Too many cull modes: {1}", filename, values);
}

// Only use the first value
// TODO TubeToonInverted has two cull values
string value = values[0];
if (value == "off")
{
Expand Down
Loading

0 comments on commit 930f55a

Please sign in to comment.