Skip to content

Commit

Permalink
エディタースクリプトを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
o-tr committed Sep 2, 2024
1 parent f57ab26 commit b547e42
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
Binary file modified Assets/Texture/splash/WeatherWidgetHorizontal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/Texture/splash/WeatherWidgetVertical.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions Runtime/Editor/VerticalLayoutEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using jp.ootr.common;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;

namespace jp.ootr.WeatherWidget.Editor
{
[CustomEditor(typeof(VerticalLayout))]
public class VerticalLayoutEditor : UnityEditor.Editor
{
private bool _debug;

public override void OnInspectorGUI()
{
var script = (VerticalLayout)target;

_debug = EditorGUILayout.ToggleLeft("Debug", _debug);
if (_debug)
{
base.OnInspectorGUI();
return;
}

EditorGUI.BeginChangeCheck();
EditorGUILayout.LabelField("WeatherWidget", EditorStyle.UiTitle);

EditorGUILayout.Space();

script.forecastCount = (int)EditorGUILayout.Slider("Forecast Count", script.forecastCount, 3, 7);

EditorGUILayout.Space();

if (EditorGUI.EndChangeCheck()) EditorUtility.SetDirty(script);
if (script.splashImage != null)
{
var texture = (Sprite)EditorGUILayout.ObjectField("Splash Image",
script.splashImage.sprite, typeof(Sprite), false);
if (texture != script.splashImage.sprite)
{
var splashImageProp = serializedObject.FindProperty("splashImage");
var splashImage = (Image)splashImageProp.objectReferenceValue;
var soImage = new SerializedObject(splashImage);
soImage.FindProperty("m_Texture").objectReferenceValue = texture;
soImage.ApplyModifiedProperties();
}
}
}
}
}
3 changes: 3 additions & 0 deletions Runtime/Editor/VerticalLayoutEditor.cs.meta

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

0 comments on commit b547e42

Please sign in to comment.