Skip to content

Commit

Permalink
feat: impl
Browse files Browse the repository at this point in the history
  • Loading branch information
mob-sakai committed Dec 28, 2020
0 parents commit 2a7baca
Show file tree
Hide file tree
Showing 53 changed files with 8,682 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
/[Bb]uilds/
/Assets/AssetStoreTools*

# Autogenerated VS/MD solution and project files
ExportedObj/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd


# Unity3D generated meta files
*.pidb.meta

# Unity3D Generated File On Crash Reports
sysinfo.txt

# Mac
*.DS_Store

# Builds
*.apk


# Packages
*.unitypackage
Samples~/Demo.meta
88 changes: 88 additions & 0 deletions AtlasImage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.U2D;
using UnityEngine.UI;

namespace Coffee.UIExtensions
{
/// <summary>
/// Atlas image.
/// </summary>
public class AtlasImage : Image
{
[SerializeField] private string m_SpriteName;
[SerializeField] private SpriteAtlas m_SpriteAtlas;
private string _lastSpriteName = "";


/// <summary>Sprite Name. If there is no other sprite with the same name in the atlas, AtlasImage will display the default sprite.</summary>
public string spriteName
{
get { return m_SpriteName; }
set
{
if (m_SpriteName != value)
{
m_SpriteName = value;
SetAllDirty();
}
}
}

/// <summary>SpriteAtlas. Get and set atlas assets created by AtlasMaker.</summary>
public SpriteAtlas spriteAtlas
{
get { return m_SpriteAtlas; }
set
{
if (m_SpriteAtlas != value)
{
m_SpriteAtlas = value;
SetAllDirty();
}
}
}

/// <summary>
/// Sets the material dirty.
/// </summary>
public override void SetMaterialDirty()
{
// Changing sprites from Animation.
// If the "sprite" is changed by an animation or script, it will be reflected in the sprite name.
if (_lastSpriteName == spriteName && sprite)
{
m_SpriteName = sprite.name.Replace("(Clone)", "");
}

if (_lastSpriteName != spriteName)
{
_lastSpriteName = spriteName;
sprite = spriteAtlas ? spriteAtlas.GetSprite(spriteName) : null;
}

base.SetMaterialDirty();
}


protected AtlasImage()
: base()
{
}

/// <summary>
/// Raises the populate mesh event.
/// </summary>
/// <param name="toFill">To fill.</param>
protected override void OnPopulateMesh(VertexHelper toFill)
{
if (!overrideSprite)
{
toFill.Clear();
return;
}
base.OnPopulateMesh(toFill);
}
}
}
12 changes: 12 additions & 0 deletions AtlasImage.cs.meta

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

15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Changelog

## [v0.1.0](https://github.com/mob-sakai/AtlasImage/tree/v0.1.0) (2018-04-30)

[Full Changelog](https://github.com/mob-sakai/AtlasImage/compare/6159735114a782ced87eb55c93edad44cad146c4...v0.1.0)

**Implemented enhancements:**

- Feature: You can edit the border in the preview window [\#3](https://github.com/mob-sakai/AtlasImage/issues/3)
- Feature: In the inspector, sprite selection window shows only sprites in SpriteAtlas [\#2](https://github.com/mob-sakai/AtlasImage/issues/2)
- Feature: Sprite for renderring can be changed using a SpriteAtlas and a sprite name [\#1](https://github.com/mob-sakai/AtlasImage/issues/1)



\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
8 changes: 8 additions & 0 deletions CHANGELOG.md.meta

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

12 changes: 12 additions & 0 deletions Coffee.AtlasImage.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "Coffee.AtlasImage",
"references": [],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}
7 changes: 7 additions & 0 deletions Coffee.AtlasImage.asmdef.meta

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

9 changes: 9 additions & 0 deletions Editor.meta

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

Binary file added Editor/AtlasImage Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
106 changes: 106 additions & 0 deletions Editor/AtlasImage Icon.png.meta

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

Loading

0 comments on commit 2a7baca

Please sign in to comment.