mirror of
https://github.com/codewriter-packages/Tri-Inspector.git
synced 2025-01-22 00:08:51 -05:00
Fix Scene attribute
This commit is contained in:
parent
86fed7a830
commit
6a5af4e687
@ -3,7 +3,7 @@ using TriInspector.Drawers;
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
[assembly: RegisterTriAttributeDrawer(typeof(SceneDrawer), TriDrawerOrder.Decorator)]
|
[assembly: RegisterTriAttributeDrawer(typeof(SceneDrawer), TriDrawerOrder.Decorator, ApplyOnArrayElement = true)]
|
||||||
|
|
||||||
namespace TriInspector.Drawers
|
namespace TriInspector.Drawers
|
||||||
{
|
{
|
||||||
@ -14,7 +14,7 @@ namespace TriInspector.Drawers
|
|||||||
var type = propertyDefinition.FieldType;
|
var type = propertyDefinition.FieldType;
|
||||||
if (type != typeof(string))
|
if (type != typeof(string))
|
||||||
{
|
{
|
||||||
return "Scene attribute can only be used on field of type int or string";
|
return "Scene attribute can only be used on field with string type";
|
||||||
}
|
}
|
||||||
|
|
||||||
return base.Initialize(propertyDefinition);
|
return base.Initialize(propertyDefinition);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
using TriInspector.Validators;
|
using TriInspector.Validators;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
|
||||||
[assembly: RegisterTriAttributeValidator(typeof(SceneValidator))]
|
[assembly: RegisterTriAttributeValidator(typeof(SceneValidator), ApplyOnArrayElement = true)]
|
||||||
|
|
||||||
namespace TriInspector.Validators
|
namespace TriInspector.Validators
|
||||||
{
|
{
|
||||||
@ -12,7 +12,12 @@ namespace TriInspector.Validators
|
|||||||
{
|
{
|
||||||
if (property.FieldType == typeof(string))
|
if (property.FieldType == typeof(string))
|
||||||
{
|
{
|
||||||
var value = property.Value;
|
var value = (string) property.Value;
|
||||||
|
|
||||||
|
if (AssetDatabase.LoadAssetAtPath<SceneAsset>(value) == null)
|
||||||
|
{
|
||||||
|
return TriValidationResult.Error($"{value} not a valid scene");
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var scene in EditorBuildSettings.scenes)
|
foreach (var scene in EditorBuildSettings.scenes)
|
||||||
{
|
{
|
||||||
@ -23,14 +28,16 @@ namespace TriInspector.Validators
|
|||||||
|
|
||||||
if (!scene.enabled)
|
if (!scene.enabled)
|
||||||
{
|
{
|
||||||
return TriValidationResult.Error($"{value} not in build settings");
|
return TriValidationResult.Error($"{value} disabled in build settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
return TriValidationResult.Valid;
|
return TriValidationResult.Valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return TriValidationResult.Error($"{value} not added to build settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
return TriValidationResult.Error($"{property.Value} not a valid scene");
|
return TriValidationResult.Valid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,10 @@
|
|||||||
using TriInspector;
|
using System.Collections.Generic;
|
||||||
|
using TriInspector;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class Decorators_SceneSample : ScriptableObject
|
public class Decorators_SceneSample : ScriptableObject
|
||||||
{
|
{
|
||||||
[Scene] public string scene;
|
[Scene] public string scene;
|
||||||
|
|
||||||
|
[Scene] public List<string> scenes;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user