Skip to content

Commit

Permalink
add asmdef
Browse files Browse the repository at this point in the history
  • Loading branch information
elringus committed Jul 21, 2019
1 parent 01c8ff1 commit f4b028f
Show file tree
Hide file tree
Showing 21 changed files with 228 additions and 45 deletions.
8 changes: 8 additions & 0 deletions Assets/SpriteGlow/Resources.meta

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

8 changes: 8 additions & 0 deletions Assets/SpriteGlow/Resources/SpriteGlow.meta

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

8 changes: 8 additions & 0 deletions Assets/SpriteGlow/Resources/SpriteGlow/Shaders.meta

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

File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions Assets/SpriteGlow/Runtime.meta

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

3 changes: 3 additions & 0 deletions Assets/SpriteGlow/Runtime/Elringus.SpriteGlow.Runtime.asmdef
@@ -0,0 +1,3 @@
{
"name": "Elringus.SpriteGlow.Runtime"
}

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

Expand Up @@ -13,32 +13,32 @@ public class SpriteGlowEffect : MonoBehaviour
public SpriteRenderer Renderer { get; private set; }
public Color GlowColor
{
get { return glowColor; }
get => glowColor;
set { if (glowColor != value) { glowColor = value; SetMaterialProperties(); } }
}
public float GlowBrightness
{
get { return glowBrightness; }
get => glowBrightness;
set { if (glowBrightness != value) { glowBrightness = value; SetMaterialProperties(); } }
}
public int OutlineWidth
{
get { return outlineWidth; }
get => outlineWidth;
set { if (outlineWidth != value) { outlineWidth = value; SetMaterialProperties(); } }
}
public float AlphaThreshold
{
get { return alphaThreshold; }
get => alphaThreshold;
set { if (alphaThreshold != value) { alphaThreshold = value; SetMaterialProperties(); } }
}
public bool DrawOutside
{
get { return drawOutside; }
get => drawOutside;
set { if (drawOutside != value) { drawOutside = value; SetMaterialProperties(); } }
}
public bool EnableInstancing
{
get { return enableInstancing; }
get => enableInstancing;
set { if (enableInstancing != value) { enableInstancing = value; SetMaterialProperties(); } }
}

