Gameplay Ingredients是一组用于 Unity 游戏的运行时和编辑器工具:一组脚本的集合,可在制作游戏和原型时简化简单的任务。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

55 行
1.6 KiB

using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using Object = UnityEngine.Object;
using UnityEngine.Events;
namespace GameplayIngredients.Editor
{
public class InvalidTransformCheck : Check
{
public override string name => "GameObject/Invalid Transform";
public override bool defaultEnabled => true;
public override string[] ResolutionActions => new string[] { "Do Nothing", "Reset", "Delete Object" };
public override int defaultResolutionActionIndex => 0;
public override IEnumerable<CheckResult> GetResults(SceneObjects so)
{
try
{
int count = so.allObjects.Length;
int i = 0;
foreach (var go in so.allObjects)
{
float progress = ++i / count;
if (EditorUtility.DisplayCancelableProgressBar("Finding Transforms...", $"{go.name}", progress))
{
break;
}
Transform t = go.transform;
if(t.localScale.sqrMagnitude == 0)
{
yield return new CheckResult(this, CheckResult.Result.Warning, $"Transform of Game Object \"{go.name}\" has zero Scale.", go);
}
}
}
finally
{
EditorUtility.ClearProgressBar();
}
}
public override void Resolve(CheckResult result)
{
throw new System.NotImplementedException();
}
}
}