添加项目文件。
6
.vsconfig
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"version": "1.0",
|
||||
"components": [
|
||||
"Microsoft.VisualStudio.Workload.ManagedGame"
|
||||
]
|
||||
}
|
||||
8
Assets/HGF.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0b1d569b6c27444382ba78f08496906
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/HGF/Scripts.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5211f5e940f29a42a987e2f71716b96
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/HGF/Scripts/Galgame.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df6ad89fd343e5743ad97bab26a958be
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
44
Assets/HGF/Scripts/Galgame/GalComponent_Choice.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ScenesScripts.GalPlot
|
||||
{
|
||||
/// <summary>
|
||||
/// 选项类
|
||||
/// </summary>
|
||||
public class GalComponent_Choice : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// 这个选项要跳转到的ID
|
||||
/// </summary>
|
||||
public string _JumpID;
|
||||
|
||||
/// <summary>
|
||||
/// 显示的文本
|
||||
/// </summary>
|
||||
public Text _Title;
|
||||
public void Init (string JumpID, string Title)
|
||||
{
|
||||
_JumpID = JumpID;
|
||||
_Title.text = Title;
|
||||
}
|
||||
/// <summary>
|
||||
/// 当玩家按下了选项
|
||||
/// </summary>
|
||||
public void Button_Click_JumpTo ()
|
||||
{
|
||||
|
||||
GalManager.PlotData.NowJumpID = _JumpID;
|
||||
GalManager.PlotData.IsBranch = true;
|
||||
GalManager_Text.IsCanJump = true;
|
||||
if (_JumpID == "-1")
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.gameObject.transform.parent.GetComponent<GalManager_Choice>().Button_Click_Choice();
|
||||
GameObject.Find("EventSystem").GetComponent<GalManager>().Button_Click_NextPlot();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/HGF/Scripts/Galgame/GalComponent_Choice.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d70b5e7b3b9866499c01173b32732a9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
333
Assets/HGF/Scripts/Galgame/GalManager.cs
Normal file
@@ -0,0 +1,333 @@
|
||||
using Common.Game;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using TetraCreations.Attributes;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.UI;
|
||||
using static ScenesScripts.GalPlot.GalManager.Struct_PlotData;
|
||||
|
||||
namespace ScenesScripts.GalPlot
|
||||
{
|
||||
public class GalManager : MonoBehaviour
|
||||
{
|
||||
[Title("当前对话")]
|
||||
///
|
||||
public GalManager_Text Gal_Text;
|
||||
|
||||
[Title("当前角色部分")]
|
||||
public GalManager_CharacterImg Gal_CharacterImg;
|
||||
|
||||
[Title("控制选项")]
|
||||
public GalManager_Choice Gal_Choice;
|
||||
|
||||
[Title("控制背景图片的组件")]
|
||||
public GalManager_BackImg Gal_BackImg;
|
||||
|
||||
/// <summary>
|
||||
/// 角色发言的AudioSource
|
||||
/// </summary>
|
||||
private AudioSource Gal_Voice;
|
||||
|
||||
/// <summary>
|
||||
/// 当前场景角色数量
|
||||
/// </summary>
|
||||
[Title("当前场景角色数量")]
|
||||
public int CharacterNum;
|
||||
private class CharacterConfig
|
||||
{
|
||||
public static GameConfig CharacterInfo = new($"{GameAPI.GetWritePath()}/Config/CharacterInfo.ini");
|
||||
public static GameConfig Department = new($"{GameAPI.GetWritePath()}/Config/Department.ini");
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 存储整个剧本的XML文档
|
||||
/// </summary>
|
||||
private XDocument PlotxDoc;
|
||||
public class Struct_PlotData
|
||||
{
|
||||
public string Title;
|
||||
public string Synopsis;
|
||||
public List<XElement> BranchPlot = new();
|
||||
public Queue<XElement> BranchPlotInfo = new();
|
||||
public Queue<XElement> MainPlot = new();
|
||||
public class Struct_Choice
|
||||
{
|
||||
public Struct_Choice (string Title, string JumpID)
|
||||
{
|
||||
this.Title = Title;
|
||||
this.JumpID = JumpID;
|
||||
}
|
||||
public string Title;
|
||||
public string JumpID;
|
||||
}
|
||||
public class Struct_CharacterInfo
|
||||
{
|
||||
public string CharacterID;
|
||||
public GameObject CharacterGameObject;
|
||||
public string Name;
|
||||
public string Affiliation;
|
||||
}
|
||||
public List<Struct_CharacterInfo> CharacterInfo = new();
|
||||
public List<Struct_Choice> ChoiceText = new();
|
||||
/// <summary>
|
||||
/// 当前的剧情节点
|
||||
/// </summary>
|
||||
public XElement NowPlotDataNode;
|
||||
|
||||
/// <summary>
|
||||
/// 当前是否为分支剧情节点
|
||||
/// </summary>
|
||||
public bool IsBranch = false;
|
||||
public string NowJumpID;
|
||||
|
||||
}
|
||||
public static Struct_PlotData PlotData = new();
|
||||
private void Start ()
|
||||
{
|
||||
Gal_Voice = this.gameObject.GetComponent<AudioSource>();
|
||||
ResetPlotData();
|
||||
StartCoroutine(LoadPlot());
|
||||
return;
|
||||
}
|
||||
/// <summary>
|
||||
/// 重置
|
||||
/// </summary>
|
||||
private void ResetPlotData ()
|
||||
{
|
||||
PlotData = new Struct_PlotData();
|
||||
return;
|
||||
}
|
||||
/// <summary>
|
||||
/// 解析框架文本
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerator LoadPlot ()
|
||||
{
|
||||
yield return null;
|
||||
try
|
||||
{
|
||||
|
||||
var _PlotText = Resources.Load<TextAsset>("TextAsset/Plots/Test").text;
|
||||
GameAPI.Print($"游戏剧本:{_PlotText}");
|
||||
PlotxDoc = XDocument.Parse(_PlotText);
|
||||
|
||||
//-----开始读取数据
|
||||
|
||||
foreach (var item in PlotxDoc.Root.Elements())
|
||||
{
|
||||
switch (item.Name.ToString())
|
||||
{
|
||||
case "title":
|
||||
{
|
||||
PlotData.Title = item.Value;
|
||||
break;
|
||||
}
|
||||
case "Synopsis":
|
||||
{
|
||||
PlotData.Synopsis = item.Value;
|
||||
break;
|
||||
}
|
||||
case "BranchPlot":
|
||||
{
|
||||
foreach (var BranchItem in item.Elements())
|
||||
{
|
||||
PlotData.BranchPlot.Add(BranchItem);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "MainPlot":
|
||||
{
|
||||
foreach (var MainPlotItem in item.Elements())
|
||||
{
|
||||
PlotData.MainPlot.Enqueue(MainPlotItem);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw new Exception("无法识别的根标签");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ex.Message != "无法识别的根标签")
|
||||
{
|
||||
|
||||
GameAPI.Print(ex.Message, "error");
|
||||
}
|
||||
}
|
||||
Button_Click_NextPlot();
|
||||
}
|
||||
/// <summary>
|
||||
/// 点击屏幕 下一句
|
||||
/// </summary>
|
||||
public void Button_Click_NextPlot ()
|
||||
{
|
||||
|
||||
if (PlotData.MainPlot.Count == 0)
|
||||
{
|
||||
GameAPI.Print("游戏结束!");
|
||||
return;
|
||||
}
|
||||
|
||||
//IsCanJump这里有问题,如果一直点击会为false,而不是说true,这是因为没有点击按钮 ,没有添加按钮
|
||||
if (GalManager_Text.IsSpeak || !GalManager_Text.IsCanJump) { return; }
|
||||
if (!PlotData.IsBranch)
|
||||
{
|
||||
PlotData.MainPlot.TryDequeue(out PlotData.NowPlotDataNode);//队列出队+内联 出一个temp节点
|
||||
PlotData.BranchPlotInfo.Clear();
|
||||
}
|
||||
else//当前为分支节点
|
||||
{
|
||||
//这块得妥善处理
|
||||
PlotData.NowPlotDataNode = GetBranchByID(PlotData.NowJumpID);
|
||||
}
|
||||
|
||||
PlotData.ChoiceText.Clear();
|
||||
if (PlotData.NowPlotDataNode == null)
|
||||
{
|
||||
GameAPI.Print("无效的剧情结点", "error");
|
||||
return;
|
||||
}
|
||||
switch (PlotData.NowPlotDataNode.Name.ToString())
|
||||
{
|
||||
case "AddCharacter"://处理添加角色信息的东西
|
||||
{
|
||||
var _ = new Struct_CharacterInfo();
|
||||
var _From = PlotData.NowPlotDataNode.Attribute("From").Value;
|
||||
var _CharacterId = PlotData.NowPlotDataNode.Attribute("CharacterID").Value;
|
||||
_.Name = CharacterConfig.CharacterInfo.GetValue(_From, "Name");
|
||||
_.CharacterID = _CharacterId;
|
||||
_.Affiliation = CharacterConfig.Department.GetValue(CharacterConfig.CharacterInfo.GetValue(_From, "Department"), "Name");
|
||||
|
||||
var _CameObj = Resources.Load<GameObject>("Common/Gameobject/Galgame/Img-Character");
|
||||
_CameObj.GetComponent<Image>().sprite = GameAPI.LoadTextureByIO($"{GameAPI.GetWritePath()}/static/Texture2D/Portrait/{CharacterConfig.CharacterInfo.GetValue(_From, "ResourcesPath")}/{CharacterConfig.CharacterInfo.GetValue(_From, "Portrait-Normall")}");
|
||||
_.CharacterGameObject = Instantiate(_CameObj, Gal_CharacterImg.gameObject.transform);
|
||||
|
||||
if (PlotData.NowPlotDataNode.Attributes("SendMessage").Count() != 0)
|
||||
{
|
||||
|
||||
_.CharacterGameObject.GetComponent<GalManager_CharacterAnimate>().Animate_StartOrOutside = PlotData.NowPlotDataNode.Attribute("SendMessage").Value;
|
||||
}
|
||||
|
||||
PlotData.CharacterInfo.Add(_);
|
||||
|
||||
Button_Click_NextPlot();
|
||||
break;
|
||||
}
|
||||
case "Speak": //处理发言
|
||||
{
|
||||
var _nodeinfo = GetCharacterObjectByName(PlotData.NowPlotDataNode.Attribute("CharacterID").Value);
|
||||
if (PlotData.NowPlotDataNode.Elements().Count() != 0) //有选项,因为他有子节点数目了
|
||||
{
|
||||
GalManager_Text.IsCanJump = false;
|
||||
foreach (var ClildItem in PlotData.NowPlotDataNode.Elements())
|
||||
{
|
||||
if (ClildItem.Name.ToString() == "Choice")
|
||||
PlotData.ChoiceText.Add(new Struct_Choice(ClildItem.Value, ClildItem.Attribute("JumpID").Value));
|
||||
|
||||
}
|
||||
Gal_Text.StartTextContent(PlotData.NowPlotDataNode.Attribute("Content").Value, _nodeinfo.Name, _nodeinfo.Affiliation, () =>
|
||||
{
|
||||
|
||||
foreach (var ClildItem in GalManager.PlotData.ChoiceText)
|
||||
{
|
||||
Gal_Choice.CreatNewChoice(ClildItem.JumpID, ClildItem.Title);
|
||||
}
|
||||
});
|
||||
}
|
||||
else Gal_Text.StartTextContent(PlotData.NowPlotDataNode.Attribute("Content").Value, _nodeinfo.Name, _nodeinfo.Affiliation);
|
||||
|
||||
//处理消息
|
||||
if (PlotData.NowPlotDataNode.Attributes("SendMessage").Count() != 0)
|
||||
SendCharMessage(_nodeinfo.CharacterID, PlotData.NowPlotDataNode.Attribute("SendMessage").Value);
|
||||
if (PlotData.NowPlotDataNode.Attributes("AudioPath").Count() != 0)
|
||||
StartCoroutine(PlayAudio(Gal_Voice, PlotData.NowPlotDataNode.Attribute("AudioPath").Value));
|
||||
break;
|
||||
}
|
||||
case "ChangeBackImg"://更换背景图片
|
||||
{
|
||||
var _Path = PlotData.NowPlotDataNode.Attribute("Path").Value;
|
||||
Gal_BackImg.SetImage(GameAPI.LoadTextureByIO(_Path));
|
||||
Button_Click_NextPlot();
|
||||
break;
|
||||
}
|
||||
case "DeleteCharacter":
|
||||
{
|
||||
DestroyCharacterByID(PlotData.NowPlotDataNode.Attribute("CharacterID").Value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (PlotData.BranchPlotInfo.Count == 0)
|
||||
{
|
||||
PlotData.IsBranch = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
public void Button_Click_FastMode ()
|
||||
{
|
||||
GalManager_Text.IsFastMode = true;
|
||||
return;
|
||||
}
|
||||
public Struct_CharacterInfo GetCharacterObjectByName (string ID)
|
||||
{
|
||||
return PlotData.CharacterInfo.Find(t => t.CharacterID == ID);
|
||||
}
|
||||
public XElement GetBranchByID (string ID)
|
||||
{
|
||||
if (PlotData.BranchPlotInfo.Count == 0)
|
||||
foreach (var item in PlotData.BranchPlot.Find(t => t.Attribute("ID").Value == ID).Elements())
|
||||
{
|
||||
PlotData.BranchPlotInfo.Enqueue(item);
|
||||
|
||||
}
|
||||
PlotData.BranchPlotInfo.TryDequeue(out XElement t);
|
||||
return t;
|
||||
}
|
||||
/// <summary>
|
||||
/// 销毁一个角色
|
||||
/// </summary>
|
||||
/// <param name="ID"></param>
|
||||
public void DestroyCharacterByID (string ID)
|
||||
{
|
||||
var _ = PlotData.CharacterInfo.Find(t => t.CharacterID == ID);
|
||||
SendCharMessage(ID, "Quit");
|
||||
PlotData.CharacterInfo.Remove(_);
|
||||
}
|
||||
public void SendCharMessage (string CharacterID, string Message)
|
||||
{
|
||||
var _t = GetCharacterObjectByName(CharacterID);
|
||||
_t.CharacterGameObject.GetComponent<GalManager_CharacterMessage>().HandleMessage(Message);
|
||||
}
|
||||
private IEnumerator PlayAudio (AudioSource audioSource, string fileName)
|
||||
{
|
||||
//获取.wav文件,并转成AudioClip
|
||||
GameAPI.Print($"{GameAPI.GetWritePath()}/{fileName}");
|
||||
UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip($"{GameAPI.GetWritePath()}/static/Audio/Plot/{fileName}", AudioType.MPEG);
|
||||
//等待转换完成
|
||||
yield return www.SendWebRequest();
|
||||
//获取AudioClip
|
||||
AudioClip audioClip = DownloadHandlerAudioClip.GetContent(www);
|
||||
//设置当前AudioSource组件的AudioClip
|
||||
audioSource.clip = audioClip;
|
||||
//播放声音
|
||||
audioSource.Play();
|
||||
}
|
||||
private void FixedUpdate ()
|
||||
{
|
||||
CharacterNum = PlotData.CharacterInfo.Count;
|
||||
}
|
||||
private void Update ()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/HGF/Scripts/Galgame/GalManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4187ce6bb31fd5443a2e7eb384144de7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
Assets/HGF/Scripts/Galgame/GalManager_BackImg.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ScenesScripts.GalPlot
|
||||
{
|
||||
|
||||
public class GalManager_BackImg : MonoBehaviour
|
||||
{
|
||||
private Image BackImg;
|
||||
private void Start ()
|
||||
{
|
||||
BackImg = this.gameObject.GetComponent<Image>();
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 直接传递图片
|
||||
/// </summary>
|
||||
/// <param name="ImgSprite"></param>
|
||||
public void SetImage (Sprite ImgSprite)
|
||||
{
|
||||
BackImg.sprite = ImgSprite;
|
||||
}
|
||||
/// <summary>
|
||||
/// 从Resources资源文件夹读图片
|
||||
/// </summary>
|
||||
/// <param name="ImgSpriteFilePath"></param>
|
||||
public void SetImage (string ImgSpriteFilePath)
|
||||
{
|
||||
BackImg.sprite = Resources.Load<Sprite>(ImgSpriteFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/HGF/Scripts/Galgame/GalManager_BackImg.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae12d1bbe863d1b41a47672fd1c49d9e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
190
Assets/HGF/Scripts/Galgame/GalManager_CharacterAnimate.cs
Normal file
@@ -0,0 +1,190 @@
|
||||
|
||||
using Common.Game;
|
||||
using DG.Tweening;
|
||||
using TetraCreations.Attributes;
|
||||
using UnityCustom;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ScenesScripts.GalPlot
|
||||
{
|
||||
public class GalManager_CharacterAnimate : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// 出入场出场动画
|
||||
/// </summary>
|
||||
[StringInList("ToShow", "Outside-ToLeft", "Outside-ToRight")] public string Animate_StartOrOutside = "ToShow";
|
||||
/// <summary>
|
||||
/// 动画
|
||||
/// <para>Shake:颤抖</para>
|
||||
/// <para>Shake-Y-Once:向下抖动一次</para>
|
||||
/// <para>ToGrey:变灰</para>
|
||||
/// <para>To - :不解释了,移动到指定位置</para>
|
||||
/// </summary>
|
||||
[StringInList("Shake", "Shake-Y-Once", "ToLeft", "ToCenter", "ToRight")] public string Animate_type = "Shake";
|
||||
/// <summary>
|
||||
/// 角色立绘
|
||||
/// </summary>
|
||||
private Image CharacterImg;
|
||||
[Title("注意,主画布的名称必须是MainCanvas")]
|
||||
public Canvas MainCanvas;
|
||||
private void Awake ()
|
||||
{
|
||||
CharacterImg = this.gameObject.GetComponent<Image>();
|
||||
if (MainCanvas == null) MainCanvas = GameObject.Find("MainCanvas").GetComponent<Canvas>();
|
||||
}
|
||||
[Button(nameof(Start), "重新执行入场动画")]
|
||||
private void Start ()
|
||||
{
|
||||
HandleInOrOutsideMessgae(Animate_StartOrOutside);
|
||||
|
||||
}
|
||||
[Button(nameof(Start), "重新执行及时动画")]
|
||||
public void HandleMessgae ()
|
||||
{
|
||||
var _rect = CharacterImg.GetComponent<RectTransform>();
|
||||
switch (Animate_type)
|
||||
{
|
||||
case "Shake":
|
||||
{
|
||||
_rect.DOShakePosition(0.5f, 30f);
|
||||
break;
|
||||
}
|
||||
case "Shake-Y-Once":
|
||||
{
|
||||
_rect.DOAnchorPosY(_rect.anchoredPosition.y - 50f, 0.6f).OnComplete(() =>
|
||||
{
|
||||
_rect.DOAnchorPosY(_rect.anchoredPosition.y + 50f, 0.6f);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "ToLeft":
|
||||
{
|
||||
DOTween.To(() => _rect.anchoredPosition, x => _rect.GetComponent<RectTransform>().anchoredPosition = x, PositionImageInside(_rect, -1), 1f);
|
||||
break;
|
||||
}
|
||||
case "ToCenter":
|
||||
{
|
||||
DOTween.To(() => _rect.anchoredPosition, x => _rect.GetComponent<RectTransform>().anchoredPosition = x, PositionImageInside(_rect, 0), 0.8f);
|
||||
break;
|
||||
}
|
||||
case "ToRight":
|
||||
{
|
||||
DOTween.To(() => _rect.anchoredPosition, x => _rect.GetComponent<RectTransform>().anchoredPosition = x, PositionImageInside(_rect, 1), 1f);
|
||||
break;
|
||||
}
|
||||
case "Quit":
|
||||
{
|
||||
CharacterImg.DOFade(0, 0.7f).OnComplete(() =>
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
});
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
GameAPI.Print("当前剧情文本受损,请重新安装游戏尝试", "error");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 处理出场动画消息
|
||||
/// </summary>
|
||||
/// <param name="Messgae"></param>
|
||||
public void HandleInOrOutsideMessgae (string Messgae)
|
||||
{
|
||||
|
||||
CharacterImg.color = new Color32(255, 255, 255, 0);//完全透明
|
||||
var rect = this.gameObject.GetComponent<RectTransform>();
|
||||
switch (Messgae)
|
||||
{
|
||||
|
||||
//逐渐显示
|
||||
case "ToShow":
|
||||
{
|
||||
|
||||
PositionImageOutside(this.gameObject.GetComponent<RectTransform>(), 0);
|
||||
break;
|
||||
}
|
||||
//从屏幕边缘滑到左侧
|
||||
case "Outside-ToLeft":
|
||||
{
|
||||
|
||||
PositionImageOutside(this.gameObject.GetComponent<RectTransform>(), -1);
|
||||
DOTween.To(() => rect.anchoredPosition, x => rect.GetComponent<RectTransform>().anchoredPosition = x, new Vector2(rect.anchoredPosition.x + CharacterImg.sprite.texture.width, rect.anchoredPosition.y), 1f);
|
||||
break;
|
||||
}
|
||||
//从屏幕边缘滑到右侧
|
||||
case "Outside-ToRight":
|
||||
{
|
||||
PositionImageOutside(this.gameObject.GetComponent<RectTransform>(), 1);
|
||||
DOTween.To(() => rect.anchoredPosition, x => rect.GetComponent<RectTransform>().anchoredPosition = x, new Vector2(rect.anchoredPosition.x - CharacterImg.sprite.texture.width, rect.anchoredPosition.y), 1f);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
GameAPI.Print("当前剧情文本受损,请重新安装游戏尝试", "error");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
//都需要指定的
|
||||
{
|
||||
CharacterImg.DOFade(1, 0.7f);
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置image的位置到屏幕之外
|
||||
/// </summary>
|
||||
/// <param name="ImageGameObject"></param>
|
||||
/// <param name="Position">-1:左侧 0:中间 1:右侧</param>
|
||||
private void PositionImageOutside (RectTransform ImageGameObject, int Position)
|
||||
{
|
||||
// 获取Image的Rect Transform
|
||||
switch (Position)
|
||||
{
|
||||
case -1:
|
||||
this.gameObject.GetComponent<RectTransform>().anchoredPosition = new Vector2((-MainCanvas.GetComponent<RectTransform>().sizeDelta.x / 2) - (ImageGameObject.gameObject.GetComponent<Image>().sprite.texture.width / 2), ImageGameObject.anchoredPosition.y);
|
||||
break;
|
||||
case 1:
|
||||
|
||||
this.gameObject.GetComponent<RectTransform>().anchoredPosition = new Vector2((MainCanvas.GetComponent<RectTransform>().sizeDelta.x / 2) + (ImageGameObject.gameObject.GetComponent<Image>().sprite.texture.width / 2), ImageGameObject.anchoredPosition.y);
|
||||
break;
|
||||
case 0:
|
||||
this.gameObject.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, ImageGameObject.anchoredPosition.y);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取image的位置到屏幕之内的位置
|
||||
/// </summary>
|
||||
/// <param name="ImageGameObject"></param>
|
||||
/// <param name="Position">-1:左侧 0:中间 1:右侧</param>
|
||||
private Vector2 PositionImageInside (RectTransform ImageGameObject, int Position)
|
||||
{
|
||||
// 获取Image的Rect Transform
|
||||
|
||||
switch (Position)
|
||||
{
|
||||
case -1:
|
||||
return new Vector2((-MainCanvas.GetComponent<RectTransform>().sizeDelta.x / 2) + (ImageGameObject.gameObject.GetComponent<Image>().sprite.texture.width / 2), ImageGameObject.anchoredPosition.y);
|
||||
|
||||
case 1:
|
||||
return new Vector2((MainCanvas.GetComponent<RectTransform>().sizeDelta.x / 2) - (ImageGameObject.gameObject.GetComponent<Image>().sprite.texture.width / 2), ImageGameObject.anchoredPosition.y);
|
||||
|
||||
case 0:
|
||||
return new Vector2(0, ImageGameObject.anchoredPosition.y);
|
||||
|
||||
default:
|
||||
{
|
||||
GameAPI.Print("当前剧情文本受损,请重新安装游戏尝试", "error");
|
||||
return new Vector2(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54b43f7a21b91734699b948fa62c4456
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
Assets/HGF/Scripts/Galgame/GalManager_CharacterImg.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ScenesScripts.GalPlot
|
||||
{
|
||||
|
||||
public class GalManager_CharacterImg : MonoBehaviour
|
||||
{
|
||||
private Image CharacterImg;
|
||||
private void Start ()
|
||||
{
|
||||
CharacterImg = this.gameObject.GetComponent<Image>();
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 直接传递图片
|
||||
/// </summary>
|
||||
/// <param name="ImgSprite"></param>
|
||||
public void SetImage (Sprite ImgSprite)
|
||||
{
|
||||
CharacterImg.sprite = ImgSprite;
|
||||
}
|
||||
/// <summary>
|
||||
/// 从Resources资源文件夹读图片
|
||||
/// </summary>
|
||||
/// <param name="ImgSpriteFilePath"></param>
|
||||
public void SetImage (string ImgSpriteFilePath)
|
||||
{
|
||||
CharacterImg.sprite = Resources.Load<Sprite>(ImgSpriteFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/HGF/Scripts/Galgame/GalManager_CharacterImg.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a3dc170f98da4848a48e1bb8cc1698a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
Assets/HGF/Scripts/Galgame/GalManager_CharacterMessage.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ScenesScripts.GalPlot
|
||||
{
|
||||
|
||||
public class GalManager_CharacterMessage : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
public GalManager_CharacterAnimate Gal_CharacterAnimate;
|
||||
public void HandleMessage (string MessageContent)
|
||||
{
|
||||
|
||||
Gal_CharacterAnimate.Animate_type = MessageContent;
|
||||
Gal_CharacterAnimate.HandleMessgae();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33a5795aa795b1046919e1869c8d65c3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
35
Assets/HGF/Scripts/Galgame/GalManager_Choice.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ScenesScripts.GalPlot
|
||||
{
|
||||
public class GalManager_Choice : MonoBehaviour
|
||||
{
|
||||
private GameObject GameObject_Choice;
|
||||
|
||||
private void Start ()
|
||||
{
|
||||
GameObject_Choice = Resources.Load<GameObject>("Common/Gameobject/Galgame/Button-Choice");
|
||||
}
|
||||
[SerializeField]
|
||||
public void CreatNewChoice (string JumpID, string Title)
|
||||
{
|
||||
|
||||
var _ = GameObject_Choice;
|
||||
_.GetComponent<GalComponent_Choice>().Init(JumpID, Title);
|
||||
Instantiate(_, this.transform);
|
||||
return;
|
||||
}
|
||||
public void Button_Click_Choice ()
|
||||
{
|
||||
|
||||
|
||||
for (int i = 0; i < this.transform.childCount; i++)
|
||||
{
|
||||
//不可用DestroyImmediate
|
||||
//原因:DestroyImmediate是同步的,如果使用则会导致每次获取的都是0,无法删除,
|
||||
Destroy(this.transform.GetChild(i).gameObject);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/HGF/Scripts/Galgame/GalManager_Choice.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b881bc00d6924c94e9caaeb957f23cde
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
117
Assets/HGF/Scripts/Galgame/GalManager_Text.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ScenesScripts.GalPlot
|
||||
{
|
||||
public class GalManager_Text : MonoBehaviour
|
||||
{
|
||||
public const float DefalutSpeed = 0.045f;
|
||||
public const float FastSpeend = 0.02f;
|
||||
/// <summary>
|
||||
/// 当前是否剧情加速
|
||||
/// </summary>
|
||||
public static bool IsFastMode;
|
||||
|
||||
/// <summary>
|
||||
/// 当前是否正在发言
|
||||
/// 如果为假则可以开始下一句
|
||||
/// 当这个文本快结束的时候也为True
|
||||
/// </summary>
|
||||
public static bool IsSpeak;
|
||||
|
||||
/// <summary>
|
||||
/// 文本内容打字机动画事件
|
||||
/// </summary>
|
||||
public static Tweener TextAnimateEvemt;
|
||||
|
||||
/// <summary>
|
||||
/// 文本内容
|
||||
/// </summary>
|
||||
public Text Text_TextContent;
|
||||
|
||||
/// <summary>
|
||||
/// 发言人
|
||||
/// </summary>
|
||||
public Text Text_CharacterName;
|
||||
|
||||
/// <summary>
|
||||
///是否可以跳过
|
||||
/// </summary>
|
||||
public static bool IsCanJump = true;
|
||||
|
||||
/// <summary>
|
||||
/// 对话框右下角的下一句提示
|
||||
/// </summary>
|
||||
public GameObject Button_Next;
|
||||
|
||||
/// <summary>
|
||||
/// 对话框是否可见
|
||||
/// </summary>
|
||||
public void SetDialogHide (bool value = false)
|
||||
{
|
||||
this.gameObject.SetActive(value);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置对话内容
|
||||
/// </summary>
|
||||
/// <param name="TextContent"></param>
|
||||
public void SetText_Content (string TextContent)
|
||||
{
|
||||
Text_TextContent.text = TextContent;
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置发言人的名称
|
||||
/// </summary>
|
||||
public void SetText_CharacterName (string CharacterName, string CharacterIdentity)
|
||||
{
|
||||
|
||||
Text_CharacterName.text = $"<b>{CharacterName}</b><size=45> <color=#F684EE>{CharacterIdentity}</color></size>";
|
||||
}
|
||||
/// <summary>
|
||||
/// 开始发言
|
||||
/// </summary>
|
||||
/// <param name="TextContent">文本内容</param>
|
||||
/// <param name="CharacterName">发言人名称</param>
|
||||
/// <param name="CharacterIdentity">发言人所属</param>
|
||||
/// <param name="CallBack">回调事件</param>
|
||||
/// <returns></returns>
|
||||
public Tweener StartTextContent (string TextContent, string CharacterName, string CharacterIdentity, UnityAction CallBack = null)
|
||||
{
|
||||
//100 60 40
|
||||
void Alwayls ()
|
||||
{
|
||||
|
||||
SetText_CharacterName(CharacterName, CharacterIdentity);
|
||||
|
||||
}
|
||||
if (IsSpeak && Text_TextContent.text.Length >= TextContent.Length * 0.75f && IsCanJump)//当前还正在发言
|
||||
{
|
||||
//但是 ,如果当前到了总文本的三分之二,也可以下一句
|
||||
SetText_Content(TextContent);
|
||||
IsSpeak = false;
|
||||
TextAnimateEvemt.Kill();
|
||||
Button_Next.SetActive(true);
|
||||
Alwayls();
|
||||
return TextAnimateEvemt;
|
||||
}
|
||||
else if (IsSpeak) return TextAnimateEvemt;
|
||||
IsSpeak = true;
|
||||
SetText_Content(string.Empty);//先清空内容
|
||||
Button_Next.SetActive(false);
|
||||
Alwayls();
|
||||
TextAnimateEvemt = Text_TextContent.DOText(TextContent, TextContent.Length * (IsFastMode ? FastSpeend : DefalutSpeed)).SetEase(Ease.Linear).OnComplete(() =>
|
||||
{
|
||||
|
||||
IsSpeak = false;
|
||||
CallBack?.Invoke();
|
||||
Button_Next.SetActive(true);
|
||||
});
|
||||
return TextAnimateEvemt;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/HGF/Scripts/Galgame/GalManager_Text.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: be1c5720203259149a471ba8c12d2566
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
156
Assets/HGF/Scripts/GameAPI.cs
Normal file
@@ -0,0 +1,156 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace Common.Game
|
||||
{
|
||||
/// <summary>
|
||||
/// 游戏内通用API
|
||||
/// </summary>
|
||||
public static class GameAPI
|
||||
{
|
||||
/// <summary>
|
||||
/// 返回可读可写路径
|
||||
/// PC端:streamingAssetsPath
|
||||
/// 移动端:Application.persistentDataPath
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetWritePath ()
|
||||
{
|
||||
#if UNITY_EDITOR || UNITY_STANDALONE
|
||||
return Application.streamingAssetsPath;
|
||||
#elif UNITY_IOS || UNITY_ANDROID
|
||||
return Application.persistentDataPath;
|
||||
#endif
|
||||
}
|
||||
/// <summary>
|
||||
/// 接管Debug.Log(...)
|
||||
/// </summary>
|
||||
/// <param name="_Message">调试信息</param>
|
||||
/// <param name="_Type">1.debug 2.warn 3.error</param>
|
||||
public static void Print (object _Message, string _Type = "debug")
|
||||
{
|
||||
string currentTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
string res = $"[{currentTime}] {_Type} : {_Message}";
|
||||
switch (_Type)
|
||||
{
|
||||
case "debug":
|
||||
Debug.Log(res);
|
||||
return;
|
||||
case "warn":
|
||||
Debug.LogWarning(res);
|
||||
return;
|
||||
case "error":
|
||||
Debug.LogError(res);
|
||||
return;
|
||||
default:
|
||||
Debug.Log(res);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 暴力查找一个物体,找不到返回Null
|
||||
/// </summary>
|
||||
/// <param name="_Name"></param>
|
||||
/// <returns></returns>
|
||||
public static GameObject FindGameObject_Force (string _Name)
|
||||
{
|
||||
|
||||
GameObject[] all = Resources.FindObjectsOfTypeAll(typeof(GameObject)) as GameObject[];
|
||||
for (int i = 0; i < all.Length; i++)
|
||||
{
|
||||
var item = all[i];
|
||||
if (item.name == _Name) return item;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 生成SHA256值
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public static string GenerateSha256 (string input)
|
||||
{
|
||||
using (SHA256 sha256Hash = SHA256.Create())
|
||||
{
|
||||
byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
builder.Append(bytes[i].ToString("x2"));
|
||||
}
|
||||
|
||||
return builder.ToString().ToUpper();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 通过UnityWebRequest获取本地StreamingAssets文件夹中的文件
|
||||
/// </summary>
|
||||
/// <param name="fileName">文件名称</param>
|
||||
/// <returns></returns>
|
||||
public static string UnityWebRequestFile (string fileName)
|
||||
{
|
||||
string url;
|
||||
#region 分平台判断 StreamingAssets 路径
|
||||
//如果在编译器或者单机中
|
||||
#if UNITY_EDITOR || UNITY_STANDALONE
|
||||
|
||||
url = "file://" + Application.dataPath + "/StreamingAssets/" + fileName;
|
||||
//否则如果在Iphone下
|
||||
#elif UNITY_IPHONE
|
||||
url = "file://" + Application.dataPath + "/Raw/"+ fileName;
|
||||
//否则如果在android下
|
||||
#elif UNITY_ANDROID
|
||||
url = "jar:file://" + Application.dataPath + "!/assets/"+ fileName;
|
||||
#endif
|
||||
#endregion
|
||||
UnityWebRequest request = UnityWebRequest.Get(url);
|
||||
request.SendWebRequest();//读取数据
|
||||
while (true)
|
||||
{
|
||||
if (request.downloadHandler.isDone)//是否读取完数据
|
||||
{
|
||||
return request.downloadHandler.text;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 从外部指定文件中加载图片
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Sprite LoadTextureByIO (string Path)
|
||||
{
|
||||
FileStream fs = new FileStream(Path, FileMode.Open, FileAccess.Read);
|
||||
fs.Seek(0, SeekOrigin.Begin);//游标的操作,可有可无
|
||||
byte[] bytes = new byte[fs.Length];//生命字节,用来存储读取到的图片字节
|
||||
try
|
||||
{
|
||||
fs.Read(bytes, 0, bytes.Length);//开始读取,这里最好用trycatch语句,防止读取失败报错
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Log(e);
|
||||
}
|
||||
fs.Close();//切记关闭
|
||||
|
||||
int width = 2048;//图片的宽(这里两个参数可以提到方法参数中)
|
||||
int height = 2048;//图片的高(这里说个题外话,pico相关的开发,这里不能大于4k×4k不然会显示异常,当时开发pico的时候应为这个问题找了大半天原因,因为美术给的图是6000*3600,导致出现切几张图后就黑屏了。。。
|
||||
Texture2D texture = new Texture2D(width, height);
|
||||
if (texture.LoadImage(bytes))
|
||||
{
|
||||
return Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));//将生成的texture2d返回,到这里就得到了外部的图片,可以使用了
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/HGF/Scripts/GameAPI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc889f71cb222774084ea6092c6534d2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
190
Assets/HGF/Scripts/GameConfig.cs
Normal file
@@ -0,0 +1,190 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
|
||||
namespace Common.Game
|
||||
{
|
||||
/// <summary>
|
||||
/// 游戏配置文件的读取,使用INI
|
||||
/// </summary>
|
||||
public class GameConfig
|
||||
{
|
||||
private Hashtable keyPairs = new Hashtable();
|
||||
private string iniFilePath;
|
||||
private struct SectionPair
|
||||
{
|
||||
public string Section;
|
||||
public string Key;
|
||||
}
|
||||
/// <summary>
|
||||
/// 在给定的路径上打开INI文件并枚举IniParser中的值。
|
||||
/// </summary>
|
||||
/// <param name="iniPath">Full path to INI file.</param>
|
||||
public GameConfig (string iniPath)
|
||||
{
|
||||
TextReader iniFile = null;
|
||||
string strLine = null;
|
||||
string currentRoot = null;
|
||||
string[] keyPair = null;
|
||||
iniFilePath = iniPath;
|
||||
if (File.Exists(iniPath))
|
||||
{
|
||||
try
|
||||
{
|
||||
iniFile = new StreamReader(iniPath);
|
||||
strLine = iniFile.ReadLine();
|
||||
while (strLine != null)
|
||||
{
|
||||
strLine = strLine.Trim();
|
||||
if (strLine != "")
|
||||
{
|
||||
if (strLine.StartsWith("[") && strLine.EndsWith("]"))
|
||||
{
|
||||
currentRoot = strLine.Substring(1, strLine.Length - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyPair = strLine.Split(new char[] { '=' }, 2);
|
||||
SectionPair sectionPair;
|
||||
String value = null;
|
||||
if (currentRoot == null)
|
||||
currentRoot = "ROOT";
|
||||
sectionPair.Section = currentRoot;
|
||||
sectionPair.Key = keyPair[0];
|
||||
if (keyPair.Length > 1)
|
||||
value = keyPair[1];
|
||||
keyPairs.Add(sectionPair, value);
|
||||
}
|
||||
}
|
||||
strLine = iniFile.ReadLine();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (iniFile != null)
|
||||
iniFile.Close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GameAPI.Print("找不到INI配置,已自动创建", "warn");
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回给定section的值,key对。
|
||||
/// </summary>
|
||||
/// <param name="sectionName">Section name</param>
|
||||
/// <param name="settingName">Key name</param>
|
||||
public string GetValue (string sectionName, string settingName)
|
||||
{
|
||||
SectionPair sectionPair;
|
||||
sectionPair.Section = sectionName;
|
||||
sectionPair.Key = settingName;
|
||||
return (string)keyPairs[sectionPair];
|
||||
}
|
||||
/// <summary>
|
||||
/// 列出给定的Section的所有行
|
||||
/// </summary>
|
||||
/// <param name="sectionName">Section to enum.</param>
|
||||
public string[] EnumSection (string sectionName)
|
||||
{
|
||||
ArrayList tmpArray = new ArrayList();
|
||||
foreach (SectionPair pair in keyPairs.Keys)
|
||||
{
|
||||
if (pair.Section == sectionName)
|
||||
tmpArray.Add(pair.Key);
|
||||
}
|
||||
return (string[])tmpArray.ToArray(typeof(string));
|
||||
}
|
||||
/// <summary>
|
||||
/// 向要保存的节添加或替换Value。
|
||||
/// </summary>
|
||||
/// <param name="sectionName">Section to add under.</param>
|
||||
/// <param name="settingName">Key name to add.</param>
|
||||
/// <param name="settingValue">Value of key.</param>
|
||||
public void SetValue (string sectionName, string settingName, string settingValue)
|
||||
{
|
||||
SectionPair sectionPair;
|
||||
sectionPair.Section = sectionName;
|
||||
sectionPair.Key = settingName;
|
||||
if (keyPairs.ContainsKey(sectionPair))
|
||||
keyPairs.Remove(sectionPair);
|
||||
keyPairs.Add(sectionPair, settingValue);
|
||||
Save();
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除设置
|
||||
/// </summary>
|
||||
/// <param name="sectionName">指定Section</param>
|
||||
/// <param name="settingName">添加的Key</param>
|
||||
public void Delete (string sectionName, string settingName)
|
||||
{
|
||||
SectionPair sectionPair;
|
||||
sectionPair.Section = sectionName;
|
||||
sectionPair.Key = settingName;
|
||||
if (keyPairs.ContainsKey(sectionPair))
|
||||
keyPairs.Remove(sectionPair);
|
||||
Save();
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存到新文件。
|
||||
/// </summary>
|
||||
/// <param name="newFilePath">新的文件路径。</param>
|
||||
public void SaveSettings (string newFilePath)
|
||||
{
|
||||
ArrayList sections = new ArrayList();
|
||||
string tmpValue = "";
|
||||
string strToSave = "";
|
||||
foreach (SectionPair sectionPair in keyPairs.Keys)
|
||||
{
|
||||
if (!sections.Contains(sectionPair.Section))
|
||||
sections.Add(sectionPair.Section);
|
||||
}
|
||||
foreach (string section in sections)
|
||||
{
|
||||
strToSave += ("[" + section + "]\r\n");
|
||||
foreach (SectionPair sectionPair in keyPairs.Keys)
|
||||
{
|
||||
if (sectionPair.Section == section)
|
||||
{
|
||||
tmpValue = (string)keyPairs[sectionPair];
|
||||
if (tmpValue != null)
|
||||
tmpValue = "=" + tmpValue;
|
||||
strToSave += (sectionPair.Key + tmpValue + "\r\n");
|
||||
}
|
||||
}
|
||||
strToSave += "\r\n";
|
||||
}
|
||||
try
|
||||
{
|
||||
TextWriter tw = new StreamWriter(newFilePath);
|
||||
tw.Write(strToSave);
|
||||
tw.Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 将设置保存回ini文件。
|
||||
/// </summary>
|
||||
public void Save ()
|
||||
{
|
||||
SaveSettings(iniFilePath);
|
||||
}
|
||||
|
||||
public static string GetValue (string Path, string SectionName, string settingName)
|
||||
{
|
||||
var _ = new GameConfig(Path);
|
||||
return _.GetValue(SectionName, settingName);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/HGF/Scripts/GameConfig.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60a53357b897c2a439d56a47f6d762dd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
125
Assets/HGF/Scripts/StringInList.cs
Normal file
@@ -0,0 +1,125 @@
|
||||
using System;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
#endif
|
||||
|
||||
namespace UnityCustom
|
||||
{
|
||||
public class StringInList : PropertyAttribute
|
||||
|
||||
{
|
||||
|
||||
public delegate string[] GetStringList ();
|
||||
|
||||
|
||||
|
||||
public StringInList (params string[] list)
|
||||
|
||||
{
|
||||
|
||||
List = list;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public StringInList (Type type, string methodName)
|
||||
|
||||
{
|
||||
|
||||
var method = type.GetMethod(methodName);
|
||||
|
||||
if (method != null)
|
||||
|
||||
{
|
||||
|
||||
List = method.Invoke(null, null) as string[];
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
Debug.LogError("NO SUCH METHOD " + methodName + " FOR " + type);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public string[] List
|
||||
|
||||
{
|
||||
|
||||
get;
|
||||
|
||||
private set;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
[CustomPropertyDrawer(typeof(StringInList))]
|
||||
|
||||
public class StringInListDrawer : PropertyDrawer
|
||||
|
||||
{
|
||||
|
||||
// Draw the property inside the given rect
|
||||
|
||||
public override void OnGUI (Rect position, SerializedProperty property, GUIContent label)
|
||||
|
||||
{
|
||||
|
||||
var stringInList = attribute as StringInList;
|
||||
|
||||
var list = stringInList.List;
|
||||
|
||||
if (property.propertyType == SerializedPropertyType.String)
|
||||
|
||||
{
|
||||
|
||||
int index = Mathf.Max(0, Array.IndexOf(list, property.stringValue));
|
||||
|
||||
index = EditorGUI.Popup(position, property.displayName, index, list);
|
||||
|
||||
|
||||
|
||||
property.stringValue = list[index];
|
||||
|
||||
}
|
||||
|
||||
else if (property.propertyType == SerializedPropertyType.Integer)
|
||||
|
||||
{
|
||||
|
||||
property.intValue = EditorGUI.Popup(position, property.displayName, property.intValue, list);
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
|
||||
base.OnGUI(position, property, label);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
11
Assets/HGF/Scripts/StringInList.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69e0aabd822d876489d488841d8d00f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/HGF/Tetra Attributes.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0cc1aa810ec32df46bc3845fd378cdd4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/HGF/Tetra Attributes/Core.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 082e69b70cfa506439749423e5025ff8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
23
Assets/HGF/Tetra Attributes/Core/ButtonAttribute.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
|
||||
namespace TetraCreations.Attributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
|
||||
public class ButtonAttribute : Attribute
|
||||
{
|
||||
public string MethodName { get; private set; }
|
||||
public string Label { get; private set; }
|
||||
public int Space { get; private set; }
|
||||
public string Row { get; private set; }
|
||||
public bool HasRow { get; private set; }
|
||||
|
||||
public ButtonAttribute(string methodName, string label = "", float width = default, int space = default, string row = default)
|
||||
{
|
||||
MethodName = methodName;
|
||||
Label = label;
|
||||
Space = space;
|
||||
Row = row;
|
||||
HasRow = !string.IsNullOrEmpty(Row);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/HGF/Tetra Attributes/Core/ButtonAttribute.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2bc3dd7092e440e46947dad5644e0254
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
47
Assets/HGF/Tetra Attributes/Core/ColorExtensions.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace TetraCreations.Attributes
|
||||
{
|
||||
public static class ColorExtensions
|
||||
{
|
||||
// Convert the TitleColor enum to an actual Color32
|
||||
public static Color32 ToColor(this CustomColor color)
|
||||
{
|
||||
switch (color)
|
||||
{
|
||||
case CustomColor.Aqua: return new Color32(127, 219, 255, 255);
|
||||
case CustomColor.Beige: return new Color32(245, 245, 220, 255);
|
||||
case CustomColor.Black: return new Color32(0, 0, 0, 255);
|
||||
case CustomColor.Blue: return new Color32(31, 133, 221, 255);
|
||||
case CustomColor.BlueVariant: return new Color32(67, 110, 238, 255);
|
||||
case CustomColor.DarkBlue: return new Color32(41, 41, 225, 255);
|
||||
case CustomColor.Bright: return new Color32(196, 196, 196, 255);
|
||||
case CustomColor.Brown: return new Color32(148, 96, 59, 255);
|
||||
case CustomColor.Cyan: return new Color32(0, 255, 255, 255);
|
||||
case CustomColor.DarkGray: return new Color32(36, 36, 36, 255);
|
||||
case CustomColor.Fuchsia: return new Color32(240, 18, 190, 255);
|
||||
case CustomColor.Gray: return new Color32(88, 88, 88, 255);
|
||||
case CustomColor.Green: return new Color32(98, 200, 79, 255);
|
||||
case CustomColor.Indigo: return new Color32(75, 0, 130, 255);
|
||||
case CustomColor.LightGray: return new Color32(128, 128, 128, 255);
|
||||
case CustomColor.Lime: return new Color32(1, 255, 112, 255);
|
||||
case CustomColor.Navy: return new Color32(15, 35, 86, 255);
|
||||
case CustomColor.Olive: return new Color32(61, 153, 112, 255);
|
||||
case CustomColor.DarkOlive: return new Color32(47, 79, 79, 255);
|
||||
case CustomColor.Orange: return new Color32(255, 128, 0, 255);
|
||||
case CustomColor.OrangeVariant: return new Color32(255, 135, 62, 255);
|
||||
case CustomColor.Pink: return new Color32(255, 152, 203, 255);
|
||||
case CustomColor.Red: return new Color32(234, 42, 42, 255);
|
||||
case CustomColor.LightRed: return new Color32(217, 71, 71, 255);
|
||||
case CustomColor.RedVariant: return new Color32(232, 10, 10, 255);
|
||||
case CustomColor.DarkRed: return new Color32(144, 20, 39, 255);
|
||||
case CustomColor.Tan: return new Color32(210, 180, 140, 255);
|
||||
case CustomColor.Teal: return new Color32(27, 126, 126, 255);
|
||||
case CustomColor.Violet: return new Color32(181, 93, 237, 255);
|
||||
case CustomColor.White: return new Color32(255, 255, 255, 255);
|
||||
case CustomColor.Yellow: return new Color32(255, 211, 0, 255);
|
||||
default: return new Color32(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/HGF/Tetra Attributes/Core/ColorExtensions.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c57a986808564b7478b4b7733a65d9bc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
44
Assets/HGF/Tetra Attributes/Core/DrawIfAttribute.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace TetraCreations.Attributes
|
||||
{
|
||||
/// <summary>
|
||||
/// Draws the field/property ONLY if the compared property compared by the comparison type with the value of comparedValue returns true.
|
||||
/// Based on: https://forum.unity.com/threads/draw-a-field-only-if-a-condition-is-met.448855/
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
|
||||
public class DrawIfAttribute : PropertyAttribute
|
||||
{
|
||||
#region Fields
|
||||
public string ComparedPropertyName { get; private set; }
|
||||
public object ComparedValue { get; private set; }
|
||||
public DisablingType DisablingType { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Only draws the field if the condition is true.<br></br>
|
||||
/// Supports Boolean and Enum.
|
||||
/// </summary>
|
||||
/// <param name="comparedPropertyName">The name of the property that is being compared (case sensitive).</param>
|
||||
/// <param name="comparedValue">The value the property is being compared to.</param>
|
||||
/// <param name="disablingType">Determine if it will hide the field or make it read only if the condition is NOT met.
|
||||
/// Defaulted to DisablingType.DontDraw.</param>
|
||||
public DrawIfAttribute(string comparedPropertyName, object comparedValue, DisablingType disablingType = DisablingType.DontDraw)
|
||||
{
|
||||
ComparedPropertyName = comparedPropertyName;
|
||||
ComparedValue = comparedValue;
|
||||
DisablingType = disablingType;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Types of comperisons.
|
||||
/// </summary>
|
||||
public enum DisablingType
|
||||
{
|
||||
ReadOnly = 2,
|
||||
DontDraw = 3
|
||||
}
|
||||
}
|
||||
11
Assets/HGF/Tetra Attributes/Core/DrawIfAttribute.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac0c4fbed039c0541b44ed5592ddc44a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/HGF/Tetra Attributes/Core/Enum.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 10946b7935516c447932e75b5f6995cc
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
38
Assets/HGF/Tetra Attributes/Core/Enum/CustomColor.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
// This is used to colorize the TitleAttribute
|
||||
namespace TetraCreations.Attributes
|
||||
{
|
||||
public enum CustomColor
|
||||
{
|
||||
Aqua,
|
||||
Beige,
|
||||
Black,
|
||||
Blue,
|
||||
BlueVariant,
|
||||
DarkBlue,
|
||||
Bright,
|
||||
Brown,
|
||||
Cyan,
|
||||
DarkGray,
|
||||
Fuchsia,
|
||||
Gray,
|
||||
Green,
|
||||
Indigo,
|
||||
LightGray,
|
||||
Lime,
|
||||
Navy,
|
||||
Olive,
|
||||
DarkOlive,
|
||||
Orange,
|
||||
OrangeVariant,
|
||||
Pink,
|
||||
Red,
|
||||
LightRed,
|
||||
RedVariant,
|
||||
DarkRed,
|
||||
Tan,
|
||||
Teal,
|
||||
Violet,
|
||||
White,
|
||||
Yellow
|
||||
}
|
||||
}
|
||||
11
Assets/HGF/Tetra Attributes/Core/Enum/CustomColor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 860072ac14442604797efc9859df4229
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
24
Assets/HGF/Tetra Attributes/Core/HelpBoxAttribute.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TetraCreations.Attributes
|
||||
{
|
||||
public enum HelpBoxMessageType { None, Info, Warning, Error }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field, Inherited = true)]
|
||||
public class HelpBoxAttribute : PropertyAttribute
|
||||
{
|
||||
public string Text { get; private set; }
|
||||
public HelpBoxMessageType MessageType { get; private set; }
|
||||
public float MinimumHeight { get; private set; }
|
||||
public int FontSize { get; private set; }
|
||||
|
||||
public HelpBoxAttribute(string text, HelpBoxMessageType messageType = HelpBoxMessageType.None, float minimumHeight = 20, int fontSize = 12)
|
||||
{
|
||||
Text = text;
|
||||
MessageType = messageType;
|
||||
MinimumHeight = minimumHeight;
|
||||
FontSize = fontSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/HGF/Tetra Attributes/Core/HelpBoxAttribute.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a4ffb9c14ebc594d99fe2b89da197ca
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/HGF/Tetra Attributes/Core/MinMaxSliderAttribute.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace TetraCreations.Attributes
|
||||
{
|
||||
public class MinMaxSliderAttribute : PropertyAttribute
|
||||
{
|
||||
public float Min { get; private set; }
|
||||
public float Max { get; private set; }
|
||||
|
||||
public MinMaxSliderAttribute(float min, float max)
|
||||
{
|
||||
Min = min;
|
||||
Max = max;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1fadfa06e2c45e46b6012ae4446acc5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/HGF/Tetra Attributes/Core/PathReference.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace TetraCreations.Attributes
|
||||
{
|
||||
[System.Serializable]
|
||||
public class PathReference
|
||||
{
|
||||
public string GUI;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public string Path => AssetDatabase.GUIDToAssetPath(GUI);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
11
Assets/HGF/Tetra Attributes/Core/PathReference.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d77aa39161ef7bd449643862d77704ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
10
Assets/HGF/Tetra Attributes/Core/ReadOnlyAttribute.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TetraCreations.Attributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
public class ReadOnlyAttribute : PropertyAttribute
|
||||
{
|
||||
}
|
||||
}
|
||||
11
Assets/HGF/Tetra Attributes/Core/ReadOnlyAttribute.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b173128c26c4c54ab83bb6c9168df07
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
11
Assets/HGF/Tetra Attributes/Core/RequiredAttribute.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TetraCreations.Attributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, Inherited = true)]
|
||||
public class RequiredAttribute : PropertyAttribute
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/HGF/Tetra Attributes/Core/RequiredAttribute.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e42d141fdead4f419cda48504ceaa8c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
56
Assets/HGF/Tetra Attributes/Core/SnappedSliderAttribute.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TetraCreations.Attributes
|
||||
{
|
||||
public class SnappedSliderAttribute : PropertyAttribute
|
||||
{
|
||||
public float Step { get; private set; }
|
||||
public float Min { get; private set; }
|
||||
public float Max { get; private set; }
|
||||
public int Precision { get; private set; }
|
||||
public bool AllowNonStepReach { get; private set; }
|
||||
public bool IsInt { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Increase a float value in step<br></br>
|
||||
/// Value is clamped by min and max parameters
|
||||
/// </summary>
|
||||
/// <param name="step">Value to add</param>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
public SnappedSliderAttribute(float step, float min, float max)
|
||||
{
|
||||
Step = step;
|
||||
Min = min;
|
||||
Max = max;
|
||||
Precision = CountFloatDigits(step);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Increase an int value in step<br></br>
|
||||
/// Value is clamped by min and max parameters
|
||||
/// </summary>
|
||||
/// <param name="step">Value to add</param>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <param name="allowNonStepReach"></param>
|
||||
public SnappedSliderAttribute(int step, int min, int max, bool allowNonStepReach = true)
|
||||
{
|
||||
Min = min;
|
||||
Max = max;
|
||||
Step = step;
|
||||
AllowNonStepReach = allowNonStepReach;
|
||||
IsInt = true;
|
||||
}
|
||||
|
||||
private int CountFloatDigits(float n, int precisionLimit = 7)
|
||||
{
|
||||
return Mathf.Min(n.ToString(System.Globalization.CultureInfo.InvariantCulture)
|
||||
.SkipWhile(c => c != '.')
|
||||
.Skip(1)
|
||||
.Count(),
|
||||
precisionLimit);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b069aed210d19b44a07d1409301c51c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
30
Assets/HGF/Tetra Attributes/Core/SpritePreviewAttribute.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TetraCreations.Attributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, Inherited = true)]
|
||||
public class SpritePreviewAttribute : PropertyAttribute
|
||||
{
|
||||
public const CustomColor DefaultBackgroundColor = CustomColor.DarkGray;
|
||||
|
||||
public bool UseAssetPreview { get; private set; }
|
||||
public float MaximumHeight { get; private set; }
|
||||
public CustomColor BackgroundColor { get; private set; }
|
||||
public string BackgroundColorString { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Dispaly the texture below a sprite field.
|
||||
/// </summary>
|
||||
/// <param name="maximumHeight">Maximum height of the preview (With useAssetPreview set to false)</param>
|
||||
/// <param name="backgroundColor">The color behind the texture</param>
|
||||
/// <param name="useAssetPreview">If true it will use AssetPreview.GetAssetPreview to draw the texture, the maximumHeight doesn't change anyting</param>
|
||||
public SpritePreviewAttribute(float maximumHeight = 256f, CustomColor backgroundColor = DefaultBackgroundColor, bool useAssetPreview = false)
|
||||
{
|
||||
UseAssetPreview = useAssetPreview;
|
||||
MaximumHeight = maximumHeight;
|
||||
BackgroundColor = backgroundColor;
|
||||
BackgroundColorString = ColorUtility.ToHtmlStringRGB(BackgroundColor.ToColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a652095430dc9c5449a1356f64e217e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "TetraCreations.Attributes",
|
||||
"rootNamespace": "",
|
||||
"references": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2870bc0b4b018d04e8ebe52993b57c6d
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
40
Assets/HGF/Tetra Attributes/Core/TitleAttribute.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace TetraCreations.Attributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, Inherited = true)]
|
||||
public class TitleAttribute : PropertyAttribute
|
||||
{
|
||||
#region Constants
|
||||
public const float DefaultLineHeight = 1f;
|
||||
public const CustomColor DefaultLineColor = CustomColor.LightGray;
|
||||
public const CustomColor DefaultTitleColor = CustomColor.Bright;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
public string Title { get; private set; }
|
||||
public float LineHeight { get; private set; }
|
||||
public CustomColor LineColor { get; private set; }
|
||||
public CustomColor TitleColor { get; private set; }
|
||||
public string LineColorString { get; private set; }
|
||||
public string TitleColorString { get; private set; }
|
||||
public float Spacing { get; private set; }
|
||||
public bool AlignTitleLeft { get; private set; }
|
||||
#endregion
|
||||
|
||||
public TitleAttribute(string title = "", CustomColor titleColor = DefaultTitleColor,
|
||||
CustomColor lineColor = DefaultLineColor, float lineHeight = DefaultLineHeight, float spacing = 14f,
|
||||
bool alignTitleLeft = false)
|
||||
{
|
||||
Title = title;
|
||||
TitleColor = titleColor;
|
||||
LineColor = lineColor;
|
||||
TitleColorString = ColorUtility.ToHtmlStringRGB(TitleColor.ToColor());
|
||||
LineColorString = ColorUtility.ToHtmlStringRGB(LineColor.ToColor());
|
||||
LineHeight = Mathf.Max(1f, lineHeight);
|
||||
Spacing = spacing;
|
||||
AlignTitleLeft = alignTitleLeft;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/HGF/Tetra Attributes/Core/TitleAttribute.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6bdbc990bdaefcf41bffe14abf791a6f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/HGF/Tetra Attributes/Documentation.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21784e8e604930e48ae4a088c56892b9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
471
Assets/HGF/Tetra Attributes/Documentation/Documentation.md
Normal file
@@ -0,0 +1,471 @@
|
||||
# Tetra Attributes 1.1.0 : Documentation #
|
||||
|
||||

|
||||
|
||||
# Importing the Asset #
|
||||
If you not familiar on how to install an asset, once you have purchased it, click on **Window → Package Manager** to reveal a window with all your available assets.
|
||||
|
||||
Type in the search field **Tetra Attributes** to download and install the last version. Follow the steps and wait till Unity finishes compiling your project.
|
||||
|
||||
<div class="page">
|
||||
|
||||
# Introduction #
|
||||
|
||||
This is a collection of C# attributes for the Unity editor that I use in most of my projects. Some are essential, like ReadOnly, which I've been using for several years. While others like Title are more for keeping the inspector window organised and clear.
|
||||
|
||||
## Changelog : 1.1.0 ##
|
||||
|
||||
- Added SpritePreview attribute to display the texture below a Sprite field.
|
||||
- PathReference : Fixed console error "InvalidOperationException: Stack empty". After closing the folder selection dialog window without selecting anything.
|
||||
- PathReference : Added the possibility to delete the folder reference when pressing the delete key while hovering the field.
|
||||
- Renamed TitleColor enum to CustomColor because it's now used in SpritePreview.
|
||||
|
||||
**Important** : You will have to replace all Title references using **TitleColor** in you project with **CustomColor**.
|
||||
|
||||
---
|
||||
|
||||
## Usage ##
|
||||
|
||||
Once imported simply add this line to your file header to use any attributes :
|
||||
|
||||
> using TetraCreations.Attributes;
|
||||
|
||||
All Property, Decorator drawers and Editor scripts are inside the namespace :
|
||||
|
||||
> TetraCreations.Attributes.Editor
|
||||
|
||||
An example scene with the AttributesExample script using every attributes is available in :
|
||||
> Assets/Tetra Creations/Attributes/Example/Example.unity
|
||||
|
||||
## Table of Contents ##
|
||||
- [Normal Attributes](#normal-attributes)
|
||||
- [\[Tile\]](#tile)
|
||||
- [\[ReadOnly\]](#readonly)
|
||||
- [\[DrawIf\]](#drawif)
|
||||
- [\[HelpBox\]](#helpbox)
|
||||
- [\[MinMaxSlider\]](#minmaxslider)
|
||||
- [\[SnappedSlider\]](#snappedslider)
|
||||
- [\[Required\]](#required)
|
||||
- [\[SpritePreview\]](#spritepreview)
|
||||
- [Special Attributes](#special-attributes)
|
||||
- [\[PathReference\]](#pathreference)
|
||||
- [\[Button\]](#button)
|
||||
|
||||
<div class="page">
|
||||
|
||||
# Normal Attributes #
|
||||
|
||||
## [Tile] ##
|
||||
|
||||
Alternative to **Header** attribute but with a line to separate the title from other fields.
|
||||
|
||||
### Usage ###
|
||||
|
||||
```cs
|
||||
public class AttributesExample : MonoBehaviour
|
||||
{
|
||||
[Title("Nice title attribute !",
|
||||
CustomColor.Yellow, CustomColor.Orange, 2f, 20f)]
|
||||
public bool DrawOtherFields
|
||||
}
|
||||
```
|
||||
|
||||
### Result ###
|
||||
|
||||

|
||||
|
||||
### Constructor ###
|
||||
|
||||
```cs
|
||||
public TitleAttribute(string title = "",
|
||||
CustomColor CustomColor = DefaultCustomColor,
|
||||
CustomColor lineColor = DefaultLineColor,
|
||||
float lineHeight = DefaultLineHeight,
|
||||
float spacing = 14f,
|
||||
bool alignTitleLeft = false)
|
||||
{
|
||||
Title = title;
|
||||
CustomColor = CustomColor;
|
||||
LineColor = lineColor;
|
||||
CustomColorString = ColorUtility.ToHtmlStringRGB(CustomColor.GetColor());
|
||||
LineColorString = ColorUtility.ToHtmlStringRGB(LineColor.GetColor());
|
||||
LineHeight = Mathf.Max(1f, lineHeight);
|
||||
Spacing = spacing;
|
||||
AlignTitleLeft = alignTitleLeft;
|
||||
}
|
||||
```
|
||||
|
||||
### Constants ###
|
||||
```cs
|
||||
public const float DefaultLineHeight = 1f;
|
||||
public const CustomColor DefaultLineColor = CustomColor.LightGray;
|
||||
public const CustomColor DefaultCustomColor = CustomColor.Bright;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## [ReadOnly] ##
|
||||
|
||||
Used to disable modifications to a serialized field.
|
||||
|
||||
### Usage ###
|
||||
|
||||
```cs
|
||||
public class AttributesExample : MonoBehaviour
|
||||
{
|
||||
[ReadOnly]
|
||||
public float ReadOnlyFloat;
|
||||
}
|
||||
```
|
||||
|
||||
### Result ###
|
||||
|
||||

|
||||
|
||||
### Constructor ###
|
||||
|
||||
There are no parameters for this attribute.
|
||||
|
||||
---
|
||||
|
||||
## [DrawIf] ##
|
||||
|
||||
Draw a property field if the condition is true. (Only for Boolean and Enum)
|
||||
In the example below, we are hiding the field **Name** until the **DrawOtherFields** field value is set to true.
|
||||
|
||||
### Usage ###
|
||||
|
||||
```cs
|
||||
public class AttributesExample : MonoBehaviour
|
||||
{
|
||||
public bool DrawOtherFields = false;
|
||||
|
||||
[DrawIf(nameof(DrawOtherFields), true)]
|
||||
public string Name;
|
||||
}
|
||||
```
|
||||
|
||||
### Result ###
|
||||
|
||||
False
|
||||
|
||||

|
||||
|
||||
True
|
||||
|
||||

|
||||
|
||||
### Constructor ###
|
||||
|
||||
```cs
|
||||
/// <summary>
|
||||
/// Only draws the field if the condition is true.<br></br>
|
||||
/// Supports Boolean and Enum.
|
||||
/// </summary>
|
||||
/// <param name="comparedPropertyName">The name of the property that is being compared (case sensitive).</param>
|
||||
/// <param name="comparedValue">The value the property is being compared to.</param>
|
||||
/// <param name="disablingType">Determine if it will hide the field or make it read only if the condition is NOT met.
|
||||
/// Defaulted to DisablingType.DontDraw.</param>
|
||||
|
||||
public DrawIfAttribute(string comparedPropertyName,
|
||||
object comparedValue,
|
||||
DisablingType disablingType = DisablingType.DontDraw)
|
||||
{
|
||||
ComparedPropertyName = comparedPropertyName;
|
||||
ComparedValue = comparedValue;
|
||||
DisablingType = disablingType;
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## [HelpBox] ##
|
||||
|
||||
Display an help box in the inspector with a message and a type (None, Info, Warning, Error)
|
||||
|
||||
### Usage ###
|
||||
|
||||
```cs
|
||||
public class AttributesExample : MonoBehaviour
|
||||
{
|
||||
[HelpBox("HelpBox attribute is useful to describe the usage of a field directly on the inspector window.", HelpBoxMessageType.Warning)]
|
||||
public bool ToggleToEdit = false;
|
||||
}
|
||||
```
|
||||
|
||||
### Result ###
|
||||
|
||||

|
||||
|
||||
### Constructor ###
|
||||
|
||||
```cs
|
||||
public HelpBoxAttribute(string text,
|
||||
HelpBoxMessageType messageType = HelpBoxMessageType.None,
|
||||
float minimumHeight = 20,
|
||||
int fontSize = 12)
|
||||
{
|
||||
Text = text;
|
||||
MessageType = messageType;
|
||||
MinimumHeight = minimumHeight;
|
||||
FontSize = fontSize;
|
||||
}
|
||||
```
|
||||
---
|
||||
|
||||
## [MinMaxSlider] ##
|
||||
|
||||
Show a slider with minimum and maximum values for a Vector2.
|
||||
|
||||
### Usage ###
|
||||
|
||||
```cs
|
||||
public class AttributesExample : MonoBehaviour
|
||||
{
|
||||
[MinMaxSlider(0, 100)]
|
||||
public Vector2 MinMaxSliderAttribute;
|
||||
}
|
||||
```
|
||||
|
||||
### Result ###
|
||||
|
||||

|
||||
|
||||
### Constructor ###
|
||||
|
||||
```cs
|
||||
public MinMaxSliderAttribute(float min, float max)
|
||||
{
|
||||
Min = min;
|
||||
Max = max;
|
||||
}
|
||||
```
|
||||
---
|
||||
|
||||
## [SnappedSlider] ##
|
||||
|
||||
Draw a slider to increase an integer or a float value by a certain amount (step) and clamped by a minimum and a maximum value. (Only for Integer and Float)
|
||||
|
||||
### Usage ###
|
||||
|
||||
```cs
|
||||
public class AttributesExample : MonoBehaviour
|
||||
{
|
||||
[SnappedSlider(0.25f, 1f, 10f)]
|
||||
Public float SnappedFloat;
|
||||
}
|
||||
```
|
||||
|
||||
### Result ###
|
||||
|
||||

|
||||
|
||||
<div class="page">
|
||||
|
||||
### Constructors ###
|
||||
|
||||
```cs
|
||||
/// <summary>
|
||||
/// Increase a float value in step<br></br>
|
||||
/// Value is clamped by min and max parameters
|
||||
/// </summary>
|
||||
/// <param name="step">Value to add</param>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
public SnappedSliderAttribute(float step, float min, float max)
|
||||
{
|
||||
Step = step;
|
||||
Min = min;
|
||||
Max = max;
|
||||
Precision = MathExtensions.CountFloatDigits(step);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Increase an int value in step<br></br>
|
||||
/// Value is clamped by min and max parameters
|
||||
/// </summary>
|
||||
/// <param name="step">Value to add</param>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <param name="allowNonStepReach"></param>
|
||||
public SnappedSliderAttribute(int step, int min, int max, bool allowNonStepReach = true)
|
||||
{
|
||||
Min = min;
|
||||
Max = max;
|
||||
Step = step;
|
||||
AllowNonStepReach = allowNonStepReach;
|
||||
IsInt = true;
|
||||
}
|
||||
```
|
||||
---
|
||||
|
||||
## [Required] ##
|
||||
|
||||
Draw an Help Box (Error Type) if a field value is empty or null.
|
||||
|
||||
### Supported SerializedPropertyType ###
|
||||
|
||||
* String
|
||||
* ObjectReference
|
||||
* ExposedReference
|
||||
* ManagedReference
|
||||
|
||||
<div class="page">
|
||||
|
||||
### Usage ###
|
||||
|
||||
```cs
|
||||
public class AttributesExample : MonoBehaviour
|
||||
{
|
||||
[Required]
|
||||
public Collider Collider;
|
||||
}
|
||||
```
|
||||
|
||||
### Result ###
|
||||
|
||||

|
||||
|
||||
### Constructor ###
|
||||
|
||||
There are no parameters for this attribute.
|
||||
|
||||
---
|
||||
|
||||
## [SpritePreview] ##
|
||||
|
||||
Draw the texture below a sprite field.
|
||||
|
||||
### Usage ###
|
||||
|
||||
```cs
|
||||
public class AttributesExample : MonoBehaviour
|
||||
{
|
||||
[SpritePreview]
|
||||
public Sprite Sprite;
|
||||
}
|
||||
```
|
||||
|
||||
<div class="page">
|
||||
|
||||
### Result ###
|
||||
|
||||

|
||||
|
||||
### Constructor ###
|
||||
```cs
|
||||
/// <summary>
|
||||
/// Dispaly the texture below a sprite field.
|
||||
/// </summary>
|
||||
/// <param name="maximumHeight">Maximum height of the preview (With useAssetPreview set to false)</param>
|
||||
/// <param name="backgroundColor">The color behind the texture</param>
|
||||
/// <param name="useAssetPreview">If true it will use AssetPreview.GetAssetPreview to draw the texture, the maximumHeight doesn't change anyting</param>
|
||||
public SpritePreviewAttribute(float maximumHeight = 256f, CustomColor backgroundColor = DefaultBackgroundColor, bool useAssetPreview = false)
|
||||
{
|
||||
UseAssetPreview = useAssetPreview;
|
||||
MaximumHeight = maximumHeight;
|
||||
BackgroundColor = backgroundColor;
|
||||
BackgroundColorString = ColorUtility.ToHtmlStringRGB(BackgroundColor.ToColor());
|
||||
}
|
||||
```
|
||||
|
||||
<div class="page">
|
||||
|
||||
# Special Attributes
|
||||
|
||||
Theses are not working like usual attributes, PathReference is not even an attribute it's a serializable class.
|
||||
|
||||
## [PathReference] ##
|
||||
|
||||
Allow to store the GUI and the Path of an asset folder.
|
||||
You can either drag and drop a folder or select it by clicking on the icon on the right.
|
||||
|
||||
### Usage ###
|
||||
|
||||
```cs
|
||||
public class AttributesExample : MonoBehaviour
|
||||
{
|
||||
Public PathReference Path;
|
||||
}
|
||||
```
|
||||
|
||||
### Result ###
|
||||
|
||||

|
||||
|
||||
### Constructor ###
|
||||
|
||||
There are no parameters for this attribute.
|
||||
|
||||
### Limitations ###
|
||||
|
||||
You cannot call PathReference.Path at Runtime, because it's using AssetDatabase class.
|
||||
You can only use the GUI Property.
|
||||
|
||||
---
|
||||
|
||||
## [Button] ##
|
||||
|
||||
Draw button in the inspector.
|
||||
This works using several classes :
|
||||
* ButtonAttribute
|
||||
* Button
|
||||
* ButtonDrawers
|
||||
* EditorButtons
|
||||
|
||||
<div class="page">
|
||||
|
||||
### Usage ###
|
||||
|
||||
```cs
|
||||
public class AttributesExample : MonoBehaviour
|
||||
{
|
||||
[Button(nameof(ButtonCallback), "Click on me !", 100f, row: "first")]
|
||||
public void ButtonCallback()
|
||||
{
|
||||
Debug.Log("You clicked on a button, congrats.");
|
||||
}
|
||||
|
||||
[Button(nameof(Test), "Another button", 100f, row:"first")]
|
||||
public void Test()
|
||||
{
|
||||
Debug.Log("This method is incredibly useful.");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Result ###
|
||||
|
||||

|
||||
|
||||
<div class="page">
|
||||
|
||||
### Constructors ###
|
||||
|
||||
```cs
|
||||
public ButtonAttribute(string methodName,
|
||||
string label = "",
|
||||
float width = default,
|
||||
int space = default,
|
||||
string row = default)
|
||||
{
|
||||
MethodName = methodName;
|
||||
Label = label;
|
||||
Space = space;
|
||||
Row = row;
|
||||
HasRow = !string.IsNullOrEmpty(Row);
|
||||
}
|
||||
|
||||
public Button(MethodInfo method, ButtonAttribute buttonAttribute)
|
||||
{
|
||||
ButtonAttribute = buttonAttribute;
|
||||
Label = string.IsNullOrEmpty(buttonAttribute.Label) ? ObjectNames.NicifyVariableName(method.Name) : buttonAttribute.Label;
|
||||
Method = method;
|
||||
}
|
||||
```
|
||||
|
||||
### Limitations ###
|
||||
|
||||
By default this wont work inside your custom editor because you need them to inherit from EditorButtons.
|
||||
|
||||
---
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc2d1b01447be7540864704b3fda1f16
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/HGF/Tetra Attributes/Documentation/Documentation.pdf
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f449960bbcc36a34ca93593270a681e4
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5783129b447fde744ab708ff0238c078
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 2.1 KiB |
@@ -0,0 +1,123 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41a2599f23b4c0842af9d993020653a9
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 3.6 KiB |
@@ -0,0 +1,123 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40f7451a89a2de24582ffd1bc5579560
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 13 KiB |
@@ -0,0 +1,123 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a83396ca5a67463499ba2e23f8a21807
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 6.0 KiB |
@@ -0,0 +1,123 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bb00d9cd925dace4f877c8509da26753
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 2.7 KiB |
@@ -0,0 +1,123 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4bf191b3192f50f4b9e3fe3d748273c2
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
@@ -0,0 +1,123 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9c40e69ec724744e9afff30989c83c7
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 3.7 KiB |
@@ -0,0 +1,123 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d6eb1adfda2bde47bc6e28ee075d968
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 5.8 KiB |
@@ -0,0 +1,123 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf9582a3ddc60ed4c80acd544f943a73
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 4.5 KiB |
@@ -0,0 +1,123 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d041933ac141454bba5d818e757c27c
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 38 KiB |
@@ -0,0 +1,123 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 204b71cb088ffe241b8f07f1b5f32b6b
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 493 KiB |
@@ -0,0 +1,123 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aefac71c0c99d1049bcb6da2d16171da
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
After Width: | Height: | Size: 14 KiB |
@@ -0,0 +1,123 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7295a76c66bdc83468f0573e4703b882
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/HGF/Tetra Attributes/Editor.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b00aa949040cfdd4085ce4ccaeddbe24
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
35
Assets/HGF/Tetra Attributes/Editor/Button.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TetraCreations.Attributes.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// Store MethodInfo to invoke it on click<br></br>
|
||||
/// By default the button label will be the method name
|
||||
/// </summary>
|
||||
public class Button
|
||||
{
|
||||
public string Label { get; private set; }
|
||||
public MethodInfo Method { get; private set; }
|
||||
public ButtonAttribute ButtonAttribute { get; private set; }
|
||||
|
||||
public Button(MethodInfo method, ButtonAttribute buttonAttribute)
|
||||
{
|
||||
ButtonAttribute = buttonAttribute;
|
||||
Label = string.IsNullOrEmpty(buttonAttribute.Label) ? ObjectNames.NicifyVariableName(method.Name) : buttonAttribute.Label;
|
||||
Method = method;
|
||||
}
|
||||
|
||||
internal void Draw(IEnumerable<object> targets)
|
||||
{
|
||||
if (!GUILayout.Button(Label)) return;
|
||||
|
||||
foreach (object target in targets)
|
||||
{
|
||||
Method.Invoke(target, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/HGF/Tetra Attributes/Editor/Button.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53908815abd0b3040804933aab0c749f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
39
Assets/HGF/Tetra Attributes/Editor/EditorButtons.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TetraCreations.Attributes.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom editor for UnityEngine.Object, this will instantiate a ButtonsDrawer.<br></br>
|
||||
/// Inside OnInspectorGUI() it will simply draw the default inspector.<br></br>
|
||||
/// Then it will draw all buttons. <br></br>
|
||||
/// You need to inherit from this class if you want to display buttons inside your custom editor.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(Object), true), CanEditMultipleObjects]
|
||||
public class EditorButtons : UnityEditor.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// Set to false if you don't want the buttons to be drawned
|
||||
/// </summary>
|
||||
private bool _enabled = true;
|
||||
|
||||
private ButtonsDrawer _buttonsDrawer;
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
_buttonsDrawer = new ButtonsDrawer(target);
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (serializedObject == null) { return; }
|
||||
|
||||
DrawDefaultInspector();
|
||||
|
||||
if (_enabled && _buttonsDrawer != null)
|
||||
{
|
||||
_buttonsDrawer.DrawButtons(targets);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/HGF/Tetra Attributes/Editor/EditorButtons.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9e8c01728df0a948a06f2b55561ef90
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/HGF/Tetra Attributes/Editor/Property Drawers.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9779f1ef83e33c54db6e21552ea5efec
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,69 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
|
||||
namespace TetraCreations.Attributes.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to draw buttons inside inspector using Button attribute on an method by using Reflection.<br></br>
|
||||
/// Buttons can be group together by using Row property like so :<br></br>
|
||||
/// [Button(nameof(ButtonCallback), "First Button", 100f, row: "first")]
|
||||
/// [Button(nameof(ButtonCallback2), "Second Button", 100f, row: "first")]
|
||||
/// </summary>
|
||||
public class ButtonsDrawer
|
||||
{
|
||||
public List<IGrouping<string, Button>> ButtonGroups { get; private set; }
|
||||
|
||||
public ButtonsDrawer(object target)
|
||||
{
|
||||
const BindingFlags flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
|
||||
var methods = target.GetType().GetMethods(flags);
|
||||
var buttons = new List<Button>();
|
||||
var rowNumber = 0;
|
||||
|
||||
// Create a Button foreach methods with the ButtonAttribute
|
||||
foreach (MethodInfo method in methods)
|
||||
{
|
||||
var buttonAttribute = method.GetCustomAttribute<ButtonAttribute>();
|
||||
|
||||
if (buttonAttribute == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
buttons.Add(new Button(method, buttonAttribute));
|
||||
}
|
||||
|
||||
ButtonGroups = buttons.GroupBy(button =>
|
||||
{
|
||||
var attribute = button.ButtonAttribute;
|
||||
var hasRow = attribute.HasRow;
|
||||
return hasRow ? attribute.Row : $"__{rowNumber++}";
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draw buttons by group
|
||||
/// </summary>
|
||||
/// <param name="targets"></param>
|
||||
public void DrawButtons(IEnumerable<object> targets)
|
||||
{
|
||||
foreach (var buttonGroup in ButtonGroups)
|
||||
{
|
||||
if (buttonGroup.Count() > 0)
|
||||
{
|
||||
var space = buttonGroup.First().ButtonAttribute.Space;
|
||||
if (space != 0) EditorGUILayout.Space(space);
|
||||
}
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
foreach (var button in buttonGroup)
|
||||
{
|
||||
button.Draw(targets);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 303c1fd4caceda14db2088beb1687196
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,139 @@
|
||||
using System.Collections;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TetraCreations.Attributes.Editor
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(DrawIfAttribute))]
|
||||
public class DrawIfPropertyDrawer : PropertyDrawer
|
||||
{
|
||||
private DrawIfAttribute _drawIf;
|
||||
private SerializedProperty _comparedField;
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
if (!ShowMe(property) && _drawIf.DisablingType == DisablingType.DontDraw)
|
||||
{
|
||||
return -EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (property.propertyType == SerializedPropertyType.Generic)
|
||||
{
|
||||
int numChildren = 0;
|
||||
float totalHeight = 0.0f;
|
||||
|
||||
IEnumerator children = property.GetEnumerator();
|
||||
|
||||
while (children.MoveNext())
|
||||
{
|
||||
SerializedProperty child = children.Current as SerializedProperty;
|
||||
|
||||
GUIContent childLabel = new GUIContent(child.displayName);
|
||||
|
||||
totalHeight += EditorGUI.GetPropertyHeight(child, childLabel) + EditorGUIUtility.standardVerticalSpacing;
|
||||
numChildren++;
|
||||
}
|
||||
|
||||
// Remove extra space at end, (we only want spaces between items)
|
||||
totalHeight -= EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
return totalHeight;
|
||||
}
|
||||
|
||||
return EditorGUI.GetPropertyHeight(property, label);
|
||||
}
|
||||
}
|
||||
|
||||
private bool ShowMe(SerializedProperty property)
|
||||
{
|
||||
_drawIf = attribute as DrawIfAttribute;
|
||||
|
||||
_comparedField = TryToFindSerializableProperty(_drawIf.ComparedPropertyName, property);
|
||||
|
||||
// We check that exist a Field with the parameter name
|
||||
if (_comparedField == null)
|
||||
{
|
||||
Debug.Log("Error getting the condition Field. Check the name.");
|
||||
return true;
|
||||
}
|
||||
|
||||
// get the value & compare based on types
|
||||
switch (_comparedField.type)
|
||||
{ // Possible extend cases to support your own type
|
||||
case "bool":
|
||||
return _comparedField.boolValue.Equals(_drawIf.ComparedValue);
|
||||
case "Enum":
|
||||
return (_comparedField.intValue & (int)_drawIf.ComparedValue) == (int)_drawIf.ComparedValue;
|
||||
default:
|
||||
Debug.LogError("Error: " + _comparedField.type + " is not supported");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
// If the condition is met, simply draw the field.
|
||||
if (ShowMe(property))
|
||||
{
|
||||
// A Generic type means a custom class...
|
||||
if (property.propertyType == SerializedPropertyType.Generic)
|
||||
{
|
||||
IEnumerator children = property.GetEnumerator();
|
||||
|
||||
Rect offsetPosition = position;
|
||||
|
||||
while (children.MoveNext())
|
||||
{
|
||||
SerializedProperty child = children.Current as SerializedProperty;
|
||||
|
||||
GUIContent childLabel = new GUIContent(child.displayName);
|
||||
|
||||
float childHeight = EditorGUI.GetPropertyHeight(child, childLabel);
|
||||
offsetPosition.height = childHeight;
|
||||
|
||||
EditorGUI.PropertyField(offsetPosition, child, childLabel);
|
||||
|
||||
offsetPosition.y += childHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.PropertyField(position, property, label);
|
||||
}
|
||||
|
||||
} //...check if the disabling type is read only. If it is, draw it disabled
|
||||
else if (_drawIf.DisablingType == DisablingType.ReadOnly)
|
||||
{
|
||||
GUI.enabled = false;
|
||||
EditorGUI.PropertyField(position, property, label);
|
||||
GUI.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return SerializedProperty by it's name if it exists, it works for nested objects and arrays
|
||||
/// </summary>
|
||||
/// <param name="propertyName"></param>
|
||||
/// <param name="property"></param>
|
||||
/// <returns></returns>
|
||||
private SerializedProperty TryToFindSerializableProperty(string propertyName, SerializedProperty property)
|
||||
{
|
||||
var serializedProperty = property.serializedObject.FindProperty(propertyName);
|
||||
|
||||
// Find relative
|
||||
if (serializedProperty == null)
|
||||
{
|
||||
string propertyPath = property.propertyPath;
|
||||
int idx = propertyPath.LastIndexOf('.');
|
||||
if (idx != -1)
|
||||
{
|
||||
propertyPath = propertyPath.Substring(0, idx);
|
||||
return property.serializedObject.FindProperty(propertyPath).FindPropertyRelative(propertyName);
|
||||
}
|
||||
}
|
||||
|
||||
return serializedProperty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b434f6c952ac41a43996761b708ae148
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,48 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace TetraCreations.Attributes.Editor
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(HelpBoxAttribute))]
|
||||
public class HelpBoxDecoratorDrawer : DecoratorDrawer
|
||||
{
|
||||
public override float GetHeight()
|
||||
{
|
||||
try
|
||||
{
|
||||
var helpBoxAttribute = attribute as HelpBoxAttribute;
|
||||
|
||||
if (helpBoxAttribute == null) return base.GetHeight();
|
||||
var helpBoxStyle = (GUI.skin != null) ? GUI.skin.GetStyle("helpbox") : null;
|
||||
if (helpBoxStyle == null) return base.GetHeight();
|
||||
|
||||
helpBoxStyle.fontSize = helpBoxAttribute.FontSize;
|
||||
return Mathf.Max(40f, helpBoxStyle.CalcHeight(new GUIContent(helpBoxAttribute.Text), EditorGUIUtility.currentViewWidth) + 4);
|
||||
}
|
||||
catch (System.ArgumentException)
|
||||
{
|
||||
return 3 * EditorGUIUtility.singleLineHeight; // Handle Unity 2022.2 bug by returning default value.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void OnGUI(Rect position)
|
||||
{
|
||||
var helpBoxAttribute = attribute as HelpBoxAttribute;
|
||||
if (helpBoxAttribute == null) return;
|
||||
EditorGUI.HelpBox(position, helpBoxAttribute.Text, GetMessageType(helpBoxAttribute.MessageType));
|
||||
}
|
||||
|
||||
private MessageType GetMessageType(HelpBoxMessageType helpBoxMessageType)
|
||||
{
|
||||
switch (helpBoxMessageType)
|
||||
{
|
||||
default:
|
||||
case HelpBoxMessageType.None: return MessageType.None;
|
||||
case HelpBoxMessageType.Info: return MessageType.Info;
|
||||
case HelpBoxMessageType.Warning: return MessageType.Warning;
|
||||
case HelpBoxMessageType.Error: return MessageType.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 206baa8e56d288847b1b642b461f6add
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,110 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace TetraCreations.Attributes.Editor
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(MinMaxSliderAttribute))]
|
||||
public class MinMaxSliderAttributeDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var minMaxAttribute = (MinMaxSliderAttribute)attribute;
|
||||
var propertyType = property.propertyType;
|
||||
|
||||
label.tooltip = minMaxAttribute.Min.ToString("F2") + " to " + minMaxAttribute.Max.ToString("F2");
|
||||
|
||||
//PrefixLabel returns the rect of the right part of the control. It leaves out the label section.
|
||||
Rect controlRect = EditorGUI.PrefixLabel(position, label);
|
||||
|
||||
Rect[] splittedRect = SplitRect(controlRect, 3);
|
||||
|
||||
if (propertyType == SerializedPropertyType.Vector2)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
Vector2 vector = property.vector2Value;
|
||||
float minVal = vector.x;
|
||||
float maxVal = vector.y;
|
||||
|
||||
//F2 limits the float to two decimal places (0.00).
|
||||
minVal = EditorGUI.FloatField(splittedRect[0], float.Parse(minVal.ToString("F2")));
|
||||
maxVal = EditorGUI.FloatField(splittedRect[2], float.Parse(maxVal.ToString("F2")));
|
||||
|
||||
EditorGUI.MinMaxSlider(splittedRect[1], ref minVal, ref maxVal,
|
||||
minMaxAttribute.Min, minMaxAttribute.Max);
|
||||
|
||||
if (minVal < minMaxAttribute.Min)
|
||||
{
|
||||
minVal = minMaxAttribute.Min;
|
||||
}
|
||||
|
||||
if (maxVal > minMaxAttribute.Max)
|
||||
{
|
||||
maxVal = minMaxAttribute.Max;
|
||||
}
|
||||
|
||||
vector = new Vector2(minVal > maxVal ? maxVal : minVal, maxVal);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
property.vector2Value = vector;
|
||||
}
|
||||
|
||||
}
|
||||
else if (propertyType == SerializedPropertyType.Vector2Int)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
Vector2Int vector = property.vector2IntValue;
|
||||
float minVal = vector.x;
|
||||
float maxVal = vector.y;
|
||||
|
||||
minVal = EditorGUI.FloatField(splittedRect[0], minVal);
|
||||
maxVal = EditorGUI.FloatField(splittedRect[2], maxVal);
|
||||
|
||||
EditorGUI.MinMaxSlider(splittedRect[1], ref minVal, ref maxVal,
|
||||
minMaxAttribute.Min, minMaxAttribute.Max);
|
||||
|
||||
if (minVal < minMaxAttribute.Min)
|
||||
{
|
||||
maxVal = minMaxAttribute.Min;
|
||||
}
|
||||
|
||||
if (minVal > minMaxAttribute.Max)
|
||||
{
|
||||
maxVal = minMaxAttribute.Max;
|
||||
}
|
||||
|
||||
vector = new Vector2Int(Mathf.FloorToInt(minVal > maxVal ? maxVal : minVal), Mathf.FloorToInt(maxVal));
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
property.vector2IntValue = vector;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Rect[] SplitRect(Rect rectToSplit, int n)
|
||||
{
|
||||
Rect[] rects = new Rect[n];
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
rects[i] = new Rect(rectToSplit.position.x + (i * rectToSplit.width / n), rectToSplit.position.y, rectToSplit.width / n, rectToSplit.height);
|
||||
}
|
||||
|
||||
int padding = (int)rects[0].width - 40;
|
||||
int space = 3;
|
||||
|
||||
rects[0].width -= padding + space;
|
||||
rects[2].width -= padding + space;
|
||||
|
||||
rects[1].x -= padding;
|
||||
rects[1].width += padding * 2;
|
||||
|
||||
rects[2].x += padding + space;
|
||||
|
||||
return rects;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0da3c3153d7e9e640affadfd7ffd4247
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,125 @@
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace TetraCreations.Attributes.Editor
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(PathReference))]
|
||||
public class PathPropertyDrawer : PropertyDrawer
|
||||
{
|
||||
private string _selectFolderLabel = "Select Folder";
|
||||
private string _invalidPathSubFolderText = "Invalid Path : Choose any folder inside the 'Assets' folder.";
|
||||
|
||||
private bool _initialized;
|
||||
private Object _obj;
|
||||
private SerializedProperty guid;
|
||||
|
||||
private void Init(SerializedProperty property)
|
||||
{
|
||||
_initialized = false;
|
||||
|
||||
guid = property.FindPropertyRelative("GUI");
|
||||
|
||||
if (guid == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_obj = AssetDatabase.LoadAssetAtPath<Object>(AssetDatabase.GUIDToAssetPath(guid.stringValue));
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
if (!_initialized)
|
||||
{
|
||||
Init(property);
|
||||
}
|
||||
|
||||
if (_obj == null && string.IsNullOrEmpty(guid.stringValue) == false)
|
||||
{
|
||||
_obj = AssetDatabase.LoadAssetAtPath<Object>(AssetDatabase.GUIDToAssetPath(guid.stringValue));
|
||||
}
|
||||
|
||||
GUIContent guiContent = EditorGUIUtility.ObjectContent(_obj, typeof(DefaultAsset));
|
||||
|
||||
Rect r = EditorGUI.PrefixLabel(position, label);
|
||||
|
||||
Rect textFieldRect = r;
|
||||
textFieldRect.width -= 19f;
|
||||
|
||||
GUIStyle textFieldStyle = new GUIStyle("TextField")
|
||||
{
|
||||
imagePosition = _obj ? ImagePosition.ImageLeft : ImagePosition.TextOnly
|
||||
};
|
||||
|
||||
if (GUI.Button(textFieldRect, guiContent, textFieldStyle) && _obj)
|
||||
{
|
||||
EditorGUIUtility.PingObject(_obj);
|
||||
}
|
||||
|
||||
if (textFieldRect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
if (Event.current.type == EventType.DragUpdated)
|
||||
{
|
||||
Object reference = DragAndDrop.objectReferences[0];
|
||||
string path = AssetDatabase.GetAssetPath(reference);
|
||||
DragAndDrop.visualMode = Directory.Exists(path) ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected;
|
||||
Event.current.Use();
|
||||
}
|
||||
else if (Event.current.type == EventType.DragPerform)
|
||||
{
|
||||
Object reference = DragAndDrop.objectReferences[0];
|
||||
string path = AssetDatabase.GetAssetPath(reference);
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
_obj = reference;
|
||||
guid.stringValue = AssetDatabase.AssetPathToGUID(path);
|
||||
property.serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
Event.current.Use();
|
||||
}
|
||||
else if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Delete)
|
||||
{
|
||||
guid.stringValue = "";
|
||||
_obj = null;
|
||||
property.serializedObject.ApplyModifiedProperties();
|
||||
Event.current.Use();
|
||||
}
|
||||
}
|
||||
|
||||
Rect objectFieldRect = r;
|
||||
objectFieldRect.x = textFieldRect.xMax + 1f;
|
||||
objectFieldRect.width = 19f;
|
||||
|
||||
if (GUI.Button(objectFieldRect, "", GUI.skin.GetStyle("IN ObjectField")))
|
||||
{
|
||||
string path = EditorUtility.OpenFolderPanel(_selectFolderLabel, "Assets", "");
|
||||
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
GUIUtility.ExitGUI();
|
||||
return;
|
||||
}
|
||||
|
||||
if (path.Contains(Application.dataPath))
|
||||
{
|
||||
path = "Assets" + path.Substring(Application.dataPath.Length);
|
||||
|
||||
_obj = AssetDatabase.LoadAssetAtPath(path, typeof(DefaultAsset));
|
||||
|
||||
guid.stringValue = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(_obj));
|
||||
property.serializedObject.ApplyModifiedProperties();
|
||||
GUIUtility.ExitGUI();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError(_invalidPathSubFolderText);
|
||||
}
|
||||
|
||||
GUIUtility.ExitGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||