Expand Down
File renamed without changes.
Expand Up @@ -5,20 +5,20 @@ namespace SpriteGlow
{
public class SpriteGlowMaterial : Material
{
public Texture SpriteTexture { get { return mainTexture; } }
public bool DrawOutside { get { return IsKeywordEnabled(outsideMaterialKeyword); } }
public bool InstancingEnabled { get { return enableInstancing; } }
public Texture SpriteTexture => mainTexture;
public bool DrawOutside => IsKeywordEnabled(outsideMaterialKeyword);
public bool InstancingEnabled => enableInstancing;

private const string outlineShaderName = "Sprites/Outline";
private const string outsideMaterialKeyword = "SPRITE_OUTLINE_OUTSIDE";
private static readonly Shader outlineShader = Shader.Find(outlineShaderName);

private static List<SpriteGlowMaterial> sharedMaterials = new List<SpriteGlowMaterial>();
private static readonly Shader outlineShader = Shader.Find(outlineShaderName);
private static readonly List<SpriteGlowMaterial> sharedMaterials = new List<SpriteGlowMaterial>();

public SpriteGlowMaterial (Texture spriteTexture, bool drawOutside = false, bool instancingEnabled = false)
: base(outlineShader)
{
if (!outlineShader) Debug.LogError(string.Format("{0} shader not found. Make sure the shader is included to the build.", outlineShaderName));
if (!outlineShader) Debug.LogError($"`{outlineShaderName}` shader not found. Make sure the shader is included to the build.");

mainTexture = spriteTexture;
if (drawOutside) EnableKeyword(outsideMaterialKeyword);
Expand Down
11 changes: 11 additions & 0 deletions Assets/SpriteGlow/package.json
@@ -0,0 +1,11 @@
{
"name": "com.elringus.spriteglow",
"version": "1.7.0",
"displayName": "SpriteGlow",
"description": "A sprite glow effect for Unity game engine",
"unity": "2019.1",
"author": {
"name": "Elringus",
"url": "https://elringus.me"
}
}
7 changes: 7 additions & 0 deletions Assets/SpriteGlow/package.json.meta

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

108 changes: 96 additions & 12 deletions Assets/ThirdParty/UnityCommon/Editor/PackageExporter.cs
@@ -1,4 +1,6 @@
using System;
// WARNING: Don't forget to keep compatibility with .NET 3.5 and Unity 2018.1.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand All @@ -21,13 +23,17 @@ public interface IProcessor
private static string PackageName { get { return PlayerPrefs.GetString(prefsPrefix + "PackageName"); } set { PlayerPrefs.SetString(prefsPrefix + "PackageName", value); } }
private static string Copyright { get { return PlayerPrefs.GetString(prefsPrefix + "Copyright"); } set { PlayerPrefs.SetString(prefsPrefix + "Copyright", value); } }
private static string LicenseFilePath { get { return PlayerPrefs.GetString(prefsPrefix + "LicenseFilePath"); } set { PlayerPrefs.SetString(prefsPrefix + "LicenseFilePath", value); } }
private static string LicenseAssetPath { get { return AssetsPath + "/" + defaultLicenseFileName + ".txt"; } }
private static string LicenseAssetPath { get { return AssetsPath + "/" + defaultLicenseFileName + ".md"; } }
private static string AssetsPath { get { return "Assets/" + PackageName; } }
private static string OutputPath { get { return PlayerPrefs.GetString(prefsPrefix + "OutputPath"); } set { PlayerPrefs.SetString(prefsPrefix + "OutputPath", value); } }
private static string OutputFileName { get { return PackageName; } }
private static string IgnoredAssetGUIds { get { return PlayerPrefs.GetString(prefsPrefix + "IgnoredAssetGUIds"); } set { PlayerPrefs.SetString(prefsPrefix + "IgnoredAssetGUIds", value); } }
private static bool IsAnyPathsIgnored { get { return !string.IsNullOrEmpty(IgnoredAssetGUIds); } }
private static bool IsReadyToExport { get { return !string.IsNullOrEmpty(OutputPath) && !string.IsNullOrEmpty(OutputFileName); } }
private static bool ExportAsUnityPackage { get { return PlayerPrefs.GetInt(prefsPrefix + "ExportAsUnityPackage", 1) == 1; } set { PlayerPrefs.SetInt(prefsPrefix + "ExportAsUnityPackage", value ? 1 : 0); } }
private static bool PublishToGit { get { return PlayerPrefs.GetInt(prefsPrefix + "PublishToGit", 0) == 1; } set { PlayerPrefs.SetInt(prefsPrefix + "PublishToGit", value ? 1 : 0); } }
private static string GitShellPath { get { return PlayerPrefs.GetString(prefsPrefix + "GitShellPath"); } set { PlayerPrefs.SetString(prefsPrefix + "GitShellPath", value); } }
private static string GitScriptPath { get { return PlayerPrefs.GetString(prefsPrefix + "GitScriptPath"); } set { PlayerPrefs.SetString(prefsPrefix + "GitScriptPath", value); } }

private const string prefsPrefix = "PackageExporter.";
private const string autoRefreshKey = "kAutoRefresh";
Expand All @@ -49,25 +55,51 @@ public static void RemoveIgnoredAsset (string assetPath)
if (!IgnoredAssetGUIds.Contains(guid)) IgnoredAssetGUIds = IgnoredAssetGUIds.Replace(guid, string.Empty);
}

private void Awake ()
private void OnEnable ()
{
if (string.IsNullOrEmpty(PackageName))
PackageName = Application.productName;
if (string.IsNullOrEmpty(LicenseFilePath))
LicenseFilePath = Application.dataPath.Replace("Assets", "") + defaultLicenseFileName;
Initialize();
}

private void OnEnable ()
private void OnGUI ()
{
DeserealizeIgnoredAssets();
RenderGUI();
}

#if UNITY_2019_1_OR_NEWER
[SettingsProvider]
internal static SettingsProvider CreateProjectSettingsProvider ()
{
var provider = new SettingsProvider("Project/Package Exporter", SettingsScope.Project);
provider.activateHandler += (a, b) => Initialize();
provider.guiHandler += id => RenderGUI();
return provider;
}
#elif UNITY_2018_3_OR_NEWER
[SettingsProvider]
internal static SettingsProvider CreateProjectSettingsProvider ()
{
var provider = new SettingsProvider("Project/Package Exporter");
provider.activateHandler += (a, b) => Initialize();
provider.guiHandler += id => RenderGUI();
return provider;
}
#else
[MenuItem("Edit/Project Settings/Package Exporter")]
private static void OpenSettingsWindow ()
{
var window = GetWindow<PackageExporter>();
window.Show();
}
#endif

private static void Initialize ()
{
if (string.IsNullOrEmpty(PackageName))
PackageName = Application.productName;
if (string.IsNullOrEmpty(LicenseFilePath))
LicenseFilePath = Application.dataPath.Replace("Assets", "") + defaultLicenseFileName;
DeserealizeIgnoredAssets();
}

[MenuItem("Assets/+ Export Package", priority = 20)]
private static void ExportPackage ()
Expand All @@ -76,7 +108,7 @@ private static void ExportPackage ()
ExportPackageImpl();
}

private void OnGUI ()
private static void RenderGUI ()
{
EditorGUILayout.LabelField("Package Exporter Settings", EditorStyles.boldLabel);
EditorGUILayout.HelpBox("Settings are stored in editor's PlayerPrefs and won't be exposed in builds or project assets.", MessageType.Info);
Expand All @@ -90,6 +122,23 @@ private void OnGUI ()
if (GUILayout.Button("Select", EditorStyles.miniButton, GUILayout.Width(65)))
OutputPath = EditorUtility.OpenFolderPanel("Output Path", "", "");
}
ExportAsUnityPackage = EditorGUILayout.Toggle("Export As Unity Package", ExportAsUnityPackage);
PublishToGit = EditorGUILayout.Toggle("Publish To Git", PublishToGit);
if (PublishToGit)
{
using (new EditorGUILayout.HorizontalScope())
{
GitShellPath = EditorGUILayout.TextField("Git Shell Path", GitShellPath);
if (GUILayout.Button("Select", EditorStyles.miniButton, GUILayout.Width(65)))
GitShellPath = EditorUtility.OpenFilePanelWithFilters("Git Shell Path", "", new[] { "Executable", "exe" });
}
using (new EditorGUILayout.HorizontalScope())
{
GitScriptPath = EditorGUILayout.TextField("Git Script Path", GitScriptPath);
if (GUILayout.Button("Select", EditorStyles.miniButton, GUILayout.Width(65)))
GitScriptPath = EditorUtility.OpenFilePanelWithFilters("Git Script Path", "", new[] { "Shell", "sh" });
}
}
EditorGUILayout.Space();

EditorGUI.BeginChangeCheck();
Expand Down Expand Up @@ -167,7 +216,7 @@ private static void ExportPackageImpl ()
var needToAddLicense = File.Exists(LicenseFilePath);
if (needToAddLicense)
{
File.Copy(LicenseFilePath, LicenseAssetPath);
File.Copy(LicenseFilePath, LicenseAssetPath, true);
AssetDatabase.ImportAsset(LicenseAssetPath, ImportAssetOptions.ForceSynchronousImport);
}

Expand Down Expand Up @@ -201,7 +250,42 @@ private static void ExportPackageImpl ()

// Export the package.
DisplayProgressBar("Writing package file...", .5f);
AssetDatabase.ExportPackage(AssetsPath, OutputPath + "/" + OutputFileName + ".unitypackage", ExportPackageOptions.Recurse);
if (ExportAsUnityPackage)
AssetDatabase.ExportPackage(AssetsPath, OutputPath + "/" + OutputFileName + ".unitypackage", ExportPackageOptions.Recurse);
else
{
try
{
var sourcePath = Path.Combine(Application.dataPath, PackageName).Replace("\\", "/");
var destPath = Path.Combine(OutputPath, OutputFileName).Replace("\\", "/"); ;
var sourceDir = new DirectoryInfo(sourcePath);

var hiddenFolders = sourceDir.GetDirectories("*", SearchOption.AllDirectories)
.Where(d => (d.Attributes & FileAttributes.Hidden) != 0)
.Select(d => d.FullName).ToList();
var packageFiles = sourceDir.GetFiles("*.*", SearchOption.AllDirectories)
.Where(f => (f.Attributes & FileAttributes.Hidden) == 0 &&
!hiddenFolders.Any(d => f.FullName.StartsWith(d))).ToList();

foreach (var packageFile in packageFiles)
{
var sourceFilePath = packageFile.FullName.Replace("\\", "/");
var destFilePath = sourceFilePath.Replace(sourcePath, destPath);
Directory.CreateDirectory(Path.GetDirectoryName(destFilePath));
File.Copy(sourceFilePath, destFilePath, true);
}
}
catch (Exception e) { Debug.LogError(e.Message); }
}

// Publish GitHub branch.
if (PublishToGit)
{
using (var proccess = System.Diagnostics.Process.Start(GitShellPath, $"\"{GitScriptPath}\""))
{
proccess.WaitForExit();
}
}

// Restore modified scripts.
DisplayProgressBar("Restoring modified scripts...", .75f);
Expand Down
7 changes: 3 additions & 4 deletions Packages/manifest.json
@@ -1,9 +1,8 @@
{
"dependencies": {
"com.unity.package-manager-ui": "2.0.7",
"com.unity.postprocessing": "2.1.6",
"com.unity.render-pipelines.lightweight": "4.10.0-preview",
"com.unity.shadergraph": "4.10.0-preview",
"com.unity.package-manager-ui": "2.1.2",
"com.unity.postprocessing": "2.1.7",
"com.unity.render-pipelines.lightweight": "5.16.1",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.assetbundle": "1.0.0",
Expand Down

0 comments on commit f4b028f

Please sign in to comment.