-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,31 @@ | ||
# MGS.Graph | ||
[TOC] | ||
|
||
# MGS.Graph | ||
|
||
## Summary | ||
- Unity plugin for graph. | ||
|
||
## Environment | ||
- .Net Framework 3.5 or above. | ||
- Unity 5.0 or above. | ||
|
||
## Platform | ||
|
||
- Windows | ||
|
||
## Demand | ||
|
||
- Load Texture2D from GIF file. | ||
|
||
## Module | ||
|
||
- GraphUtility | ||
|
||
- ImageUtility | ||
|
||
## Demo | ||
- Demos in the path "MGS.Packages/Graph/Demo/" provide reference to you. | ||
|
||
------ | ||
|
||
Copyright © 2022 Mogoson. [email protected] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/************************************************************************* | ||
* Copyright © 2022 Mogoson. All rights reserved. | ||
*------------------------------------------------------------------------ | ||
* File : LoadGifDemo.cs | ||
* Description : | ||
*------------------------------------------------------------------------ | ||
* Author : Mogoson | ||
* Version : 1.0 | ||
* Date : 11/30/2022 | ||
* Description : Initial development version. | ||
*************************************************************************/ | ||
|
||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
namespace MGS.Graph.Demo | ||
{ | ||
public class LoadGifDemo : MonoBehaviour | ||
{ | ||
int index = 0; | ||
|
||
void Start() | ||
{ | ||
var gifFile = string.Format("{0}/MGS.Packages/Graph/Demo/Textures/Running.gif", Application.dataPath); | ||
StartCoroutine(GraphUtility.LoadGifFromFile(gifFile, OnLoadProgress)); | ||
} | ||
|
||
void OnLoadProgress(float progress, Texture2D texture) | ||
{ | ||
transform.GetChild(index).GetComponent<RawImage>().texture = texture; | ||
index++; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
[TOC] | ||
|
||
# MGS.Graph | ||
|
||
## Summary | ||
- Unity plugin for graph. | ||
|
||
## Environment | ||
- .Net Framework 3.5 or above. | ||
- Unity 5.0 or above. | ||
|
||
## Platform | ||
|
||
- Windows | ||
|
||
## Version | ||
|
||
- 0.1.0 | ||
|
||
## Demand | ||
|
||
- Load Texture2D from GIF file. | ||
|
||
## Module | ||
|
||
- GraphUtility | ||
|
||
- ImageUtility | ||
|
||
## Demo | ||
- Demos in the path "MGS.Packages/Graph/Demo/" provide reference to you. | ||
|
||
## Source | ||
|
||
- https://github.com/mogoson/MGS.Graph | ||
|
||
------ | ||
|
||
Copyright © 2022 Mogoson. [email protected] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/************************************************************************* | ||
* Copyright © 2021 Mogoson. All rights reserved. | ||
*------------------------------------------------------------------------ | ||
* File : GraphUtility.cs | ||
* Description : Utility for unity Graph. | ||
*------------------------------------------------------------------------ | ||
* Author : Mogoson | ||
* Version : 1.0 | ||
* Date : 10/04/2021 | ||
* Description : Initial development version. | ||
*************************************************************************/ | ||
|
||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Drawing.Imaging; | ||
using UnityEngine; | ||
|
||
namespace MGS.Graph | ||
{ | ||
/// <summary> | ||
/// Utility for unity Graph. | ||
/// </summary> | ||
public sealed class GraphUtility | ||
{ | ||
/// <summary> | ||
/// Load gif from file. | ||
/// </summary> | ||
/// <param name="file"></param> | ||
/// <param name="progress"></param> | ||
/// <param name="finished"></param> | ||
/// <returns></returns> | ||
public static IEnumerator LoadGifFromFile(string file, | ||
Action<float, Texture2D> progress, Action<List<Texture2D>> finished = null) | ||
{ | ||
var frames = ImageUtility.GetFrames(file); | ||
var index = 0; | ||
var textures = new List<Texture2D>(); | ||
foreach (var frame in frames) | ||
{ | ||
var buffer = ImageUtility.GetBuffer(frame, ImageFormat.Png); | ||
var texture = new Texture2D(frame.Width, frame.Height); | ||
texture.LoadImage(buffer); | ||
textures.Add(texture); | ||
|
||
index++; | ||
if (progress != null) | ||
{ | ||
progress.Invoke((float)index / frames.Length, texture); | ||
} | ||
yield return null; | ||
} | ||
if (finished != null) | ||
{ | ||
finished.Invoke(textures); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.