Files
FORT-BO/Assets/Plugins/VolumetricLightBeam/Editor/EditorCommon.cs
T
AsanoRema ffa1064063 Squashed commit of the following:
commit 428243f4a6
Author: AsanoRema <asanorema2036@gmail.com>
Date:   Sat Aug 29 13:43:13 2026 +0300

    Squashed commit of the following:

    commit 68e78fa464
    Author: AsanoRema <asanorema2036@gmail.com>
    Date:   Sat Aug 29 13:41:49 2026 +0300

        Updated .gitignore

commit 9f87122a34
Author: AsanoRema <asanorema2036@gmail.com>
Date:   Sat Aug 29 13:34:57 2026 +0300

    Added Dohya

commit f6a7547e84
Author: AsanoRema <asanorema2036@gmail.com>
Date:   Fri Aug 21 17:59:13 2026 +0300

    Fixed

commit b98901c366
Author: AsanoRema <asanorema2036@gmail.com>
Date:   Tue Aug 18 17:37:22 2026 +0300

    Added new particle Package

commit bb2f4a3b16
Author: AsanoRema <asanorema2036@gmail.com>
Date:   Tue Aug 18 17:17:48 2026 +0300

    Map mehanic ready to multiplayer

commit c01ff800f6
Author: AsanoRema <asanorema2036@gmail.com>
Date:   Tue Aug 18 16:16:19 2026 +0300

    Squashed commit of the following:

    commit 173bbb165c
    Author: henjkey <henjkey@gmail.com>
    Date:   Fri Aug 14 18:51:23 2026 +0500

        Mappp

    commit d559ab338a
    Author: henjkey <henjkey@gmail.com>
    Date:   Thu Aug 13 18:42:41 2026 +0500

        Map

        Controller
        Coordinates
        Target System
        Crosshair System
        Radar System
2026-08-29 13:45:55 +03:00

157 lines
5.2 KiB
C#

#if UNITY_EDITOR
#if UNITY_2019_1_OR_NEWER
#define UI_USE_FOLDOUT_HEADER_2019
#endif
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using System.Linq.Expressions;
using System.Reflection;
namespace VLB
{
public class EditorCommon : Editor
{
protected virtual void OnEnable()
{
FoldableHeader.OnEnable();
RetrieveSerializedProperties("_");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
#if UNITY_2019_3_OR_NEWER
// no vertical space in 2019.3 looks better
#else
EditorGUILayout.Separator();
#endif
}
public static void DrawLineSeparator()
{
DrawLineSeparator(Color.grey, 1, 10);
}
static void DrawLineSeparator(Color color, int thickness = 2, int padding = 10)
{
Rect r = EditorGUILayout.GetControlRect(GUILayout.Height(padding + thickness));
r.x = 0;
r.width = EditorGUIUtility.currentViewWidth;
r.y += padding / 2;
r.height = thickness;
EditorGUI.DrawRect(r, color);
}
protected void ButtonOpenConfig(bool miniButton = true)
{
bool buttonClicked = false;
if (miniButton) buttonClicked = GUILayout.Button(EditorStrings.Common.ButtonOpenGlobalConfig, EditorStyles.miniButton);
else buttonClicked = GUILayout.Button(EditorStrings.Common.ButtonOpenGlobalConfig);
if (buttonClicked)
Config.EditorSelectInstance();
}
protected bool GlobalToggleButton(ref bool boolean, GUIContent content, string saveString, float maxWidth = 999.0f)
{
EditorGUI.BeginChangeCheck();
boolean = GUILayout.Toggle(boolean, content, EditorStyles.miniButton, GUILayout.MaxWidth(maxWidth));
if (EditorGUI.EndChangeCheck())
{
EditorPrefs.SetBool(saveString, boolean);
SceneView.RepaintAll();
return true;
}
return false;
}
// SERIALIZED PROPERTY RETRIEVAL
string GetThisNamespaceAsString() { return GetType().Namespace; }
SerializedProperty FindProperty(string prefix, string name)
{
Debug.Assert(serializedObject != null);
var prop = serializedObject.FindProperty(name);
if (prop == null)
{
name = string.Format("{0}{1}{2}", prefix, char.ToUpperInvariant(name[0]), name.Substring(1)); // get '_Name' from 'name'
prop = serializedObject.FindProperty(name);
}
return prop;
}
void RetrieveSerializedProperties(string prefix, Type t)
{
if (t == null) return;
if (t.Namespace != GetThisNamespaceAsString()) return;
var allEditorFields = t.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
foreach (var field in allEditorFields)
{
if (field.FieldType == typeof(SerializedProperty))
{
var runtimeFieldName = field.Name;
var serializedProp = FindProperty(prefix, runtimeFieldName);
Debug.AssertFormat(serializedProp != null, "Fail to find serialized field '{0}' in object {1}", runtimeFieldName, serializedObject.targetObject);
field.SetValue(this, serializedProp);
}
}
RetrieveSerializedProperties(prefix, t.BaseType);
}
protected void RetrieveSerializedProperties(string prefix)
{
RetrieveSerializedProperties(prefix, GetType());
}
public abstract class EditorGUIWidth : System.IDisposable
{
protected abstract void ApplyWidth(float width);
public EditorGUIWidth(float width) { ApplyWidth(width); }
public void Dispose() { ApplyWidth(0.0f); }
}
public class LabelWidth : EditorGUIWidth
{
public LabelWidth(float width) : base(width) { }
protected override void ApplyWidth(float width) { EditorGUIUtility.labelWidth = width; }
}
public class FieldWidth : EditorGUIWidth
{
public FieldWidth(float width) : base(width) { }
protected override void ApplyWidth(float width) { EditorGUIUtility.fieldWidth = width; }
}
private static ArcHandle ms_HandleRadius = null;
// HANDLES
protected static ArcHandle handleRadius
{
get
{
if (ms_HandleRadius == null)
{
ms_HandleRadius = new ArcHandle();
ms_HandleRadius.SetColorWithRadiusHandle(Color.white, 0f);
ms_HandleRadius.angle = 360f;
ms_HandleRadius.angleHandleSizeFunction = null;
ms_HandleRadius.angleHandleColor = Color.clear;
}
return ms_HandleRadius;
}
}
}
}
#endif // UNITY_EDITOR