Skip to content

Commit

Permalink
更新到AutoUI-V0.033 添加图片外部配置,包括单独组件、首帧配置
Browse files Browse the repository at this point in the history
  • Loading branch information
Auto committed Apr 23, 2021
1 parent 4872481 commit 3ddbb59
Show file tree
Hide file tree
Showing 370 changed files with 958 additions and 8 deletions.
12 changes: 10 additions & 2 deletions Assets/AutoUI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
## 简介
- **AutoUI框架**来组织**页面**切换的通用逻辑。
- 只需定制每个**页面**的业务逻辑内容,将页面的切换交给框架来处理。
- *当前版本:* **AutoUI-V0.032**
- *当前版本:* **AutoUI-V0.033**
- 更新内容:
- 加入**串口通信组件**
- 加入 扩展 Ugui中Image的组件:**AutoUIImage**,扩展了Image的外部配置能力,可将图片素材放到StreamingAssets中,通过组件中选择路径的方式配置图片。可在打包后外部配置图片。
- 扩展 AVProVideo 中 DisplayUGUI 的首帧图片外部配置功能。可将首帧图片放入StreamingAssets中,通过选择路径的方式配置图片。*类似其选择视频的方式*

- *Author:* [SmalBox](https://smalbox.top),*GitHub:* [GitHub/SmalBox](https://github.com/smalbox)

Expand Down Expand Up @@ -141,6 +142,13 @@
- *注:本组件需要实用工具中的AutoUIUtilities.GetInfoForConfig来帮助获取ComName配置文件。*
-Inspector 中可配置串口名、波特率等串口配置,当开启 isConfigComName 选项后,可修改配置文件中的 COMName 为实际串口名。
- 组件可接收串口发来的消息,并且自动计算校验码解析命令(已做了错误命令过滤),在成功接收到完整命令后调用 ComReceiveCallBack 回调。
- **扩展的UI组件**
- **AutoUIImage**
- 扩展 UIImage 的组件。主要为了可在外部配置替换图片素材。
- 新建一个空对象,用添加组件的方式添加 AutoUIImage ,通过打开文件管理器的方式选择StreamingAssets中的图片素材。*(也可手动填写图片路径)*
- **DisplayUGUI**
- 为其添加首帧图片外部配置功能。
- 在组件的属性面板中选择图片即可配置外部首帧图片。

## 高级功能
- **创建页面管理工具**
Expand Down
2 changes: 1 addition & 1 deletion Assets/Move.meta → Assets/AutoUI/Resources/Img.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/AutoUI/Resources/Img/Icon.meta

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

Binary file added Assets/AutoUI/Resources/Img/Icon/AutoLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions Assets/AutoUI/Resources/Img/Icon/AutoLogo.png.meta

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

1 change: 1 addition & 0 deletions Assets/AutoUI/Resources/Prefabs/Pages/StandbyPage.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ MonoBehaviour:
_noDefaultDisplay: 0
_displayInEditor: 1
_defaultTexture: {fileID: 0}
streamingAssetsImgPath:
--- !u!114 &2988001746311472917
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
8 changes: 8 additions & 0 deletions Assets/AutoUI/Scripts/AutoUICom.meta

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

24 changes: 24 additions & 0 deletions Assets/AutoUI/Scripts/AutoUICom/AutoUIImage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

[AddComponentMenu("AutoUI/AutoUIImage")]
public class AutoUIImage : Image
{
public string streamingAssetsImgPath;
protected override void OnEnable()
{
base.OnEnable();
// 读取图片
if (streamingAssetsImgPath != null && streamingAssetsImgPath != "")
{
Texture2D tx = new Texture2D(0, 0);
tx.LoadImage(
System.IO.File.ReadAllBytes(Application.streamingAssetsPath + streamingAssetsImgPath)
);
Sprite mySprite = Sprite.Create(tx, new Rect(0, 0, tx.width, tx.height), Vector2.zero);
sprite = mySprite;
}
}
}
11 changes: 11 additions & 0 deletions Assets/AutoUI/Scripts/AutoUICom/AutoUIImage.cs.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/AutoUI/Scripts/AutoUICom/Editor.meta

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

48 changes: 48 additions & 0 deletions Assets/AutoUI/Scripts/AutoUICom/Editor/AutoUIImageEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using UnityEngine;
using UnityEditor;
using SFB;

[CustomEditor(typeof(AutoUIImage))]
public class AutoUIImageEditor : Editor
{
AutoUIImage image;
private void OnEnable()
{
image = (AutoUIImage)target;
}
public override void OnInspectorGUI()
{
EditorGUILayout.BeginVertical();

image.sprite = (Sprite)EditorGUILayout.ObjectField("SourceImage", image.sprite, typeof(Sprite), true);
image.color = EditorGUILayout.ColorField("Color", image.color);
image.material = (Material)EditorGUILayout.ObjectField("Material", image.material, typeof(Material), true);
image.raycastTarget = EditorGUILayout.Toggle("RaycastTarget", image.raycastTarget);

EditorGUILayout.BeginHorizontal();
image.streamingAssetsImgPath = EditorGUILayout.TextField("StreamingAssetsImagtPath", image.streamingAssetsImgPath);
if (GUILayout.Button("选择图片"))
{
string[] selectedImg = StandaloneFileBrowser.OpenFilePanel("选择外部配置图片", Application.streamingAssetsPath, "png", false);
if (selectedImg.Length > 0)
{
string fullName = selectedImg[0].Replace("\\", "/").Replace(Application.streamingAssetsPath, "");
image.streamingAssetsImgPath = fullName;
// 读取图片
if (image.streamingAssetsImgPath != "")
{
Texture2D tx = new Texture2D(0, 0);
tx.LoadImage(
System.IO.File.ReadAllBytes(Application.streamingAssetsPath + image.streamingAssetsImgPath)
);
Sprite mySprite = Sprite.Create(tx, new Rect(0, 0, tx.width, tx.height), Vector2.zero);
image.sprite = mySprite;
}
}
GUIUtility.ExitGUI();
}
EditorGUILayout.EndHorizontal();

EditorGUILayout.EndVertical();
}
}
11 changes: 11 additions & 0 deletions Assets/AutoUI/Scripts/AutoUICom/Editor/AutoUIImageEditor.cs.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/AutoUI/Scripts/ThreePart.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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public class DisplayUGUI : UnityEngine.UI.MaskableGraphic
[SerializeField]
public Texture _defaultTexture;

public string streamingAssetsImgPath;

private int _lastWidth;
private int _lastHeight;
private bool _flipY;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,31 @@ public override void OnInspectorGUI()

EditorGUILayout.PropertyField(m_Movie);
EditorGUILayout.PropertyField(m_DefaultTexture);

EditorGUILayout.BeginHorizontal();
DisplayUGUI image = target as DisplayUGUI;
image.streamingAssetsImgPath = EditorGUILayout.TextField("StreamingAssetsImagtPath", image.streamingAssetsImgPath);
if (GUILayout.Button("Ñ¡ÔñͼƬ"))
{
string[] selectedImg = SFB.StandaloneFileBrowser.OpenFilePanel("Ñ¡ÔñÍⲿÅäÖÃͼƬ", Application.streamingAssetsPath, "png", false);
if (selectedImg.Length > 0)
{
string fullName = selectedImg[0].Replace("\\", "/").Replace(Application.streamingAssetsPath, "");
image.streamingAssetsImgPath = fullName;
// ¶ÁȡͼƬ
if (image.streamingAssetsImgPath != "")
{
Texture2D tx = new Texture2D(0, 0);
tx.LoadImage(
System.IO.File.ReadAllBytes(Application.streamingAssetsPath + image.streamingAssetsImgPath)
);
image._defaultTexture = tx;
}
}
GUIUtility.ExitGUI();
}
EditorGUILayout.EndHorizontal();

EditorGUILayout.PropertyField(m_NoDefaultDisplay);
EditorGUILayout.PropertyField(m_DisplayInEditor);
AppearanceControlsGUI();
Expand Down
File renamed without changes.
Loading

0 comments on commit 3ddbb59

Please sign in to comment.