init
This commit is contained in:
5
Assets/Editor/GUIWindows.meta
Normal file
5
Assets/Editor/GUIWindows.meta
Normal file
@@ -0,0 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4052862acd23cd644afbdebcc6dd5769
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
||||
35
Assets/Editor/GUIWindows/GUIPointerObjectEditor.cs
Normal file
35
Assets/Editor/GUIWindows/GUIPointerObjectEditor.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Rellac.Windows
|
||||
{
|
||||
[CustomEditor(typeof(GUIPointerObject))]
|
||||
[CanEditMultipleObjects]
|
||||
public class GUIPointerObjectEditor : Editor
|
||||
{
|
||||
|
||||
SerializedProperty onPointerUp;
|
||||
SerializedProperty onPointerDown;
|
||||
SerializedProperty onPointerEnter;
|
||||
SerializedProperty onPointerExit;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
onPointerUp = serializedObject.FindProperty("onPointerUp");
|
||||
onPointerDown = serializedObject.FindProperty("onPointerDown");
|
||||
onPointerEnter = serializedObject.FindProperty("onPointerEnter");
|
||||
onPointerExit = serializedObject.FindProperty("onPointerExit");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(onPointerUp);
|
||||
EditorGUILayout.PropertyField(onPointerDown);
|
||||
EditorGUILayout.PropertyField(onPointerEnter);
|
||||
EditorGUILayout.PropertyField(onPointerExit);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Assets/Editor/GUIWindows/GUIPointerObjectEditor.cs.meta
Normal file
8
Assets/Editor/GUIWindows/GUIPointerObjectEditor.cs.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e208f13f49d1a4c42b716cbde5c0ba97
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
8
Assets/Editor/RTG.meta
Normal file
8
Assets/Editor/RTG.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d6e7d03e48a331241bdbfbcb3dc7d268
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
23
Assets/Editor/RTG/RTCameraBackgroundInspector.cs
Normal file
23
Assets/Editor/RTG/RTCameraBackgroundInspector.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace RTG.Editor
|
||||
{
|
||||
[CustomEditor(typeof(RTCameraBackground))]
|
||||
public class RTCameraBackgroundInspector : UnityEditor.Editor
|
||||
{
|
||||
private RTCameraBackground _cameraBk;
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
_cameraBk.Settings.UsesFoldout = true;
|
||||
_cameraBk.Settings.FoldoutLabel = "Settings";
|
||||
_cameraBk.Settings.RenderEditorGUI(_cameraBk);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_cameraBk = target as RTCameraBackground;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Editor/RTG/RTCameraBackgroundInspector.cs.meta
Normal file
12
Assets/Editor/RTG/RTCameraBackgroundInspector.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e54013a3415b0f4fbce73f7ed820348
|
||||
timeCreated: 1514455192
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
70
Assets/Editor/RTG/RTCameraInspector.cs
Normal file
70
Assets/Editor/RTG/RTCameraInspector.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace RTG.Editor
|
||||
{
|
||||
[CustomEditor(typeof(RTFocusCamera))]
|
||||
public class RTCameraInspector : UnityEditor.Editor
|
||||
{
|
||||
private RTFocusCamera _camera;
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
Camera newCamera;
|
||||
|
||||
var content = new GUIContent();
|
||||
content.text = "Target camera";
|
||||
content.tooltip = "Allows you to specify the camera object which will be controlled by the RTFocusCamera script. Note: Prefabs are not allowed. Only scene cameras can be used.";
|
||||
newCamera = EditorGUILayout.ObjectField(content, _camera.TargetCamera, typeof(Camera), true) as Camera;
|
||||
if (newCamera != _camera.TargetCamera)
|
||||
{
|
||||
EditorUndoEx.Record(_camera);
|
||||
_camera.SetTargetCamera(newCamera);
|
||||
}
|
||||
|
||||
_camera.Settings.RenderEditorGUI(_camera);
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
_camera.MoveSettings.UsesFoldout = true;
|
||||
_camera.MoveSettings.FoldoutLabel = "Move settings";
|
||||
_camera.MoveSettings.RenderEditorGUI(_camera);
|
||||
|
||||
_camera.PanSettings.UsesFoldout = true;
|
||||
_camera.PanSettings.FoldoutLabel = "Pan settings";
|
||||
_camera.PanSettings.RenderEditorGUI(_camera);
|
||||
|
||||
_camera.LookAroundSettings.UsesFoldout = true;
|
||||
_camera.LookAroundSettings.FoldoutLabel = "Look around settings";
|
||||
_camera.LookAroundSettings.RenderEditorGUI(_camera);
|
||||
|
||||
_camera.OrbitSettings.UsesFoldout = true;
|
||||
_camera.OrbitSettings.FoldoutLabel = "Orbit settings";
|
||||
_camera.OrbitSettings.RenderEditorGUI(_camera);
|
||||
|
||||
_camera.ZoomSettings.UsesFoldout = true;
|
||||
_camera.ZoomSettings.FoldoutLabel = "Zoom settings";
|
||||
_camera.ZoomSettings.RenderEditorGUI(_camera);
|
||||
|
||||
_camera.FocusSettings.UsesFoldout = true;
|
||||
_camera.FocusSettings.FoldoutLabel = "Focus settings";
|
||||
_camera.FocusSettings.RenderEditorGUI(_camera);
|
||||
|
||||
_camera.RotationSwitchSettings.UsesFoldout = true;
|
||||
_camera.RotationSwitchSettings.FoldoutLabel = "Rotation switch settings";
|
||||
_camera.RotationSwitchSettings.RenderEditorGUI(_camera);
|
||||
|
||||
_camera.ProjectionSwitchSettings.UsesFoldout = true;
|
||||
_camera.ProjectionSwitchSettings.FoldoutLabel = "Projection switch settings";
|
||||
_camera.ProjectionSwitchSettings.RenderEditorGUI(_camera);
|
||||
|
||||
_camera.Hotkeys.UsesFoldout = true;
|
||||
_camera.Hotkeys.FoldoutLabel = "Hotkeys";
|
||||
_camera.Hotkeys.RenderEditorGUI(_camera);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_camera = target as RTFocusCamera;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Editor/RTG/RTCameraInspector.cs.meta
Normal file
12
Assets/Editor/RTG/RTCameraInspector.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 482e8f09e7fc2c44eb6b6168339d7be6
|
||||
timeCreated: 1485511969
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
105
Assets/Editor/RTG/RTGizmoEngineInspector.cs
Normal file
105
Assets/Editor/RTG/RTGizmoEngineInspector.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace RTG.Editor
|
||||
{
|
||||
[CustomEditor(typeof(RTGizmosEngine))]
|
||||
public class RTGizmoEngineInspector : UnityEditor.Editor
|
||||
{
|
||||
private const int _generalTab = 0;
|
||||
private const int _sceneGizmo = _generalTab + 1;
|
||||
private const int _moveGizmoTab = _sceneGizmo + 1;
|
||||
private const int _rotationGizmoTab = _moveGizmoTab + 1;
|
||||
private const int _scaleGizmoTab = _rotationGizmoTab + 1;
|
||||
private const int _universalGizmoTab = _scaleGizmoTab + 1;
|
||||
|
||||
private RTGizmosEngine _gizmoEngine;
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.Separator();
|
||||
_gizmoEngine.MainToolbar.RenderEditorGUI(_gizmoEngine);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_gizmoEngine = target as RTGizmosEngine;
|
||||
|
||||
_gizmoEngine.MainToolbar.GetTabByIndex(_generalTab).AddTargetSettings(_gizmoEngine.Settings);
|
||||
_gizmoEngine.MainToolbar.GetTabByIndex(_sceneGizmo).AddTargetSettings(_gizmoEngine.SceneGizmoLookAndFeel);
|
||||
|
||||
_gizmoEngine.MoveGizmoSettings2D.FoldoutLabel = "2D Mode settings";
|
||||
_gizmoEngine.MoveGizmoSettings2D.UsesFoldout = true;
|
||||
_gizmoEngine.MoveGizmoSettings3D.FoldoutLabel = "3D Mode settings";
|
||||
_gizmoEngine.MoveGizmoSettings3D.UsesFoldout = true;
|
||||
_gizmoEngine.MoveGizmoLookAndFeel2D.FoldoutLabel = "2D Mode look & feel";
|
||||
_gizmoEngine.MoveGizmoLookAndFeel2D.UsesFoldout = true;
|
||||
_gizmoEngine.MoveGizmoLookAndFeel3D.FoldoutLabel = "3D Mode look & feel";
|
||||
_gizmoEngine.MoveGizmoLookAndFeel3D.UsesFoldout = true;
|
||||
_gizmoEngine.MoveGizmoHotkeys.FoldoutLabel = "Hotkeys";
|
||||
_gizmoEngine.MoveGizmoHotkeys.UsesFoldout = true;
|
||||
_gizmoEngine.ObjectMoveGizmoSettings.FoldoutLabel = "Object settings";
|
||||
_gizmoEngine.ObjectMoveGizmoSettings.UsesFoldout = true;
|
||||
|
||||
_gizmoEngine.RotationGizmoSettings3D.FoldoutLabel = "Settings";
|
||||
_gizmoEngine.RotationGizmoSettings3D.UsesFoldout = true;
|
||||
_gizmoEngine.RotationGizmoLookAndFeel3D.FoldoutLabel = "Look & feel";
|
||||
_gizmoEngine.RotationGizmoLookAndFeel3D.UsesFoldout = true;
|
||||
_gizmoEngine.RotationGizmoHotkeys.FoldoutLabel = "Hotkeys";
|
||||
_gizmoEngine.RotationGizmoHotkeys.UsesFoldout = true;
|
||||
_gizmoEngine.ObjectRotationGizmoSettings.FoldoutLabel = "Object settings";
|
||||
_gizmoEngine.ObjectRotationGizmoSettings.UsesFoldout = true;
|
||||
|
||||
_gizmoEngine.ScaleGizmoSettings3D.FoldoutLabel = "Settings";
|
||||
_gizmoEngine.ScaleGizmoSettings3D.UsesFoldout = true;
|
||||
_gizmoEngine.ScaleGizmoLookAndFeel3D.FoldoutLabel = "Look & feel";
|
||||
_gizmoEngine.ScaleGizmoLookAndFeel3D.UsesFoldout = true;
|
||||
_gizmoEngine.ScaleGizmoHotkeys.FoldoutLabel = "Hotkeys";
|
||||
_gizmoEngine.ScaleGizmoHotkeys.UsesFoldout = true;
|
||||
_gizmoEngine.ObjectScaleGizmoSettings.FoldoutLabel = "Object settings";
|
||||
_gizmoEngine.ObjectScaleGizmoSettings.UsesFoldout = true;
|
||||
|
||||
_gizmoEngine.UniversalGizmoSettings2D.FoldoutLabel = "2D Mode settings";
|
||||
_gizmoEngine.UniversalGizmoSettings2D.UsesFoldout = true;
|
||||
_gizmoEngine.UniversalGizmoSettings3D.FoldoutLabel = "3D Mode settings";
|
||||
_gizmoEngine.UniversalGizmoSettings3D.UsesFoldout = true;
|
||||
_gizmoEngine.UniversalGizmoLookAndFeel2D.FoldoutLabel = "2D Mode look & feel";
|
||||
_gizmoEngine.UniversalGizmoLookAndFeel2D.UsesFoldout = true;
|
||||
_gizmoEngine.UniversalGizmoLookAndFeel3D.FoldoutLabel = "3D Mode look & feel";
|
||||
_gizmoEngine.UniversalGizmoLookAndFeel3D.UsesFoldout = true;
|
||||
_gizmoEngine.UniversalGizmoHotkeys.FoldoutLabel = "Hotkeys";
|
||||
_gizmoEngine.UniversalGizmoHotkeys.UsesFoldout = true;
|
||||
_gizmoEngine.ObjectUniversalGizmoSettings.FoldoutLabel = "Object settings";
|
||||
_gizmoEngine.ObjectUniversalGizmoSettings.UsesFoldout = true;
|
||||
|
||||
var tab = _gizmoEngine.MainToolbar.GetTabByIndex(_moveGizmoTab);
|
||||
tab.AddTargetSettings(_gizmoEngine.ObjectMoveGizmoSettings);
|
||||
tab.AddTargetSettings(_gizmoEngine.MoveGizmoSettings3D);
|
||||
tab.AddTargetSettings(_gizmoEngine.MoveGizmoSettings2D);
|
||||
tab.AddTargetSettings(_gizmoEngine.MoveGizmoLookAndFeel3D);
|
||||
tab.AddTargetSettings(_gizmoEngine.MoveGizmoLookAndFeel2D);
|
||||
tab.AddTargetSettings(_gizmoEngine.MoveGizmoHotkeys);
|
||||
|
||||
tab = _gizmoEngine.MainToolbar.GetTabByIndex(_rotationGizmoTab);
|
||||
tab.AddTargetSettings(_gizmoEngine.ObjectRotationGizmoSettings);
|
||||
tab.AddTargetSettings(_gizmoEngine.RotationGizmoSettings3D);
|
||||
tab.AddTargetSettings(_gizmoEngine.RotationGizmoLookAndFeel3D);
|
||||
tab.AddTargetSettings(_gizmoEngine.RotationGizmoHotkeys);
|
||||
|
||||
tab = _gizmoEngine.MainToolbar.GetTabByIndex(_scaleGizmoTab);
|
||||
tab.AddTargetSettings(_gizmoEngine.ObjectScaleGizmoSettings);
|
||||
tab.AddTargetSettings(_gizmoEngine.ScaleGizmoSettings3D);
|
||||
tab.AddTargetSettings(_gizmoEngine.ScaleGizmoLookAndFeel3D);
|
||||
tab.AddTargetSettings(_gizmoEngine.ScaleGizmoHotkeys);
|
||||
|
||||
tab = _gizmoEngine.MainToolbar.GetTabByIndex(_universalGizmoTab);
|
||||
tab.AddTargetSettings(_gizmoEngine.UniversalGizmoConfig);
|
||||
tab.AddTargetSettings(_gizmoEngine.ObjectUniversalGizmoSettings);
|
||||
tab.AddTargetSettings(_gizmoEngine.UniversalGizmoSettings2D);
|
||||
tab.AddTargetSettings(_gizmoEngine.UniversalGizmoSettings3D);
|
||||
tab.AddTargetSettings(_gizmoEngine.UniversalGizmoLookAndFeel2D);
|
||||
tab.AddTargetSettings(_gizmoEngine.UniversalGizmoLookAndFeel3D);
|
||||
tab.AddTargetSettings(_gizmoEngine.UniversalGizmoHotkeys);
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Editor/RTG/RTGizmoEngineInspector.cs.meta
Normal file
12
Assets/Editor/RTG/RTGizmoEngineInspector.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f999de9a48aa6a54f84eefdca82133b4
|
||||
timeCreated: 1497955245
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Assets/Editor/RTG/RTSceneGridInspector.cs
Normal file
31
Assets/Editor/RTG/RTSceneGridInspector.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace RTG
|
||||
{
|
||||
[CustomEditor(typeof(RTSceneGrid))]
|
||||
public class RTSceneGridInspector : UnityEditor.Editor
|
||||
{
|
||||
private RTSceneGrid _sceneGrid;
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
_sceneGrid.Settings.UsesFoldout = true;
|
||||
_sceneGrid.Settings.FoldoutLabel = "Settings";
|
||||
_sceneGrid.Settings.RenderEditorGUI(_sceneGrid);
|
||||
|
||||
_sceneGrid.LookAndFeel.UsesFoldout = true;
|
||||
_sceneGrid.LookAndFeel.FoldoutLabel = "Look & feel";
|
||||
_sceneGrid.LookAndFeel.RenderEditorGUI(_sceneGrid);
|
||||
|
||||
_sceneGrid.Hotkeys.UsesFoldout = true;
|
||||
_sceneGrid.Hotkeys.FoldoutLabel = "Hotkeys";
|
||||
_sceneGrid.Hotkeys.RenderEditorGUI(_sceneGrid);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_sceneGrid = target as RTSceneGrid;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Editor/RTG/RTSceneGridInspector.cs.meta
Normal file
12
Assets/Editor/RTG/RTSceneGridInspector.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9185a2da4782544e979c74faaa9c26a
|
||||
timeCreated: 1487523713
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
24
Assets/Editor/RTG/RTSceneInspector.cs
Normal file
24
Assets/Editor/RTG/RTSceneInspector.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace RTG.Editor
|
||||
{
|
||||
[CustomEditor(typeof(RTScene))]
|
||||
public class RTSceneInspector : UnityEditor.Editor
|
||||
{
|
||||
private RTScene _scene;
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
_scene.Settings.RenderEditorGUI(_scene);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_scene = target as RTScene;
|
||||
|
||||
_scene.Settings.FoldoutLabel = "Settings";
|
||||
_scene.Settings.UsesFoldout = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Editor/RTG/RTSceneInspector.cs.meta
Normal file
12
Assets/Editor/RTG/RTSceneInspector.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21557fa42c454dd4182ff06422bcdf01
|
||||
timeCreated: 1496687007
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Editor/TriLibCore.meta
Normal file
8
Assets/Editor/TriLibCore.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e0c0a32eb8819f4cb8869483da839ee
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Editor/TriLibCore/Scripts.meta
Normal file
8
Assets/Editor/TriLibCore/Scripts.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d678ca13b18d6c14da3d0f0f31d422a9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
223
Assets/Editor/TriLibCore/Scripts/AssetLoaderOptionsEditor.cs
Normal file
223
Assets/Editor/TriLibCore/Scripts/AssetLoaderOptionsEditor.cs
Normal file
@@ -0,0 +1,223 @@
|
||||
using TriLibCore.General;
|
||||
using TriLibCore.Mappers;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TriLibCore.Editor
|
||||
{
|
||||
[CustomEditor(typeof(AssetLoaderOptions))]
|
||||
public class AssetLoaderOptionsEditor : UnityEditor.Editor
|
||||
{
|
||||
private int _currentTab;
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
ShowInspectorGUI(serializedObject, ref _currentTab);
|
||||
}
|
||||
|
||||
public static void ShowInspectorGUI(SerializedObject serializedObject, ref int currentTab)
|
||||
{
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Toggle(currentTab == 0, "Model", "LargeButtonLeft"))
|
||||
{
|
||||
currentTab = 0;
|
||||
}
|
||||
if (GUILayout.Toggle(currentTab == 1, "Rig", "LargeButtonMid"))
|
||||
{
|
||||
currentTab = 1;
|
||||
}
|
||||
if (GUILayout.Toggle(currentTab == 2, "Animations", "LargeButtonMid"))
|
||||
{
|
||||
currentTab = 2;
|
||||
}
|
||||
if (GUILayout.Toggle(currentTab == 3, "Materials", "LargeButtonMid"))
|
||||
{
|
||||
currentTab = 3;
|
||||
}
|
||||
if (GUILayout.Toggle(currentTab == 4, "Textures", "LargeButtonMid"))
|
||||
{
|
||||
currentTab = 4;
|
||||
}
|
||||
if (GUILayout.Toggle(currentTab == 5, "Misc.", "LargeButtonRight"))
|
||||
{
|
||||
currentTab = 5;
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.BeginVertical();
|
||||
switch (currentTab)
|
||||
{
|
||||
case 0:
|
||||
GUILayout.Label(new GUIContent("Scene", "Scene import settings"), "BoldLabel");
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("ScaleFactor"), new GUIContent("Scale Factor", "Model scale multiplier."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("UseFileScale"), new GUIContent("Use File Scale", "Turn on this flag to use the file original scale."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("ImportVisibility"), new GUIContent("Import Visibility", "Turn on this field to apply the visibility property to Mesh Renderers/Skinned Mesh Renderers."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("ImportCameras"), new GUIContent("Import Cameras", "Turn on this field to enable Cameras importing."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("ImportLights"), new GUIContent("Import Lights", "Turn on this field to enable Lights importing."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("Static"), new GUIContent("Import as Static", "Turn on this field to import the Model as a static Game Object."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("SortHierarchyByName"), new GUIContent("Sort Hierarchy by Name", "Turn on this field to sort the Model hierarchy by name."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("AddAssetUnloader"), new GUIContent("Add Asset Unloader", "Turn on this field to add the Asset Unloader Component to the loaded Game Object."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("ShowLoadingWarnings"), new GUIContent("Show Loading Warnings", "Turn on this field to display Model loading warnings on the Console."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("CloseStreamAutomatically"), new GUIContent("Close Stream Automatically", "Turn on this field to close the Model loading Stream automatically."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("DestroyOnError"), new GUIContent("Destroy on Error", "Turn on this field to destroy the loaded Game Object automatically when there is any loading error."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("PivotPosition"), new GUIContent("Pivot Position", "Use this field to realign the Model pivot based on the given value."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("DisableObjectsRenaming"), new GUIContent("Disable Objects Renaming", "Turn on this field to disable objects renaming."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("MergeSingleChild"), new GUIContent("Merge Single Child", "Turn on this field to merge single child models into a single GameObject."));
|
||||
|
||||
EditorGUILayout.Space();
|
||||
GUILayout.Label(new GUIContent("Meshes", "Global settings for generated meshes"), "BoldLabel");
|
||||
var importMeshesProperty = serializedObject.FindProperty("ImportMeshes");
|
||||
EditorGUILayout.PropertyField(importMeshesProperty, new GUIContent("Import Meshes", "Turn on this field to import Model Meshes."));
|
||||
if (importMeshesProperty.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("MarkMeshesAsDynamic"), new GUIContent("Mark Meshes as Dynamic", "Turn on this field to mark created meshes as dynamic."));
|
||||
var generateCollidersProperty = serializedObject.FindProperty("GenerateColliders");
|
||||
EditorGUILayout.PropertyField(generateCollidersProperty, new GUIContent("Generate Colliders", "Turn on this field to generate Colliders for imported Meshes."));
|
||||
if (generateCollidersProperty.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("ConvexColliders"), new GUIContent("Convex Colliders", "Turn on this field to generate convex Colliders when the GenerateColliders field is enabled."));
|
||||
}
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("IndexFormat"), new GUIContent("Index Format", "Mesh index format (16 or 32 bits)."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("KeepQuads"), new GUIContent("Keep Quads", "Turn on this field to mantain Mesh quads (Useful for DX11 tesselation)."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("MergeVertices"), new GUIContent("Merge Vertices", "Turn on this field to merge model duplicated vertices where possible."));
|
||||
var importNormalsProperty = serializedObject.FindProperty("ImportNormals");
|
||||
EditorGUILayout.PropertyField(importNormalsProperty, new GUIContent("Import Normals", "Turn on this field to import Mesh normals. If not enabled, normals will be calculated instead."));
|
||||
var generateNormalsProperty = serializedObject.FindProperty("GenerateNormals");
|
||||
if (generateNormalsProperty.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(generateNormalsProperty, new GUIContent("Generate Normals", "Turn off this field to disable Mesh normals generation."));
|
||||
var useUnityNativeNormalCalculatorProperty = serializedObject.FindProperty("UseUnityNativeNormalCalculator");
|
||||
EditorGUILayout.PropertyField(useUnityNativeNormalCalculatorProperty, new GUIContent("Use Unity Native Normal Calculator", "Turn on this field to use the builtin Unity normal calculator."));
|
||||
if (!useUnityNativeNormalCalculatorProperty.boolValue)
|
||||
{
|
||||
EditorGUILayout.Slider(serializedObject.FindProperty("SmoothingAngle"), 0f, 180f, new GUIContent("Smoothing Angle", "Normals calculation smoothing angle."));
|
||||
}
|
||||
}
|
||||
var importBlendShapesProperty = serializedObject.FindProperty("ImportBlendShapes");
|
||||
EditorGUILayout.PropertyField(importBlendShapesProperty, new GUIContent("Import Blend Shapes", "Turn on this field to import Mesh Blend Shapes."));
|
||||
if (importBlendShapesProperty.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("ImportBlendShapeNormals"), new GUIContent("Import Blend Shape Normals", "Turn on this field to import Mesh Blend Shape normals."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("CalculateBlendShapeNormals"), new GUIContent("Calculate Blend Shape Normals", "Turn on this field to calculate Mesh Blend Shape normals when none can be imported."));
|
||||
}
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("ImportColors"), new GUIContent("Import Colors", "Turn on this field to import Mesh Colors."));
|
||||
var importTangentsProperty = serializedObject.FindProperty("ImportTangents");
|
||||
EditorGUILayout.PropertyField(importTangentsProperty, new GUIContent("Import Tangents", "Turn on this field to import Mesh tangents. If not enabled, tangents will be calculated instead."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("GenerateTangents"), new GUIContent("Generate Tangents", "Turn off this field to disable Mesh tangents generation."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("SwapUVs"), new GUIContent("Swap UVs", "Turn on this field to swap Mesh UVs. (uv1 into uv2)"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("LODScreenRelativeTransitionHeightBase"), new GUIContent("LOD Screen Relative Transition Height Base", "Defines the initial screen relative transition height when creating LOD Groups."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("ReadEnabled"), new GUIContent("Read Enabled", "Turn on this field to make mesh CPU data readable."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("DisableTesselation"), new GUIContent("Disable Tesselation", "Turn on this field to disable polygon tesselation."));
|
||||
}
|
||||
var loadPointCloudsProperty = serializedObject.FindProperty("LoadPointClouds");
|
||||
EditorGUILayout.PropertyField(loadPointCloudsProperty, new GUIContent("Load Point Clouds", "TTurn on this field to load the model as a Point Cloud (PLY and OBJ only)"));
|
||||
if (!loadPointCloudsProperty.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("OptimizeMeshes"), new GUIContent("Optimize Meshes", "Turn on this field to optimize imported Meshes for GPU access."));
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
var animationTypeProperty = serializedObject.FindProperty("AnimationType");
|
||||
EditorGUILayout.PropertyField(animationTypeProperty, new GUIContent("Animation Type", "Model rigging type."));
|
||||
var animationType = (AnimationType)animationTypeProperty.intValue;
|
||||
switch (animationType)
|
||||
{
|
||||
case AnimationType.Generic:
|
||||
case AnimationType.Humanoid:
|
||||
|
||||
var avatarDefinitionTypeProperty = serializedObject.FindProperty("AvatarDefinition");
|
||||
EditorGUILayout.PropertyField(avatarDefinitionTypeProperty, new GUIContent("Avatar Definition", "Type of avatar creation for the Model."));
|
||||
var avatarDefinitionType = (AvatarDefinitionType)avatarDefinitionTypeProperty.intValue;
|
||||
switch (avatarDefinitionType)
|
||||
{
|
||||
case AvatarDefinitionType.CreateFromThisModel:
|
||||
if (animationType == AnimationType.Humanoid)
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("HumanDescription"), new GUIContent("Human Description", "Human Description used to create the humanoid Avatar, when the humanoid rigging type is selected."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("SampleBindPose"), new GUIContent("Sample Bind Pose", "Turn on this field to enforce the loaded Model to the bind-pose when rigging."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("EnforceTPose"), new GUIContent("Enforce T-Pose", "Turn on this field to enforce the loaded Model to the t-pose when rigging."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("HumanoidAvatarMapper"), new GUIContent("Humanoid Avatar Mapper", "Mapper used to map the humanoid Avatar, when the humanoid rigging type is selected."));
|
||||
}
|
||||
break;
|
||||
case AvatarDefinitionType.CopyFromOtherAvatar:
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("Avatar"), new GUIContent("Source", "Source Avatar to use when copying from other Avatar."));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case AnimationType.Legacy:
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("AutomaticallyPlayLegacyAnimations"), new GUIContent("Play Legacy Animations Automatically", "Turn on this field to play Legacy Animation Clips automatically (The first available Clip will be played)."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("EnforceAnimatorWithLegacyAnimations"), new GUIContent("Enforce Animator with Legacy Animations", "Turn on this field to add an Animator when the AnimationType is set to Legacy."));
|
||||
break;
|
||||
}
|
||||
if (animationType != AnimationType.None)
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("RootBoneMapper"), new GUIContent("Root Bone Mapper", "Mapper used to find the Model root bone."));
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
animationTypeProperty = serializedObject.FindProperty("AnimationType");
|
||||
animationType = (AnimationType)animationTypeProperty.intValue;
|
||||
//todo: add constraints
|
||||
if (animationType != AnimationType.None)
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("EnsureQuaternionContinuity"), new GUIContent("Ensure Quaternion Continuity", "Turn on this field to realign quaternion keys to ensure shortest interpolation paths."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("ResampleFrequency"), new GUIContent("Resample Frequency", "Defines the FBX Rotation Animation Curve resampling frequency. (1 = every frame, 2 = every 2 frames, 3 = every 3 frames and so on)"));
|
||||
//todo: add keyframe reduction
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("AnimationWrapMode"), new GUIContent("Wrap Mode", "Default wrap-mode to apply to Animations."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("AnimationClipMappers"), new GUIContent("Animation Clip Mappers", "Mappers used to process Animation Clips."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("AddAllBonesToSkinnedMeshRenderers"), new GUIContent("Add all Bones to Skinned Mesh Renderers", "Turn on this field to add all available bones to every created SkinnedMeshRenderer."));
|
||||
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
var importMaterialsProperty = serializedObject.FindProperty("ImportMaterials");
|
||||
EditorGUILayout.PropertyField(importMaterialsProperty, new GUIContent("Import Materials", "Turn on this field to import Materials."));
|
||||
if (importMaterialsProperty.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("UseMaterialKeywords"), new GUIContent("Use Material Keywords", "Turn on this field to enable/disable created Material Keywords based on the source native Materials."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("AlphaMaterialMode"), new GUIContent("Alpha Material Mode", "Chooses the way TriLib creates alpha materials."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("MaterialMappers"), new GUIContent("Material Mappers", "Mappers used to create suitable Unity Materials from original Materials."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("DoubleSidedMaterials"), new GUIContent("Double Sided Materials", "Turn on this field to create double-sided Materials (TriLib does that by duplicating the original Meshes)."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("SetUnusedTexturePropertiesToNull"), new GUIContent("Set unused Texture Properties to Null", "Turn on this field to set the unused Material Texture Properties to null."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("CreateMaterialsForAllModels"), new GUIContent("Create Materials for all Models", "Turn on this field to make TriLib create materials for every loaded model, even models without an original material."));
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
var importTexturesProperty = serializedObject.FindProperty("ImportTextures");
|
||||
EditorGUILayout.PropertyField(importTexturesProperty, new GUIContent("Import Textures", "Turn on this field to import Textures."));
|
||||
if (importTexturesProperty.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("TextureMappers"), new GUIContent("Texture Mappers", "Mappers used to find native Texture Streams from custom sources."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("TextureCompressionQuality"), new GUIContent("Texture Compression Quality", "Texture compression to apply on loaded Textures."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("GenerateMipmaps"), new GUIContent("Generate Mipmaps", "Turn on this field to enable Textures mip-map generation."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("FixNormalMaps"), new GUIContent("Fix Normal Maps", "Turn on this field to change normal map channels order to ABBR instead of RGBA."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("EnforceAlphaChannelTextures"), new GUIContent("Enforce Alpha Channel Textures", "Turn on this field to enforce alpha channel on textures creation."));
|
||||
var alphaMaterialModeProperty = serializedObject.FindProperty("AlphaMaterialMode");
|
||||
if (alphaMaterialModeProperty.enumValueIndex > 0)
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("ScanForAlphaPixels"), new GUIContent("Scan for Alpha Pixels", "Turn on this field to scan Textures for alpha-blended pixels in order to generate transparent Materials."));
|
||||
}
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("LoadTexturesAsSRGB"), new GUIContent("Load Textures as sRGB", "Turn off this field to load textures as linear, instead of sRGB."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("ApplyGammaCurveToMaterialColors"), new GUIContent("Apply Gamma Curve to Material Colors", "When this field is on, TriLib will also apply the gamma curve to the material colors."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("ApplyTexturesOffsetAndScaling"), new GUIContent("Apply Textures Offset and Scaling", "Turn on this field to apply Textures offset and scaling."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("DiscardUnusedTextures"), new GUIContent("Discard Unused Textures", "Turn off this field to keep unused Textures."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("ForcePowerOfTwoTextures"), new GUIContent("Force Power of Two Textures", "Turn on this field to enforce power of two resolution when loading textures (needed for texture compression and in some platforms)."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("UseUnityNativeTextureLoader"), new GUIContent("Use Unity Native Texture Loader", "Turn on this field to use Unity builtin Texture loader instead of stb_image."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("MaxTexturesResolution"), new GUIContent("Max Textures Resolution", "Use this field to limit textures resolution. Textures with resolutions higher than this value (when the value is not zero) will not be loaded."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("ConvertMaterialTexturesUsingHalfRes"), new GUIContent("Convert Material Textures using Half Res", "Turn off this field to generate the \"Metallic/Smoothness/Specular/Roughness\" textures with the full original resolution."));
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("ExternalDataMapper"), new GUIContent("External Data Mapper", "Mapper used to find data Streams on external sources."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("UserPropertiesMapper"), new GUIContent("User Properties Mapper", " Mapper used to process User Properties from Models."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("LipSyncMappers"), new GUIContent("Lip Sync Mappers", "Mappers used to configure Lip-Sync Blend Shapes."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("NameMapper"), new GUIContent("Name Mapper", "This class can be inherited and used to generate Game Object naming based on file-format model specific data."));
|
||||
break;
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e964c5e158b24dc6ad03b0a14c2ef811
|
||||
timeCreated: 1573053965
|
||||
61
Assets/Editor/TriLibCore/Scripts/BuildProcessor.cs
Normal file
61
Assets/Editor/TriLibCore/Scripts/BuildProcessor.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using UnityEngine;
|
||||
using Debug = UnityEngine.Debug;
|
||||
|
||||
namespace TriLibCore.Editor
|
||||
{
|
||||
public class BuildProcessor : IPreprocessBuildWithReport
|
||||
{
|
||||
public int callbackOrder => -1000;
|
||||
|
||||
public void OnPreprocessBuild(BuildReport report)
|
||||
{
|
||||
#if TRILIB_ENABLE_WEBGL_THREADS
|
||||
PlayerSettings.WebGL.threadsSupport = true;
|
||||
#else
|
||||
PlayerSettings.WebGL.threadsSupport = false;
|
||||
#endif
|
||||
#if UNITY_WSA
|
||||
if (!Application.isBatchMode && !PlayerSettings.WSA.GetCapability(PlayerSettings.WSACapability.RemovableStorage) && EditorUtility.DisplayDialog(
|
||||
"TriLib", "TriLib cache system needs the [RemovableStorage] WSA Capacity enabled. Do you want to enable it?", "Yes", "No"))
|
||||
{
|
||||
PlayerSettings.WSA.SetCapability(PlayerSettings.WSACapability.RemovableStorage, true);
|
||||
}
|
||||
#endif
|
||||
var waitingMappers = false;
|
||||
string materialMapper = null;
|
||||
var arguments = Environment.GetCommandLineArgs();
|
||||
for (var i = 0; i < arguments.Length; i++)
|
||||
{
|
||||
var argument = arguments[i];
|
||||
if (waitingMappers)
|
||||
{
|
||||
materialMapper = argument;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (argument)
|
||||
{
|
||||
case "-trilib_mappers":
|
||||
{
|
||||
waitingMappers = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (materialMapper is object)
|
||||
{
|
||||
Debug.Log($"Using the given material mapper:{materialMapper}.");
|
||||
CheckMappers.SelectMapper(materialMapper);
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckMappers.Initialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Editor/TriLibCore/Scripts/BuildProcessor.cs.meta
Normal file
11
Assets/Editor/TriLibCore/Scripts/BuildProcessor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d556beac2d22e38459a0060666d79950
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
76
Assets/Editor/TriLibCore/Scripts/CheckMappers.cs
Normal file
76
Assets/Editor/TriLibCore/Scripts/CheckMappers.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using TriLibCore.Mappers;
|
||||
using TriLibCore.Utils;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TriLibCore.Editor
|
||||
{
|
||||
public static class CheckMappers
|
||||
{
|
||||
[InitializeOnEnterPlayMode]
|
||||
[InitializeOnLoadMethod]
|
||||
public static void Initialize()
|
||||
{
|
||||
var hasAnyMapper = false;
|
||||
for (var i = 0; i < MaterialMapper.RegisteredMappers.Count; i++)
|
||||
{
|
||||
var materialMapperName = MaterialMapper.RegisteredMappers[i];
|
||||
if (TriLibSettings.GetBool(materialMapperName))
|
||||
{
|
||||
hasAnyMapper = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasAnyMapper)
|
||||
{
|
||||
string materialMapper;
|
||||
if (GraphicsSettingsUtils.IsUsingHDRPPipeline)
|
||||
{
|
||||
materialMapper = "HDRPMaterialMapper";
|
||||
}
|
||||
else if (GraphicsSettingsUtils.IsUsingUniversalPipeline)
|
||||
{
|
||||
materialMapper = "UniversalRPMaterialMapper";
|
||||
}
|
||||
else
|
||||
{
|
||||
materialMapper = "StandardMaterialMapper";
|
||||
}
|
||||
Debug.Log($"TriLib is configured to use the '{materialMapper}' Material Mapper. If you want to use different Material Mappers, you can change this setting on the Project Settings/TriLib area.");
|
||||
TriLibSettings.SetBool(materialMapper, true);
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("Tools/TriLib/Select Material Mappers based on Rendering Pipeline")]
|
||||
public static void AutoSelect()
|
||||
{
|
||||
for (var i = 0; i < MaterialMapper.RegisteredMappers.Count; i++)
|
||||
{
|
||||
var materialMapperName = MaterialMapper.RegisteredMappers[i];
|
||||
TriLibSettings.SetBool(materialMapperName, false);
|
||||
}
|
||||
|
||||
string materialMapper;
|
||||
if (GraphicsSettingsUtils.IsUsingHDRPPipeline)
|
||||
{
|
||||
materialMapper = "HDRPMaterialMapper";
|
||||
}
|
||||
else if (GraphicsSettingsUtils.IsUsingUniversalPipeline)
|
||||
{
|
||||
materialMapper = "UniversalRPMaterialMapper";
|
||||
}
|
||||
else
|
||||
{
|
||||
materialMapper = "StandardMaterialMapper";
|
||||
}
|
||||
SelectMapper(materialMapper);
|
||||
}
|
||||
|
||||
public static void SelectMapper(string materialMapper)
|
||||
{
|
||||
Debug.Log($"TriLib is configured to use the '{materialMapper}' Material Mapper. If you want to use different Material Mappers, you can change this setting on the Project Settings/TriLib area.");
|
||||
TriLibSettings.SetBool(materialMapper, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Editor/TriLibCore/Scripts/CheckMappers.cs.meta
Normal file
11
Assets/Editor/TriLibCore/Scripts/CheckMappers.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19aa55894ca34a84db70e98de607f5da
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
Assets/Editor/TriLibCore/Scripts/ImporterOption.cs
Normal file
17
Assets/Editor/TriLibCore/Scripts/ImporterOption.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TriLibCore.Editor
|
||||
{
|
||||
public class ImporterOption : GUIContent
|
||||
{
|
||||
public readonly string Namespace;
|
||||
public readonly PluginImporter PluginImporter;
|
||||
|
||||
public ImporterOption(string name, string @namespace, PluginImporter pluginImporter) : base(name)
|
||||
{
|
||||
Namespace = @namespace;
|
||||
PluginImporter = pluginImporter;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Editor/TriLibCore/Scripts/ImporterOption.cs.meta
Normal file
3
Assets/Editor/TriLibCore/Scripts/ImporterOption.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c201497c49b244e8a7ae0152eb5ad027
|
||||
timeCreated: 1573070165
|
||||
38
Assets/Editor/TriLibCore/Scripts/LipSyncMappingEditor.cs
Normal file
38
Assets/Editor/TriLibCore/Scripts/LipSyncMappingEditor.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using TriLibCore.General;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TriLibCore.Editor
|
||||
{
|
||||
[CustomEditor(typeof(LipSyncMapping))]
|
||||
public class LipSyncMappingEditor : UnityEditor.Editor
|
||||
{
|
||||
private SkinnedMeshRenderer _skinnedMeshRenderer;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_skinnedMeshRenderer = ((LipSyncMapping) target).GetComponent<SkinnedMeshRenderer>();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
_skinnedMeshRenderer = null;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (_skinnedMeshRenderer == null)
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
return;
|
||||
}
|
||||
GUI.enabled = false;
|
||||
var visemeToBlendShapeTargets = serializedObject.FindProperty("VisemeToBlendTargets");
|
||||
for (var i = 0; i < 14; i++)
|
||||
{
|
||||
EditorGUILayout.TextField(((LipSyncViseme) i).ToString(), _skinnedMeshRenderer.sharedMesh.GetBlendShapeName(visemeToBlendShapeTargets.GetArrayElementAtIndex(i).intValue));
|
||||
}
|
||||
GUI.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4660b91c10b46834391a27f679f07187
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
44
Assets/Editor/TriLibCore/Scripts/MapperContextActions.cs
Normal file
44
Assets/Editor/TriLibCore/Scripts/MapperContextActions.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using TriLibCore.Mappers;
|
||||
using TriLibCore.Utils;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TriLibCore.Editor
|
||||
{
|
||||
public class MapperContextActions : MonoBehaviour
|
||||
{
|
||||
[MenuItem("Assets/Create Mapper Instance")]
|
||||
private static void CreateInstance()
|
||||
{
|
||||
var monoScript = Selection.activeObject as MonoScript;
|
||||
if (monoScript != null)
|
||||
{
|
||||
var scriptableObject = ScriptableObject.CreateInstance(monoScript.GetClass());
|
||||
var assetPath = AssetDatabase.GetAssetPath(monoScript);
|
||||
var directory = FileUtils.GetFileDirectory(assetPath);
|
||||
var name = FileUtils.GetFilenameWithoutExtension(assetPath);
|
||||
AssetDatabase.CreateAsset(scriptableObject, $"{directory}/{name}.asset");
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Create Mapper Instance", true)]
|
||||
private static bool Validate()
|
||||
{
|
||||
if (Selection.activeObject is MonoScript monoScript)
|
||||
{
|
||||
var @class = monoScript.GetClass();
|
||||
return
|
||||
typeof(AnimationClipMapper).IsAssignableFrom(@class) ||
|
||||
typeof(MaterialMapper).IsAssignableFrom(@class) ||
|
||||
typeof(TextureMapper).IsAssignableFrom(@class) ||
|
||||
typeof(HumanoidAvatarMapper).IsAssignableFrom(@class) ||
|
||||
typeof(RootBoneMapper).IsAssignableFrom(@class) ||
|
||||
typeof(LipSyncMapper).IsAssignableFrom(@class) ||
|
||||
typeof(UserPropertiesMapper).IsAssignableFrom(@class) ||
|
||||
typeof(ExternalDataMapper).IsAssignableFrom(@class);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 222f79d3cf134a44483e2a2122cec110
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
83
Assets/Editor/TriLibCore/Scripts/PreBuiltResources.cs
Normal file
83
Assets/Editor/TriLibCore/Scripts/PreBuiltResources.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using TriLibCore.General;
|
||||
using TriLibCore.Mappers;
|
||||
using TriLibCore.Utils;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using HumanLimit = TriLibCore.General.HumanLimit;
|
||||
|
||||
namespace TriLibCore.Editor
|
||||
{
|
||||
public class PreBuiltResources : UnityEditor.Editor
|
||||
{
|
||||
|
||||
[MenuItem("Assets/Create/TriLib/Asset Loader Options/Pre-built Asset Loader Options")]
|
||||
public static void CreatePreBuiltAssetLoaderOptions()
|
||||
{
|
||||
var assetLoaderOptions = AssetLoader.CreateDefaultLoaderOptions(false, true);
|
||||
AssetDatabase.CreateAsset(assetLoaderOptions, $"{FileUtils.GetFileDirectory(AssetDatabase.GetAssetPath(Selection.activeObject))}/AssetLoaderOptions.asset");
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Create/TriLib/Mappers/Humanoid/Mixamo and Biped By Name Humanoid Avatar Mapper")]
|
||||
public static void CreateMixamoAndBipedMapper()
|
||||
{
|
||||
var humanLimit = new HumanLimit();
|
||||
var mapper = CreateInstance<ByNameHumanoidAvatarMapper>();
|
||||
mapper.AddMapping(HumanBodyBones.Head, humanLimit, "Head", "Head1");
|
||||
mapper.AddMapping(HumanBodyBones.Neck, humanLimit, "Neck", "Neck1");
|
||||
mapper.AddMapping(HumanBodyBones.Chest, humanLimit, "Spine1");
|
||||
mapper.AddMapping(HumanBodyBones.UpperChest, humanLimit, "Spine4", "Spine3", "Spine2", "Spine1");
|
||||
mapper.AddMapping(HumanBodyBones.Spine, humanLimit, "Spine");
|
||||
mapper.AddMapping(HumanBodyBones.Hips, humanLimit, "Hips", "Bip01", "Pelvis");
|
||||
mapper.AddMapping(HumanBodyBones.LeftShoulder, humanLimit, "LeftShoulder", "L Clavicle", "L_Clavicle");
|
||||
mapper.AddMapping(HumanBodyBones.LeftUpperArm, humanLimit, "LeftArm", "L UpperArm", "L_UpperArm");
|
||||
mapper.AddMapping(HumanBodyBones.LeftLowerArm, humanLimit, "LeftForeArm", "L Forearm", "L_Forearm");
|
||||
mapper.AddMapping(HumanBodyBones.LeftHand, humanLimit, "LeftHand", "L Hand", "L_Hand", "LeftWrist");
|
||||
mapper.AddMapping(HumanBodyBones.RightShoulder, humanLimit, "RightShoulder", "R Clavicle", "R_Clavicle");
|
||||
mapper.AddMapping(HumanBodyBones.RightUpperArm, humanLimit, "RightArm", "R UpperArm", "R_UpperArm");
|
||||
mapper.AddMapping(HumanBodyBones.RightLowerArm, humanLimit, "RightForeArm", "R Forearm", "R_Forearm");
|
||||
mapper.AddMapping(HumanBodyBones.RightHand, humanLimit, "RightHand", "R Hand", "R_Hand", "RightWrist");
|
||||
mapper.AddMapping(HumanBodyBones.LeftUpperLeg, humanLimit, "LeftUpLeg", "L Thigh", "L_Thigh");
|
||||
mapper.AddMapping(HumanBodyBones.LeftLowerLeg, humanLimit, "LeftLeg", "L Calf", "L_Calf");
|
||||
mapper.AddMapping(HumanBodyBones.LeftFoot, humanLimit, "LeftFoot", "L Foot", "L_Foot");
|
||||
mapper.AddMapping(HumanBodyBones.LeftToes, humanLimit, "LeftToeBase", "L Toe0", "L_Toe0");
|
||||
mapper.AddMapping(HumanBodyBones.RightUpperLeg, humanLimit, "RightUpLeg", "R Thigh", "R_Thigh");
|
||||
mapper.AddMapping(HumanBodyBones.RightLowerLeg, humanLimit, "RightLeg", "R Calf", "R_Calf");
|
||||
mapper.AddMapping(HumanBodyBones.RightFoot, humanLimit, "RightFoot", "R Foot", "R_Foot");
|
||||
mapper.AddMapping(HumanBodyBones.RightToes, humanLimit, "RightToeBase", "R Toe0", "R_Toe0");
|
||||
mapper.AddMapping(HumanBodyBones.LeftThumbProximal, humanLimit, "LeftHandThumb1", "L Finger0", "L_Finger0");
|
||||
mapper.AddMapping(HumanBodyBones.LeftThumbIntermediate, humanLimit, "LeftHandThumb2", "L Finger01", "L_Finger01");
|
||||
mapper.AddMapping(HumanBodyBones.LeftThumbDistal, humanLimit, "LeftHandThumb3", "L Finger02", "L_Finger02");
|
||||
mapper.AddMapping(HumanBodyBones.LeftIndexProximal, humanLimit, "LeftHandIndex1", "L Finger1", "L_Finger1");
|
||||
mapper.AddMapping(HumanBodyBones.LeftIndexIntermediate, humanLimit, "LeftHandIndex2", "L Finger11", "L_Finger11");
|
||||
mapper.AddMapping(HumanBodyBones.LeftIndexDistal, humanLimit, "LeftHandIndex3", "L Finger12", "L_Finger12");
|
||||
mapper.AddMapping(HumanBodyBones.LeftMiddleProximal, humanLimit, "LeftHandMiddle1", "L Finger2", "L_Finger2");
|
||||
mapper.AddMapping(HumanBodyBones.LeftMiddleIntermediate, humanLimit, "LeftHandMiddle2", "L Finger21", "L_Finger21");
|
||||
mapper.AddMapping(HumanBodyBones.LeftMiddleDistal, humanLimit, "LeftHandMiddle3", "L Finger22", "L_Finger22");
|
||||
mapper.AddMapping(HumanBodyBones.LeftRingProximal, humanLimit, "LeftHandRing1", "L Finger3", "L_Finger3");
|
||||
mapper.AddMapping(HumanBodyBones.LeftRingIntermediate, humanLimit, "LeftHandRing2", "L Finger31", "L_Finger31");
|
||||
mapper.AddMapping(HumanBodyBones.LeftRingDistal, humanLimit, "LeftHandRing3", "L Finger32", "L_Finger32");
|
||||
mapper.AddMapping(HumanBodyBones.LeftLittleProximal, humanLimit, "LeftHandPinky1", "L Finger4", "L_Finger4");
|
||||
mapper.AddMapping(HumanBodyBones.LeftLittleIntermediate, humanLimit, "LeftHandPinky2", "L Finger41", "L_Finger41");
|
||||
mapper.AddMapping(HumanBodyBones.LeftLittleDistal, humanLimit, "LeftHandPinky3", "L Finger42", "L_Finger42");
|
||||
mapper.AddMapping(HumanBodyBones.RightThumbProximal, humanLimit, "RightHandThumb1", "R Finger0", "R_Finger0");
|
||||
mapper.AddMapping(HumanBodyBones.RightThumbIntermediate, humanLimit, "RightHandThumb2", "R Finger01", "R_Finger01");
|
||||
mapper.AddMapping(HumanBodyBones.RightThumbDistal, humanLimit, "RightHandThumb3", "R Finger02", "R_Finger02");
|
||||
mapper.AddMapping(HumanBodyBones.RightIndexProximal, humanLimit, "RightHandIndex1", "R Finger1", "R_Finger1");
|
||||
mapper.AddMapping(HumanBodyBones.RightIndexIntermediate, humanLimit, "RightHandIndex2", "R Finger11", "R_Finger11");
|
||||
mapper.AddMapping(HumanBodyBones.RightIndexDistal, humanLimit, "RightHandIndex3", "R Finger12", "R_Finger12");
|
||||
mapper.AddMapping(HumanBodyBones.RightMiddleProximal, humanLimit, "RightHandMiddle1", "R Finger2", "R_Finger2");
|
||||
mapper.AddMapping(HumanBodyBones.RightMiddleIntermediate, humanLimit, "RightHandMiddle2", "R Finger21", "R_Finger21");
|
||||
mapper.AddMapping(HumanBodyBones.RightMiddleDistal, humanLimit, "RightHandMiddle3", "R Finger22", "R_Finger22");
|
||||
mapper.AddMapping(HumanBodyBones.RightRingProximal, humanLimit, "RightHandRing1", "R Finger3", "R_Finger3");
|
||||
mapper.AddMapping(HumanBodyBones.RightRingIntermediate, humanLimit, "RightHandRing2", "R Finger31", "R_Finger31");
|
||||
mapper.AddMapping(HumanBodyBones.RightRingDistal, humanLimit, "RightHandRing3", "R Finger32", "R_Finger32");
|
||||
mapper.AddMapping(HumanBodyBones.RightLittleProximal, humanLimit, "RightHandPinky1", "R Finger4", "R_Finger4");
|
||||
mapper.AddMapping(HumanBodyBones.RightLittleIntermediate, humanLimit, "RightHandPinky2", "R Finger41", "R_Finger41");
|
||||
mapper.AddMapping(HumanBodyBones.RightLittleDistal, humanLimit, "RightHandPinky3", "R Finger42", "R_Finger42");
|
||||
mapper.CaseInsensitive = true;
|
||||
mapper.stringComparisonMode = StringComparisonMode.LeftEndsWithRight;
|
||||
AssetDatabase.CreateAsset(mapper, $"{FileUtils.GetFileDirectory(AssetDatabase.GetAssetPath(Selection.activeObject))}/MixamoAndBipedByNameHumanoidAvatarMapper.asset");
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Editor/TriLibCore/Scripts/PreBuiltResources.cs.meta
Normal file
11
Assets/Editor/TriLibCore/Scripts/PreBuiltResources.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26256a5ba4a8395469486a528ea78955
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,27 @@
|
||||
using TriLibCore.Playables;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TriLibCore.Editor
|
||||
{
|
||||
[CustomEditor(typeof(SimpleAnimationPlayer))]
|
||||
public class SimpleAnimationPlayerEditor : UnityEditor.Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
var simpleAnimationPlayer = (SimpleAnimationPlayer) target;
|
||||
if (simpleAnimationPlayer.AnimationClips != null)
|
||||
{
|
||||
for (var i = 0; i < simpleAnimationPlayer.AnimationClips.Count; i++)
|
||||
{
|
||||
var animationClip = simpleAnimationPlayer.AnimationClips[i];
|
||||
if (animationClip != null && GUILayout.Button(animationClip.name))
|
||||
{
|
||||
simpleAnimationPlayer.PlayAnimation(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2d92827e4bc43d68ac3a39cbdee0da3
|
||||
timeCreated: 1589229113
|
||||
@@ -0,0 +1,44 @@
|
||||
#pragma warning disable CS0105
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using Object = UnityEngine.Object;
|
||||
using UnityEditor.AssetImporters;
|
||||
namespace TriLibCore.Editor
|
||||
{
|
||||
#if !TRILIB_DISABLE_EDITOR_3MF_IMPORT
|
||||
[ScriptedImporter(2, new[] { "3mf" })]
|
||||
#endif
|
||||
public class TriLib3MFScriptedImporter : TriLibScriptedImporter
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[CustomEditor(typeof(TriLib3MFScriptedImporter))]
|
||||
public class TriLib3MFImporterEditor : ScriptedImporterEditor
|
||||
{
|
||||
private int _currentTab;
|
||||
|
||||
protected override Type extraDataType => typeof(AssetLoaderOptions);
|
||||
|
||||
protected override void InitializeExtraDataInstance(Object extraData, int targetIndex)
|
||||
{
|
||||
var scriptedImporter = (TriLib3MFScriptedImporter) target;
|
||||
var existingAssetLoaderOptions = scriptedImporter.AssetLoaderOptions;
|
||||
EditorUtility.CopySerializedIfDifferent(existingAssetLoaderOptions, extraData);
|
||||
}
|
||||
|
||||
protected override void Apply()
|
||||
{
|
||||
base.Apply();
|
||||
var assetLoaderOptions = (AssetLoaderOptions) extraDataTarget;
|
||||
var scriptedImporter = (TriLib3MFScriptedImporter) target;
|
||||
scriptedImporter.AssetLoaderOptions = assetLoaderOptions;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
AssetLoaderOptionsEditor.ShowInspectorGUI(extraDataSerializedObject, ref _currentTab);
|
||||
ApplyRevertGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 860acb1e6b6c07e4c927af41c4fe20aa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,60 @@
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
|
||||
namespace TriLibCore.Editor
|
||||
{
|
||||
public static class TriLibDefineSymbolsHelper
|
||||
{
|
||||
public static bool IsSymbolDefined(string targetDefineSymbol)
|
||||
{
|
||||
var targetGroup = NamedBuildTarget.FromBuildTargetGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
|
||||
//var defineSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
|
||||
var defineSymbols = PlayerSettings.GetScriptingDefineSymbols(targetGroup);
|
||||
var defineSymbolsArray = defineSymbols.Split(';');
|
||||
for (var i = 0; i < defineSymbolsArray.Length; i++)
|
||||
{
|
||||
var defineSymbol = defineSymbolsArray[i];
|
||||
var trimmedDefineSymbol = defineSymbol.Trim();
|
||||
if (trimmedDefineSymbol == targetDefineSymbol)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void UpdateSymbol(string targetDefineSymbol, bool value)
|
||||
{
|
||||
var targetGroup = NamedBuildTarget.FromBuildTargetGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
|
||||
var defineSymbols = PlayerSettings.GetScriptingDefineSymbols(targetGroup);
|
||||
//var defineSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
|
||||
var defineSymbolsArray = defineSymbols.Split(';');
|
||||
var newDefineSymbols = string.Empty;
|
||||
var isDefined = false;
|
||||
for (var i = 0; i < defineSymbolsArray.Length; i++)
|
||||
{
|
||||
var defineSymbol = defineSymbolsArray[i];
|
||||
var trimmedDefineSymbol = defineSymbol.Trim();
|
||||
if (trimmedDefineSymbol == targetDefineSymbol)
|
||||
{
|
||||
if (!value)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
isDefined = true;
|
||||
}
|
||||
|
||||
newDefineSymbols += string.Format("{0};", trimmedDefineSymbol);
|
||||
}
|
||||
|
||||
if (value && !isDefined)
|
||||
{
|
||||
newDefineSymbols += string.Format("{0};", targetDefineSymbol);
|
||||
}
|
||||
PlayerSettings.SetScriptingDefineSymbols(targetGroup, newDefineSymbols);
|
||||
//PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, newDefineSymbols);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 125b4cfbcb29baa49830ec7c04854c32
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace TriLibCore.Editor
|
||||
{
|
||||
public static class TriLibDeprecationWarnings
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea65d7911ef789442ada2b330273ae66
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
#pragma warning disable CS0105
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using Object = UnityEngine.Object;
|
||||
using UnityEditor.AssetImporters;
|
||||
namespace TriLibCore.Editor
|
||||
{
|
||||
#if !TRILIB_DISABLE_EDITOR_GLTF_IMPORT
|
||||
[ScriptedImporter(2, new[] { "gltf", "glb"})]
|
||||
#endif
|
||||
public class TriLibGLTFScriptedImporter : TriLibScriptedImporter
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[CustomEditor(typeof(TriLibGLTFScriptedImporter))]
|
||||
public class TriLibGLTFImporterEditor : ScriptedImporterEditor
|
||||
{
|
||||
private int _currentTab;
|
||||
|
||||
protected override Type extraDataType => typeof(AssetLoaderOptions);
|
||||
|
||||
protected override void InitializeExtraDataInstance(Object extraData, int targetIndex)
|
||||
{
|
||||
var scriptedImporter = (TriLibGLTFScriptedImporter) target;
|
||||
var existingAssetLoaderOptions = scriptedImporter.AssetLoaderOptions;
|
||||
EditorUtility.CopySerializedIfDifferent(existingAssetLoaderOptions, extraData);
|
||||
}
|
||||
|
||||
protected override void Apply()
|
||||
{
|
||||
base.Apply();
|
||||
var assetLoaderOptions = (AssetLoaderOptions) extraDataTarget;
|
||||
var scriptedImporter = (TriLibGLTFScriptedImporter) target;
|
||||
scriptedImporter.AssetLoaderOptions = assetLoaderOptions;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
AssetLoaderOptionsEditor.ShowInspectorGUI(extraDataSerializedObject, ref _currentTab);
|
||||
ApplyRevertGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b41132147e7df9498566a67dbd40543
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
#pragma warning disable CS0105
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using Object = UnityEngine.Object;
|
||||
using UnityEditor.AssetImporters;
|
||||
namespace TriLibCore.Editor
|
||||
{
|
||||
#if !TRILIB_DISABLE_EDITOR_PLY_IMPORT
|
||||
[ScriptedImporter(2, new[] { "ply" })]
|
||||
#endif
|
||||
public class TriLibPLYScriptedImporter : TriLibScriptedImporter
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[CustomEditor(typeof(TriLibPLYScriptedImporter))]
|
||||
public class TriLibPLYImporterEditor : ScriptedImporterEditor
|
||||
{
|
||||
private int _currentTab;
|
||||
|
||||
protected override Type extraDataType => typeof(AssetLoaderOptions);
|
||||
|
||||
protected override void InitializeExtraDataInstance(Object extraData, int targetIndex)
|
||||
{
|
||||
var scriptedImporter = (TriLibPLYScriptedImporter) target;
|
||||
var existingAssetLoaderOptions = scriptedImporter.AssetLoaderOptions;
|
||||
EditorUtility.CopySerializedIfDifferent(existingAssetLoaderOptions, extraData);
|
||||
}
|
||||
|
||||
protected override void Apply()
|
||||
{
|
||||
base.Apply();
|
||||
var assetLoaderOptions = (AssetLoaderOptions) extraDataTarget;
|
||||
var scriptedImporter = (TriLibPLYScriptedImporter) target;
|
||||
scriptedImporter.AssetLoaderOptions = assetLoaderOptions;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
AssetLoaderOptionsEditor.ShowInspectorGUI(extraDataSerializedObject, ref _currentTab);
|
||||
ApplyRevertGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 649469c6a3fb99e49a8b3ed0ff48d866
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
#pragma warning disable CS0105
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using Object = UnityEngine.Object;
|
||||
using UnityEditor.AssetImporters;
|
||||
namespace TriLibCore.Editor
|
||||
{
|
||||
#if !TRILIB_DISABLE_EDITOR_STL_IMPORT
|
||||
[ScriptedImporter(2, new[] { "stl" })]
|
||||
#endif
|
||||
public class TriLibSTLScriptedImporter : TriLibScriptedImporter
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[CustomEditor(typeof(TriLibSTLScriptedImporter))]
|
||||
public class TriLibSTLImporterEditor : ScriptedImporterEditor
|
||||
{
|
||||
private int _currentTab;
|
||||
|
||||
protected override Type extraDataType => typeof(AssetLoaderOptions);
|
||||
|
||||
protected override void InitializeExtraDataInstance(Object extraData, int targetIndex)
|
||||
{
|
||||
var scriptedImporter = (TriLibSTLScriptedImporter) target;
|
||||
var existingAssetLoaderOptions = scriptedImporter.AssetLoaderOptions;
|
||||
EditorUtility.CopySerializedIfDifferent(existingAssetLoaderOptions, extraData);
|
||||
}
|
||||
|
||||
protected override void Apply()
|
||||
{
|
||||
base.Apply();
|
||||
var assetLoaderOptions = (AssetLoaderOptions) extraDataTarget;
|
||||
var scriptedImporter = (TriLibSTLScriptedImporter) target;
|
||||
scriptedImporter.AssetLoaderOptions = assetLoaderOptions;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
AssetLoaderOptionsEditor.ShowInspectorGUI(extraDataSerializedObject, ref _currentTab);
|
||||
ApplyRevertGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3053bb072954bb644a4a34101e211a63
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
63
Assets/Editor/TriLibCore/Scripts/TriLibScriptedImporter.cs
Normal file
63
Assets/Editor/TriLibCore/Scripts/TriLibScriptedImporter.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
#pragma warning disable CS0105
|
||||
using UnityEngine;
|
||||
using TriLibCore.Interfaces;
|
||||
using UnityEditor;
|
||||
using TriLibCore.Utils;
|
||||
using UnityEditor.AssetImporters;
|
||||
namespace TriLibCore.Editor
|
||||
{
|
||||
public class TriLibScriptedImporter : ScriptedImporter
|
||||
{
|
||||
public AssetLoaderOptions AssetLoaderOptions
|
||||
{
|
||||
get
|
||||
{
|
||||
var assetLoaderOptions = AssetLoader.CreateDefaultLoaderOptions(true, true);
|
||||
if (userData != null && userData != "null")
|
||||
{
|
||||
EditorJsonUtility.FromJsonOverwrite(userData, assetLoaderOptions);
|
||||
}
|
||||
//Editor coroutines are not allowed
|
||||
assetLoaderOptions.UseCoroutines = false;
|
||||
return assetLoaderOptions;
|
||||
}
|
||||
set => userData = EditorJsonUtility.ToJson(value);
|
||||
}
|
||||
|
||||
public override void OnImportAsset(AssetImportContext assetImportContext)
|
||||
{
|
||||
var assetLoaderOptions = AssetLoaderOptions;
|
||||
assetLoaderOptions.Timeout = EditorPrefs.GetInt("TriLibTimeout", 180);
|
||||
var assetLoaderContext = AssetLoader.LoadModelFromFileNoThread(assetImportContext.assetPath, OnError, null, assetLoaderOptions, CustomDataHelper.CreateCustomDataDictionaryWithData(assetImportContext));
|
||||
if (assetLoaderContext.RootGameObject != null)
|
||||
{
|
||||
assetImportContext.AddObjectToAsset("Main", assetLoaderContext.RootGameObject);
|
||||
assetImportContext.SetMainObject(assetLoaderContext.RootGameObject);
|
||||
for (var i = 0; i < assetLoaderContext.Allocations.Count; i++)
|
||||
{
|
||||
var allocation = assetLoaderContext.Allocations[i];
|
||||
if (string.IsNullOrWhiteSpace(allocation.name))
|
||||
{
|
||||
allocation.name = allocation.GetType().Name;
|
||||
}
|
||||
assetImportContext.AddObjectToAsset(allocation.name, allocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnError(IContextualizedError contextualizedError)
|
||||
{
|
||||
var exception = contextualizedError.GetInnerException();
|
||||
if (contextualizedError.GetContext() is IAssetLoaderContext assetLoaderContext)
|
||||
{
|
||||
var assetImportContext = CustomDataHelper.GetCustomData<AssetImportContext>(assetLoaderContext.Context.CustomData);
|
||||
if (assetImportContext != null)
|
||||
{
|
||||
assetImportContext.LogImportError(exception.ToString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
Debug.LogError(exception.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6baa15879b9982542854c3ca3522da19
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
132
Assets/Editor/TriLibCore/Scripts/TriLibSettingsProvider.cs
Normal file
132
Assets/Editor/TriLibCore/Scripts/TriLibSettingsProvider.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TriLibCore.Mappers;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TriLibCore.Editor
|
||||
{
|
||||
public class TriLibSettingsProvider : SettingsProvider
|
||||
{
|
||||
private class Styles
|
||||
{
|
||||
public static readonly GUIStyle Group = new GUIStyle { padding = new RectOffset(10, 10, 5, 5) };
|
||||
}
|
||||
|
||||
private static string _settingsFilePath;
|
||||
|
||||
public TriLibSettingsProvider(string path, SettingsScope scopes = SettingsScope.User, IEnumerable<string> keywords = null) : base(path, scopes, keywords)
|
||||
{
|
||||
var settingsAssetGuids = AssetDatabase.FindAssets("TriLibReaders");
|
||||
if (settingsAssetGuids.Length > 0)
|
||||
{
|
||||
_settingsFilePath = AssetDatabase.GUIDToAssetPath(settingsAssetGuids[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Could not find TriLibReaders.cs file. Please re-import TriLib package.");
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnGUI(string searchContext)
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
var contentWidth = GUILayoutUtility.GetLastRect().width * 0.5f;
|
||||
EditorGUIUtility.labelWidth = contentWidth;
|
||||
EditorGUIUtility.fieldWidth = contentWidth;
|
||||
GUILayout.BeginVertical(Styles.Group);
|
||||
GUILayout.Label("Runtime Importing", EditorStyles.boldLabel);
|
||||
GUILayout.Label("You can disable runtime file-formats importing here");
|
||||
EditorGUILayout.Space();
|
||||
ShowConditionalToggle("Disable runtime FBX importing", "TRILIB_DISABLE_FBX_IMPORT");
|
||||
ShowConditionalToggle("Disable runtime gLTF2 importing", "TRILIB_DISABLE_GLTF_IMPORT");
|
||||
ShowConditionalToggle("Disable runtime OBJ importing", "TRILIB_DISABLE_OBJ_IMPORT");
|
||||
ShowConditionalToggle("Disable runtime STL importing", "TRILIB_DISABLE_STL_IMPORT");
|
||||
ShowConditionalToggle("Disable runtime PLY importing", "TRILIB_DISABLE_PLY_IMPORT");
|
||||
ShowConditionalToggle("Disable runtime 3MF importing", "TRILIB_DISABLE_3MF_IMPORT");
|
||||
ShowConditionalToggle("Disable runtime DAE importing", "TRILIB_DISABLE_DAE_IMPORT");
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.Space();
|
||||
GUILayout.Label("Editor Importing", EditorStyles.boldLabel);
|
||||
EditorPrefs.SetInt("TriLibTimeout", EditorGUILayout.IntField("Loading timeout", EditorPrefs.GetInt("TriLibTimeout", 180)));
|
||||
GUILayout.Label("You can disable in editor file-formats importing to avoid conflicts with other editor importers");
|
||||
EditorGUILayout.Space();
|
||||
ShowConditionalToggle("Disable in editor gLTF2 importing", "TRILIB_DISABLE_EDITOR_GLTF_IMPORT");
|
||||
ShowConditionalToggle("Disable in editor PLY importing", "TRILIB_DISABLE_EDITOR_PLY_IMPORT");
|
||||
ShowConditionalToggle("Disable in editor 3MF importing", "TRILIB_DISABLE_EDITOR_3MF_IMPORT");
|
||||
ShowConditionalToggle("Disable in editor STL importing", "TRILIB_DISABLE_EDITOR_STL_IMPORT");
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.Space();
|
||||
GUILayout.Label("Material Mappers", EditorStyles.boldLabel);
|
||||
GUILayout.Label("Select the material mappers according to your project rendering pipeline");
|
||||
EditorGUILayout.Space();
|
||||
for (var i = 0; i < MaterialMapper.RegisteredMappers.Count; i++)
|
||||
{
|
||||
var materialMapperName = MaterialMapper.RegisteredMappers[i];
|
||||
var value = TriLibSettings.GetBool(materialMapperName);
|
||||
var newValue = EditorGUILayout.Toggle(materialMapperName, value);
|
||||
if (newValue != value)
|
||||
{
|
||||
TriLibSettings.SetBool(materialMapperName, newValue);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.Space();
|
||||
GUILayout.Label("Misc Options", EditorStyles.boldLabel);
|
||||
GUILayout.Label("Advanced and experimental options");
|
||||
EditorGUILayout.Space();
|
||||
//todo: fbx sdk will be included in a future update
|
||||
//ShowConditionalToggle("Use FBX SDK (Experimental)", "TRILIB_USE_FBXSDK");
|
||||
ShowConditionalToggle("Enable UWP threaded loading (Experimental)", "TRILIB_ENABLE_UWP_THREADS");
|
||||
ShowConditionalToggle("Enable gLTF2 Draco decompression (Experimental)", "TRILIB_DRACO");
|
||||
ShowConditionalToggle("Force synchronous loading", "TRILIB_FORCE_SYNC");
|
||||
ShowConditionalToggle("Change thread names (Debug purposes only)", "TRILIB_USE_THREAD_NAMES");
|
||||
ShowConditionalToggle("Disable asset loader options validations", "TRILIB_DISABLE_VALIDATIONS");
|
||||
ShowConditionalToggle("Show advanced memory usage (Windows only)", "TRILIB_SHOW_MEMORY_USAGE");
|
||||
EditorGUILayout.Space();
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.FlexibleSpace();
|
||||
if (GUILayout.Button("Version Notes"))
|
||||
{
|
||||
TriLibVersionNotes.ShowWindow();
|
||||
}
|
||||
if (GUILayout.Button("API Reference"))
|
||||
{
|
||||
Application.OpenURL("https://ricardoreis.net/trilib/trilib2/docs/");
|
||||
}
|
||||
if (GUILayout.Button("Wiki"))
|
||||
{
|
||||
Application.OpenURL("https://ricardoreis.net/trilibwiki/index.php");
|
||||
}
|
||||
if (GUILayout.Button("Support"))
|
||||
{
|
||||
Application.OpenURL("https://ricardoreis.net/contact/");
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.EndVertical();
|
||||
CheckMappers.Initialize();
|
||||
base.OnGUI(searchContext);
|
||||
}
|
||||
|
||||
private void ShowConditionalToggle(string label, string symbol, Action<bool> onChange = null)
|
||||
{
|
||||
var currentValue = TriLibDefineSymbolsHelper.IsSymbolDefined(symbol);
|
||||
var newValue = EditorGUILayout.Toggle(label, currentValue);
|
||||
if (newValue != currentValue)
|
||||
{
|
||||
TriLibDefineSymbolsHelper.UpdateSymbol(symbol, newValue);
|
||||
onChange?.Invoke(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
[SettingsProvider]
|
||||
public static SettingsProvider TriLib()
|
||||
{
|
||||
var provider = new TriLibSettingsProvider("Project/TriLib", SettingsScope.Project)
|
||||
{
|
||||
keywords = GetSearchKeywordsFromGUIContentProperties<Styles>()
|
||||
};
|
||||
return provider;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5b653e1047e419fb6dc0d9b9d4d2c46
|
||||
timeCreated: 1573055735
|
||||
23
Assets/Editor/TriLibCore/Scripts/TriLibSplashScreen.cs
Normal file
23
Assets/Editor/TriLibCore/Scripts/TriLibSplashScreen.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TriLibCore.Editor
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public class TriLibSplashScreen
|
||||
{
|
||||
static TriLibSplashScreen()
|
||||
{
|
||||
EditorApplication.update += Update;
|
||||
}
|
||||
|
||||
private static void Update()
|
||||
{
|
||||
EditorApplication.update -= Update;
|
||||
if (!EditorApplication.isPlayingOrWillChangePlaymode && !EditorPrefs.GetBool(TriLibVersionInfo.Instance.SkipVersionInfoKey))
|
||||
{
|
||||
TriLibVersionNotes.ShowWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Editor/TriLibCore/Scripts/TriLibSplashScreen.cs.meta
Normal file
11
Assets/Editor/TriLibCore/Scripts/TriLibSplashScreen.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11d5e1e8c2814ec46b6dac8c8c4b69bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
34
Assets/Editor/TriLibCore/Scripts/TriLibVersionInfo.cs
Normal file
34
Assets/Editor/TriLibCore/Scripts/TriLibVersionInfo.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
namespace TriLibCore.Editor
|
||||
{
|
||||
public class TriLibVersionInfo
|
||||
{
|
||||
private static TriLibVersionInfo _instance;
|
||||
|
||||
public string CurrentVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
var assembly = System.Reflection.Assembly.GetAssembly(typeof(TriLibCore.ReaderBase));
|
||||
var fileVersionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
|
||||
return fileVersionInfo.ProductVersion;
|
||||
}
|
||||
}
|
||||
|
||||
public string SkipVersionInfoKey
|
||||
{
|
||||
get { return $"TriLibSkipVersionInfo{CurrentVersion}"; }
|
||||
}
|
||||
|
||||
public static TriLibVersionInfo Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new TriLibVersionInfo();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Editor/TriLibCore/Scripts/TriLibVersionInfo.cs.meta
Normal file
11
Assets/Editor/TriLibCore/Scripts/TriLibVersionInfo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd2438f4fdd2cdb42b08cd9116118e21
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
132
Assets/Editor/TriLibCore/Scripts/TriLibVersionNotes.cs
Normal file
132
Assets/Editor/TriLibCore/Scripts/TriLibVersionNotes.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TriLibCore.Editor
|
||||
{
|
||||
public class TriLibVersionNotes : EditorWindow
|
||||
{
|
||||
private class Styles
|
||||
{
|
||||
public const float WindowWidth = 0.75f;
|
||||
public const float WindowHeight = 0.5f;
|
||||
public static readonly GUIStyle HeaderStyle = new GUIStyle("label") { fontSize = 19, fontStyle = FontStyle.Bold, margin = new RectOffset(10, 10, 5, 5) };
|
||||
public static readonly GUIStyle SubHeaderStyle = new GUIStyle("label") { margin = new RectOffset(10, 10, 5, 5), fontStyle = FontStyle.Bold };
|
||||
public static readonly GUIStyle TextStyle = new GUIStyle("label") { margin = new RectOffset(20, 20, 5, 5) };
|
||||
public static readonly GUIStyle TextAreaStyle = new GUIStyle(TextStyle) { wordWrap = true };
|
||||
public static readonly GUIStyle ButtonStyle = new GUIStyle("button") { margin = new RectOffset(10, 10, 5, 5) };
|
||||
}
|
||||
|
||||
private string _text;
|
||||
private bool _loaded;
|
||||
private Vector2 _changeLogScrollPosition;
|
||||
private Vector2 _notesScrollPosition;
|
||||
|
||||
private static TriLibVersionNotes Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
var window = GetWindow<TriLibVersionNotes>();
|
||||
window.titleContent = new GUIContent("TriLib Version Notes");
|
||||
window.minSize = new Vector2(Styles.WindowWidth * Screen.width, Styles.WindowHeight * Screen.height);
|
||||
return window;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void ShowWindow()
|
||||
{
|
||||
Instance.Show();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
EditorPrefs.SetBool(TriLibVersionInfo.Instance.SkipVersionInfoKey, true);
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
if (!_loaded)
|
||||
{
|
||||
var guids = AssetDatabase.FindAssets("TriLibReleaseNotes");
|
||||
if (guids.Length > 0)
|
||||
{
|
||||
var guid = guids[0];
|
||||
var assetPath = AssetDatabase.GUIDToAssetPath(guid);
|
||||
var textAsset = AssetDatabase.LoadAssetAtPath<TextAsset>(assetPath);
|
||||
if (textAsset == null || textAsset.text == null)
|
||||
{
|
||||
AssetDatabase.Refresh();
|
||||
textAsset = AssetDatabase.LoadAssetAtPath<TextAsset>(assetPath);
|
||||
if (textAsset == null)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
return;
|
||||
}
|
||||
_text = textAsset.text.Replace("\\n", "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
Close();
|
||||
}
|
||||
_loaded = true;
|
||||
}
|
||||
EditorGUILayout.BeginVertical();
|
||||
using (var stringReader = new StringReader(_text))
|
||||
{
|
||||
var changeLogOpen = false;
|
||||
var version = stringReader.ReadLine();
|
||||
GUILayout.Label($"TriLib {version}", Styles.HeaderStyle);
|
||||
for (; ; )
|
||||
{
|
||||
var line = stringReader.ReadLine();
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (line.ToLowerInvariant() == "changelog:")
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
GUILayout.Label("Changelog", Styles.SubHeaderStyle);
|
||||
_changeLogScrollPosition = GUILayout.BeginScrollView(_changeLogScrollPosition, GUILayout.Height(260f));
|
||||
changeLogOpen = true;
|
||||
}
|
||||
else if (line.ToLowerInvariant() == "version notes:")
|
||||
{
|
||||
if (changeLogOpen)
|
||||
{
|
||||
GUILayout.EndScrollView();
|
||||
changeLogOpen = false;
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
GUILayout.Label("Version Notes", Styles.SubHeaderStyle);
|
||||
var versionInfo = stringReader.ReadToEnd();
|
||||
_notesScrollPosition = EditorGUILayout.BeginScrollView(_notesScrollPosition);
|
||||
EditorGUILayout.TextArea(versionInfo, Styles.TextAreaStyle);
|
||||
EditorGUILayout.EndScrollView();
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
GUILayout.Label(line, Styles.TextStyle);
|
||||
}
|
||||
}
|
||||
if (changeLogOpen)
|
||||
{
|
||||
GUILayout.EndScrollView();
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.Space();
|
||||
GUILayout.Label("You can show this window on the Project Settings/TriLib area", Styles.SubHeaderStyle);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.FlexibleSpace();
|
||||
if (GUILayout.Button("Close", Styles.ButtonStyle))
|
||||
{
|
||||
Close();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Editor/TriLibCore/Scripts/TriLibVersionNotes.cs.meta
Normal file
11
Assets/Editor/TriLibCore/Scripts/TriLibVersionNotes.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 538a5acbe6221b048b5cacdbd452cffd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Editor/WI.meta
Normal file
8
Assets/Editor/WI.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46afb1091162af045b2f6f3695b65303
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
15
Assets/Editor/WI/CustomAssetAttribute.cs
Normal file
15
Assets/Editor/WI/CustomAssetAttribute.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
|
||||
public class CustomAssetAttribute : Attribute
|
||||
{
|
||||
public string[] extensions;
|
||||
public CustomAssetAttribute(params string[] extensions)
|
||||
{
|
||||
this.extensions = extensions;
|
||||
}
|
||||
}
|
||||
11
Assets/Editor/WI/CustomAssetAttribute.cs.meta
Normal file
11
Assets/Editor/WI/CustomAssetAttribute.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cdf97140a49833e42adddf3380bfbc7f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
81
Assets/Editor/WI/DefalutAssetInspector.cs
Normal file
81
Assets/Editor/WI/DefalutAssetInspector.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor(typeof(DefaultAsset))]
|
||||
public class DefaultAssetInspector : Editor
|
||||
{
|
||||
private Editor editor;
|
||||
private static Type[] customAssetTypes;
|
||||
|
||||
/// <summary>
|
||||
/// 확장자에 따른 CustomAsset 속성이 붙은 클래스를 얻어옵니다
|
||||
/// </summary>
|
||||
/// <param name="extension">확장자(예시: .zip)</param>
|
||||
private Type GetCustomAssetEditorType(string extension)
|
||||
{
|
||||
switch (extension)
|
||||
{
|
||||
case ".ini":
|
||||
return typeof(INIEditor);
|
||||
default:
|
||||
return typeof(DefaultAsset);
|
||||
}
|
||||
}
|
||||
|
||||
string data;
|
||||
private void OnEnable()
|
||||
{
|
||||
var assetPath = AssetDatabase.GetAssetPath(target);
|
||||
var extension = Path.GetExtension(assetPath);
|
||||
var customAssetEditorType = GetCustomAssetEditorType(extension);
|
||||
if (customAssetEditorType == typeof(DefaultAsset))
|
||||
return;
|
||||
editor = CreateEditor(target, customAssetEditorType);
|
||||
if(editor!=null)
|
||||
{
|
||||
data = File.ReadAllText(assetPath);
|
||||
switch(editor)
|
||||
{
|
||||
case INIEditor ie:
|
||||
ie.data = data;
|
||||
ie.assetPath = assetPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (editor != null)
|
||||
{
|
||||
GUI.enabled = true;
|
||||
editor.OnInspectorGUI();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HasPreviewGUI()
|
||||
{
|
||||
return editor != null ? editor.HasPreviewGUI() : base.HasPreviewGUI();
|
||||
}
|
||||
|
||||
public override void OnPreviewGUI(Rect r, GUIStyle background)
|
||||
{
|
||||
if (editor != null)
|
||||
editor.OnPreviewGUI(r, background);
|
||||
}
|
||||
|
||||
public override void OnPreviewSettings()
|
||||
{
|
||||
if (editor != null)
|
||||
editor.OnPreviewSettings();
|
||||
}
|
||||
|
||||
public override string GetInfoString()
|
||||
{
|
||||
return editor != null ? editor.GetInfoString() : base.GetInfoString();
|
||||
}
|
||||
|
||||
//아래로는 임의로 다루고 싶은 Editor 클래스의 확장을 실행합니다
|
||||
}
|
||||
11
Assets/Editor/WI/DefalutAssetInspector.cs.meta
Normal file
11
Assets/Editor/WI/DefalutAssetInspector.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b52e169a05dee9c46970a5722ecff5b7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
88
Assets/Editor/WI/FontChanger.cs
Normal file
88
Assets/Editor/WI/FontChanger.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace XED.UI
|
||||
{
|
||||
public class FontChanger : MonoBehaviour
|
||||
{
|
||||
private const string FONTPATH = "Assets/Font/Pretendard-Regular SDF.asset";
|
||||
private static string[] folderPath = { "Assets/Prefabs",
|
||||
"Assets/Resources/Prefabs"};
|
||||
|
||||
[MenuItem("Tools/Change Font/Hierarchy")]
|
||||
public static void ChangeFont_Hierarchy()
|
||||
{
|
||||
GameObject[] rootObj = SceneManager.GetActiveScene().GetRootGameObjects();
|
||||
|
||||
for (int i = 0; i < rootObj.Length; i++)
|
||||
{
|
||||
SetFont(rootObj[i]);
|
||||
}
|
||||
|
||||
Debug.Log("Font changed successfully");
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Change Font/Prject")]
|
||||
public static void ChangeFont_Prject()
|
||||
{
|
||||
string[] allPrefabs = AssetDatabase.FindAssets("t:Prefab");
|
||||
|
||||
foreach (string guid in allPrefabs)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
|
||||
if (IsPathAllowed(path) == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(path);
|
||||
|
||||
if (prefab != null)
|
||||
{
|
||||
int missingCount = GameObjectUtility.GetMonoBehavioursWithMissingScriptCount(prefab);
|
||||
|
||||
// ´©¶ô ½ºÅ©¸³Æ® Á¦°Å
|
||||
if(missingCount > 0)
|
||||
GameObjectUtility.RemoveMonoBehavioursWithMissingScript(prefab);
|
||||
|
||||
SetFont(prefab);
|
||||
|
||||
PrefabUtility.SavePrefabAsset(prefab);
|
||||
EditorUtility.SetDirty(prefab);
|
||||
}
|
||||
}
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
Debug.Log("Font changed successfully");
|
||||
}
|
||||
|
||||
private static void SetFont(GameObject obj)
|
||||
{
|
||||
Component[] componts = obj.transform.GetComponentsInChildren(typeof(TextMeshProUGUI), true);
|
||||
|
||||
foreach (TextMeshProUGUI text in componts)
|
||||
{
|
||||
text.font = AssetDatabase.LoadAssetAtPath<TMP_FontAsset>(FONTPATH);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsPathAllowed(string path)
|
||||
{
|
||||
foreach (string folder in folderPath)
|
||||
{
|
||||
if (path.StartsWith(folder))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Editor/WI/FontChanger.cs.meta
Normal file
11
Assets/Editor/WI/FontChanger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07eae5158785f27468419c052dbdfe31
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
29
Assets/Editor/WI/INIEditor.cs
Normal file
29
Assets/Editor/WI/INIEditor.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using WI;
|
||||
using XED;
|
||||
|
||||
[CustomAsset(".ini")]
|
||||
|
||||
public class INIEditor : Editor
|
||||
{
|
||||
public string data;
|
||||
public string assetPath;
|
||||
static int prevHash;
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
data = EditorGUILayout.TextArea(data);
|
||||
int hash = data.GetHashCode();
|
||||
if (hash != prevHash)
|
||||
{
|
||||
File.WriteAllText(assetPath, data);
|
||||
prevHash = hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Editor/WI/INIEditor.cs.meta
Normal file
11
Assets/Editor/WI/INIEditor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37aedf2a3e35cd04cb4a8a70235bfc30
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
83
Assets/Editor/WI/PanelBaseEditor.cs
Normal file
83
Assets/Editor/WI/PanelBaseEditor.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using TMPro;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using WI;
|
||||
using WI.UI;
|
||||
|
||||
[CustomEditor(typeof(PanelBase), true)]
|
||||
public class PanelBaseEditor : Editor
|
||||
{
|
||||
PanelBase pb;
|
||||
|
||||
//1. pb transform의 child Button 목록 cbList 가져오기
|
||||
//2. cbList를 순회하며 반복
|
||||
//2-1. childButton 의 gameObject.name string 을 '_' 문자로 Split
|
||||
//2-2. Split된 문자열 배열에서 가장 마지막 배열의 문자열인 cbName 가져오기
|
||||
//2-3. cbName을 childButton 하위의 TextMeshProUGUI의 텍스트로 삽입
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
//base.OnInspectorGUI();
|
||||
pb = target as PanelBase;
|
||||
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
if (GUILayout.Button("Button Naming"))
|
||||
{
|
||||
ButtonNaming();
|
||||
}
|
||||
|
||||
if(GUILayout.Button("Text Titleling"))
|
||||
{
|
||||
TextTitleling();
|
||||
}
|
||||
}
|
||||
|
||||
void TextTitleling()
|
||||
{
|
||||
//1. pb transform의 child Text 목록 가져오기
|
||||
TextMeshProUGUI[] textList = pb.transform.GetComponentsInChildren<TextMeshProUGUI>();
|
||||
|
||||
//2. child Text의 gameObject.name 을 '_'로 Split
|
||||
foreach (var text in textList)
|
||||
{
|
||||
string[] nameSplit = text.gameObject.name.Split('_');
|
||||
|
||||
//3. Split된 문자열 배열에서 첫번째 배열의 값이 "Title" 일 경우
|
||||
if (nameSplit[0] == "Title")
|
||||
{
|
||||
//4. 해당 childText에 Split된 문자열 배열의 두번째 배열값 입력
|
||||
text.text = nameSplit[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ButtonNaming()
|
||||
{
|
||||
//1. pb transform의 child Button 목록 cbList 가져오기
|
||||
Button[] cbList = pb.transform.GetComponentsInChildren<Button>();
|
||||
|
||||
//2. cbList를 순회하며 반복
|
||||
foreach (var cb in cbList)
|
||||
{
|
||||
//2-1. childButton 의 gameObject.name string 을 '_' 문자로 Split
|
||||
string[] nameSplit = cb.gameObject.name.Split('_');
|
||||
|
||||
//2-2. Split된 문자열 배열에서 가장 마지막 배열의 문자열인 cbName 가져오기
|
||||
string cbName = nameSplit[nameSplit.Length - 1];
|
||||
|
||||
//2-3. cbName을 childButton 하위의 TextMeshProUGUI의 텍스트로 삽입
|
||||
TextMeshProUGUI text = cb.GetComponentInChildren<TextMeshProUGUI>();
|
||||
if (text != null)
|
||||
{
|
||||
text.text = cbName;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Editor/WI/PanelBaseEditor.cs.meta
Normal file
11
Assets/Editor/WI/PanelBaseEditor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5f60cd4fbc6ab14589c91839db57ab5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
273
Assets/Editor/WI/TwinObjectPreprocessingHelper.cs
Normal file
273
Assets/Editor/WI/TwinObjectPreprocessingHelper.cs
Normal file
@@ -0,0 +1,273 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using WI;
|
||||
using WI.Util;
|
||||
using System.Threading.Tasks;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor.AddressableAssets.Settings;
|
||||
using UnityEditor.AddressableAssets;
|
||||
#endif
|
||||
|
||||
namespace XED
|
||||
{
|
||||
public class TwinObjectPreprocessingHelper
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
static List<TwinContainer> twinContainerList = new();
|
||||
|
||||
[MenuItem("Tools/TwinObjectsSetting")]
|
||||
public static void TwinObjectsSetting()
|
||||
{
|
||||
AutomateTwinObjectSetup();
|
||||
}
|
||||
|
||||
//존재하지 않은 폴더의 경우 해당 폴더를 생성해주는 메서드
|
||||
static void CreateFolder(string folderPath)
|
||||
{
|
||||
if (Directory.Exists(folderPath))
|
||||
return;
|
||||
|
||||
Directory.CreateDirectory(folderPath);
|
||||
}
|
||||
|
||||
//TODO : 경로를 하드코딩 하는 방식 이외의 다른 방식 활용, Prefab 의 이름 파싱을 이용한 방식 활용(PRF_Robot01_Robot)
|
||||
static void AutomateTwinObjectSetup()
|
||||
{
|
||||
var mainPath = "Assets/Models/";
|
||||
var beforePath = string.Concat(mainPath, "TwinObject_BeforeProcessing");
|
||||
var afterPath = string.Concat(mainPath, "TwinObject_AfterProcessing/");
|
||||
string etcPath = string.Concat(mainPath, "$etc");
|
||||
|
||||
CreateFolder(etcPath);
|
||||
|
||||
CreateAddressableAssets(beforePath, etcPath, afterPath);
|
||||
|
||||
TwinContainerAddressableSetting(twinContainerList);
|
||||
}
|
||||
static void CreateAddressableAssets(string beforePath, string etcPath, string afterPath)
|
||||
{
|
||||
//beforPath 폴더 안의 타입이 프리팹인 Asset의 guid를 모두 찾습니다.
|
||||
string[] guids = AssetDatabase.FindAssets("t:Prefab", new string[] { beforePath });
|
||||
|
||||
foreach (var guid in guids)
|
||||
{
|
||||
//guid 에 해당하는 Asset 의 경로를 찾습니다.
|
||||
string filePath = AssetDatabase.GUIDToAssetPath(guid);
|
||||
|
||||
if (filePath.StartsWith(etcPath))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//경로에 해당하는 Asset 을 찾습니다.
|
||||
var loadAsset = AssetDatabase.LoadAssetAtPath<GameObject>(filePath);
|
||||
var twinObject = loadAsset.GetComponent<TwinObject>();
|
||||
|
||||
string fileName = Path.GetFileName(filePath);
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath);
|
||||
string folderPath = string.Concat(afterPath, fileNameWithoutExtension);
|
||||
string fullPath = string.Concat(folderPath, "/", fileName);
|
||||
|
||||
//전처리 완료 폴더를 생성합니다.
|
||||
CreateFolder(folderPath);
|
||||
|
||||
//TwinContainer 를 생성합니다.
|
||||
var twinContainer = CreateTwinContainer(folderPath, twinObject);
|
||||
|
||||
//TwinObject 미리보기 이미지를 생성합니다.
|
||||
var texture = CreateTwinObjectPortrait(folderPath, twinObject);
|
||||
|
||||
//TwinObject 의 모델링 위치, 콜라이더를 초기화 후 파일 위치를 변경합니다.
|
||||
SetTwinObject(loadAsset);
|
||||
var moveFilePath = MoveFiles(fileName, filePath, fullPath, etcPath);
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
//TwinContainer 에 데이터를 할당합니다.
|
||||
TwinContainerSetData(twinContainer, texture, moveFilePath);
|
||||
twinContainerList.Add(twinContainer);
|
||||
}
|
||||
}
|
||||
|
||||
static TwinContainer CreateTwinContainer(string folderPath, TwinObject twinObject)
|
||||
{
|
||||
var twinContainer = ScriptableObject.CreateInstance<TwinContainer>();
|
||||
|
||||
var path = string.Concat(folderPath, "/", twinObject.name, ".asset");
|
||||
|
||||
AssetDatabase.CreateAsset(twinContainer, path);
|
||||
return twinContainer;
|
||||
}
|
||||
|
||||
static Texture2D CreateTwinObjectPortrait(string folderPath, TwinObject twinObject)
|
||||
{
|
||||
Texture2D thumbnailTexture = null;
|
||||
|
||||
//미리보기 텍스처 생성
|
||||
while (thumbnailTexture == null)
|
||||
{
|
||||
thumbnailTexture = AssetPreview.GetAssetPreview(twinObject.gameObject);
|
||||
System.Threading.Thread.Sleep(5);
|
||||
}
|
||||
|
||||
var transparentTexture = BackgroundTransparencyProcess(thumbnailTexture);
|
||||
//텍스처 저장
|
||||
transparentTexture.name = string.Concat("Texture_", twinObject.name);
|
||||
byte[] bytes = transparentTexture.EncodeToPNG();
|
||||
string filePath = string.Concat(folderPath, "/", transparentTexture.name, ".png");
|
||||
|
||||
File.WriteAllBytes(filePath, bytes);
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
//텍스처 불러오기
|
||||
var texture = AssetDatabase.LoadAssetAtPath<Texture2D>(filePath);
|
||||
return texture;
|
||||
}
|
||||
|
||||
static Texture2D BackgroundTransparencyProcess(Texture2D texture)
|
||||
{
|
||||
var transparentTexture = new Texture2D(texture.width, texture.height);
|
||||
transparentTexture.SetPixels(texture.GetPixels());
|
||||
|
||||
for (int h = 0; h < texture.height; h++)
|
||||
{
|
||||
for (int w = 0; w < texture.width; w++)
|
||||
{
|
||||
transparentTexture.SetPixel(w, h, Color.clear);
|
||||
|
||||
if (texture.GetPixel(w, h) != texture.GetPixel(w + 1, h))
|
||||
break;
|
||||
}
|
||||
|
||||
for (int w = texture.width; w > 0; w--)
|
||||
{
|
||||
transparentTexture.SetPixel(w, h, Color.clear);
|
||||
|
||||
if (texture.GetPixel(w, h) != texture.GetPixel(w - 1, h))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
transparentTexture.Apply();
|
||||
return transparentTexture;
|
||||
}
|
||||
|
||||
|
||||
//작업이 완료된 모델링을 전처리 완료 폴더로 이동시키는 메서드
|
||||
static string MoveFiles(string fileName, string filePath, string fullPath, string etcPath)
|
||||
{
|
||||
if (File.Exists(fullPath) && (filePath != fullPath))
|
||||
{
|
||||
int filenum = 0;
|
||||
string EtcFileName = string.Concat(etcPath, "/", fileName);
|
||||
|
||||
while (File.Exists(EtcFileName))
|
||||
{
|
||||
filenum++;
|
||||
EtcFileName = string.Concat(etcPath, "/", filenum.ToString(), "_", fileName);
|
||||
}
|
||||
fullPath = EtcFileName;
|
||||
}
|
||||
|
||||
File.Move(filePath, fullPath);
|
||||
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
static void TwinContainerSetData(TwinContainer twinContainer, Texture2D texture, string filePath)
|
||||
{
|
||||
var moveAsset = AssetDatabase.LoadAssetAtPath<GameObject>(filePath);
|
||||
var moveTwinObject = moveAsset.GetComponent<TwinObject>();
|
||||
|
||||
twinContainer.twinObject = moveTwinObject;
|
||||
twinContainer.twinObjectPortrait = texture;
|
||||
}
|
||||
|
||||
|
||||
#region TwinObject Modeling 과 Collider 를 설정하는 메서드
|
||||
//TwinObject 의 Modeling 의 위치와 Collider 를 설정하는 메서드
|
||||
static void SetTwinObject(GameObject twinObject)
|
||||
{
|
||||
var bounds = CalculateBounds(twinObject.transform);
|
||||
|
||||
SetModelPosition(twinObject.transform, bounds);
|
||||
SetBoxCollider(twinObject.transform, bounds);
|
||||
}
|
||||
|
||||
//TwinObject 의 Bounds 를 계산하는 메서드
|
||||
static Bounds CalculateBounds(Transform twinObject)
|
||||
{
|
||||
var childRenderers = twinObject.GetComponentsInChildren<Renderer>();
|
||||
var combinedBounds = childRenderers[0].bounds;
|
||||
|
||||
foreach (var childRenderer in childRenderers)
|
||||
{
|
||||
combinedBounds.Encapsulate(childRenderer.bounds);
|
||||
}
|
||||
return combinedBounds;
|
||||
}
|
||||
|
||||
//TwinObject 의 콜라이더를 크기에 맞게 설정하는 메서드
|
||||
static void SetBoxCollider(Transform twinObject, Bounds bounds)
|
||||
{
|
||||
var boxCollider = twinObject.GetOrAddComponent<BoxCollider>();
|
||||
boxCollider.size = bounds.size;
|
||||
boxCollider.center = Vector3.zero;
|
||||
}
|
||||
|
||||
//TwinObject 의 모델링 객체의 위치를 설정하는 메서드
|
||||
static void SetModelPosition(Transform twinObject, Bounds bounds)
|
||||
{
|
||||
var twinObjectChild = twinObject.GetChild(0);
|
||||
twinObjectChild.position -= bounds.center;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region TwinContainer 를 Addressable Asset 으로 설정하는 메서드
|
||||
private static void TwinContainerAddressableSetting(List<TwinContainer> twinContainers)
|
||||
{
|
||||
foreach (var twinContainer in twinContainers)
|
||||
{
|
||||
AddressableSetting(twinContainer);
|
||||
}
|
||||
}
|
||||
|
||||
//TwinContainer 의 Addressable(Group, Label)을 설정하는 메서드
|
||||
private static void AddressableSetting(TwinContainer twinContainer)
|
||||
{
|
||||
AddressableAssetSettings settings = AddressableAssetSettingsDefaultObject.Settings;
|
||||
|
||||
var path = AssetDatabase.GetAssetPath(twinContainer);
|
||||
var guid = AssetDatabase.AssetPathToGUID(path);
|
||||
var entry = settings.FindAssetEntry(guid);
|
||||
|
||||
var label = twinContainer.twinObject.assetLabel.ToString();
|
||||
var group = CreateOrFindGroup(settings, label);
|
||||
|
||||
if (entry == null)
|
||||
{
|
||||
entry = settings.CreateOrMoveEntry(guid, group);
|
||||
}
|
||||
else
|
||||
{
|
||||
entry.address = path;
|
||||
}
|
||||
settings.MoveEntry(entry, group);
|
||||
entry.SetLabel(label, true);
|
||||
}
|
||||
|
||||
//Addressable Group 을 찾고, 찾지 못했으면 해당 Group 을 생성하고 반환하는 메서드
|
||||
static AddressableAssetGroup CreateOrFindGroup(AddressableAssetSettings settings, string groupName)
|
||||
{
|
||||
var group = settings.FindGroup(groupName);
|
||||
|
||||
if (group == null)
|
||||
group = settings.CreateGroup(groupName, false, false, true, null);
|
||||
|
||||
return group;
|
||||
}
|
||||
#endregion
|
||||
#endif
|
||||
}
|
||||
}
|
||||
11
Assets/Editor/WI/TwinObjectPreprocessingHelper.cs.meta
Normal file
11
Assets/Editor/WI/TwinObjectPreprocessingHelper.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db14844db8d707440bc723fb7a82959c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/Editor/com.unity.uiextensions.meta
Normal file
9
Assets/Editor/com.unity.uiextensions.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b95396d565a2a7f478b12f8b9648ed8f
|
||||
folderAsset: yes
|
||||
timeCreated: 1467468503
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
///Credit ChoMPHi
|
||||
///Sourced from - http://forum.unity3d.com/threads/accordion-type-layout.271818/
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEditor.UI;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[CustomEditor(typeof(AccordionElement), true)]
|
||||
public class AccordionElementEditor : ToggleEditor {
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
this.serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(this.serializedObject.FindProperty("m_MinHeight"));
|
||||
this.serializedObject.ApplyModifiedProperties();
|
||||
|
||||
base.serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(base.serializedObject.FindProperty("m_IsOn"));
|
||||
EditorGUILayout.PropertyField(base.serializedObject.FindProperty("m_Interactable"));
|
||||
base.serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8882b502b0c65b24ba4623d6a383815b
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
@@ -0,0 +1,77 @@
|
||||
///Credit Jason Horsburgh
|
||||
///Sourced from - https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/issues/127/uilinerenderer-mesh-not-updating-in-editor
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[CustomEditor(typeof(UILineRenderer))]
|
||||
public class BezierLineRendererEditor : Editor
|
||||
{
|
||||
void OnSceneGUI()
|
||||
{
|
||||
UILineRenderer curveRenderer = target as UILineRenderer;
|
||||
|
||||
if (!curveRenderer || curveRenderer.drivenExternally || curveRenderer.Points == null || curveRenderer.Points.Length < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var oldMatrix = Handles.matrix;
|
||||
var transform = curveRenderer.GetComponent<RectTransform>();
|
||||
//Pivot must be 0,0 to edit
|
||||
//transform.pivot = Vector2.zero;
|
||||
Handles.matrix = transform.localToWorldMatrix;
|
||||
|
||||
var sizeX = curveRenderer.rectTransform.rect.width;
|
||||
var sizeY = curveRenderer.rectTransform.rect.height;
|
||||
var offsetX = -curveRenderer.rectTransform.pivot.x * sizeX;
|
||||
var offsetY = -curveRenderer.rectTransform.pivot.y * sizeY;
|
||||
|
||||
Vector2[] points = new Vector2[curveRenderer.Points.Length];
|
||||
for (int i = 0; i < curveRenderer.Points.Length; i++)
|
||||
{
|
||||
points[i] = curveRenderer.Points[i];
|
||||
}
|
||||
|
||||
//Need to transform points to worldspace! when set to Relative
|
||||
if (curveRenderer.RelativeSize)
|
||||
{
|
||||
for (int i = 0; i < points.Length; i++)
|
||||
{
|
||||
points[i] = new Vector2(points[i].x * sizeX + offsetX, points[i].y * sizeY + offsetY);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < points.Length - 1; i += 2)
|
||||
{
|
||||
Handles.DrawLine(points[i], points[i + 1]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < points.Length; ++i)
|
||||
{
|
||||
using (var check = new EditorGUI.ChangeCheckScope())
|
||||
{
|
||||
var p = Handles.PositionHandle(points[i], Quaternion.identity);
|
||||
|
||||
if (check.changed)
|
||||
{
|
||||
Undo.RecordObject(curveRenderer, "Changed Curve Position");
|
||||
if (curveRenderer.RelativeSize)
|
||||
{
|
||||
curveRenderer.Points[i] = new Vector2((p.x - offsetX) / sizeX, (p.y - offsetY) / sizeY);
|
||||
}
|
||||
else
|
||||
{
|
||||
curveRenderer.Points[i] = p;
|
||||
}
|
||||
curveRenderer.transform.gameObject.SetActive(false);
|
||||
curveRenderer.transform.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Handles.matrix = oldMatrix;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ef6a0d3c3259384982ae3974fe7e618
|
||||
timeCreated: 1492258093
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
67
Assets/Editor/com.unity.uiextensions/BoxSliderEditor.cs
Normal file
67
Assets/Editor/com.unity.uiextensions/BoxSliderEditor.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
///Credit judah4
|
||||
///Sourced from - http://forum.unity3d.com/threads/color-picker.267043/
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEditor.UI;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[CustomEditor(typeof(BoxSlider), true)]
|
||||
[CanEditMultipleObjects]
|
||||
public class BoxSliderEditor : SelectableEditor
|
||||
{
|
||||
|
||||
SerializedProperty m_HandleRect;
|
||||
SerializedProperty m_MinValue;
|
||||
SerializedProperty m_MaxValue;
|
||||
SerializedProperty m_WholeNumbers;
|
||||
SerializedProperty m_ValueX;
|
||||
SerializedProperty m_ValueY;
|
||||
SerializedProperty m_OnValueChanged;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
m_HandleRect = serializedObject.FindProperty("m_HandleRect");
|
||||
|
||||
m_MinValue = serializedObject.FindProperty("m_MinValue");
|
||||
m_MaxValue = serializedObject.FindProperty("m_MaxValue");
|
||||
m_WholeNumbers = serializedObject.FindProperty("m_WholeNumbers");
|
||||
m_ValueX = serializedObject.FindProperty("m_ValueX");
|
||||
m_ValueY = serializedObject.FindProperty("m_ValueY");
|
||||
m_OnValueChanged = serializedObject.FindProperty("m_OnValueChanged");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
EditorGUILayout.Space();
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.PropertyField(m_HandleRect);
|
||||
|
||||
if (m_HandleRect.objectReferenceValue != null)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
|
||||
EditorGUILayout.PropertyField(m_MinValue);
|
||||
EditorGUILayout.PropertyField(m_MaxValue);
|
||||
EditorGUILayout.PropertyField(m_WholeNumbers);
|
||||
EditorGUILayout.Slider(m_ValueX, m_MinValue.floatValue, m_MaxValue.floatValue);
|
||||
EditorGUILayout.Slider(m_ValueY, m_MinValue.floatValue, m_MaxValue.floatValue);
|
||||
|
||||
// Draw the event notification options
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.PropertyField(m_OnValueChanged);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("Specify a RectTransform for the slider fill or the slider handle or both. Each must have a parent RectTransform that it can slide within.", MessageType.Info);
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Editor/com.unity.uiextensions/BoxSliderEditor.cs.meta
Normal file
11
Assets/Editor/com.unity.uiextensions/BoxSliderEditor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c1047f9974e7ee1478bbf5490a7a62d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
59
Assets/Editor/com.unity.uiextensions/CUIBezierCurveEditor.cs
Normal file
59
Assets/Editor/com.unity.uiextensions/CUIBezierCurveEditor.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
/// Credit Titinious (https://github.com/Titinious)
|
||||
/// Sourced from - https://github.com/Titinious/CurlyUI
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[CustomEditor(typeof(CUIBezierCurve))]
|
||||
[CanEditMultipleObjects]
|
||||
public class CUIBezierCurveEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
DrawDefaultInspector();
|
||||
}
|
||||
|
||||
protected void OnSceneGUI()
|
||||
{
|
||||
CUIBezierCurve script = (CUIBezierCurve)this.target;
|
||||
|
||||
if (script.ControlPoints != null)
|
||||
{
|
||||
Vector3[] controlPoints = script.ControlPoints;
|
||||
|
||||
Transform handleTransform = script.transform;
|
||||
Quaternion handleRotation = script.transform.rotation;
|
||||
|
||||
for (int p = 0; p < CUIBezierCurve.CubicBezierCurvePtNum; p++)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
Vector3 newPt = Handles.DoPositionHandle(handleTransform.TransformPoint(controlPoints[p]), handleRotation);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
|
||||
Undo.RecordObject(script, "Move Point");
|
||||
EditorUtility.SetDirty(script);
|
||||
controlPoints[p] = handleTransform.InverseTransformPoint(newPt);
|
||||
script.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
Handles.color = Color.gray;
|
||||
Handles.DrawLine(handleTransform.TransformPoint(controlPoints[0]), handleTransform.TransformPoint(controlPoints[1]));
|
||||
Handles.DrawLine(handleTransform.TransformPoint(controlPoints[1]), handleTransform.TransformPoint(controlPoints[2]));
|
||||
Handles.DrawLine(handleTransform.TransformPoint(controlPoints[2]), handleTransform.TransformPoint(controlPoints[3]));
|
||||
|
||||
int sampleSize = 10;
|
||||
|
||||
Handles.color = Color.white;
|
||||
for (int s = 0; s < sampleSize; s++)
|
||||
{
|
||||
Handles.DrawLine(handleTransform.TransformPoint(script.GetPoint((float)s / sampleSize)), handleTransform.TransformPoint(script.GetPoint((float)(s + 1) / sampleSize)));
|
||||
}
|
||||
|
||||
script.EDITOR_ControlPoints = controlPoints;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40e01e4fb1e006b46a0f127c8a9907b3
|
||||
timeCreated: 1485671367
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
187
Assets/Editor/com.unity.uiextensions/CUIGraphicEditor.cs
Normal file
187
Assets/Editor/com.unity.uiextensions/CUIGraphicEditor.cs
Normal file
@@ -0,0 +1,187 @@
|
||||
/// Credit Titinious (https://github.com/Titinious)
|
||||
/// Sourced from - https://github.com/Titinious/CurlyUI
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[CustomEditor(typeof(CUIGraphic), true)]
|
||||
public class CUIGraphicEditor : Editor {
|
||||
|
||||
protected static bool isCurveGpFold = false;
|
||||
|
||||
protected Vector3[] reuse_Vector3s = new Vector3[4];
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
CUIGraphic script = (CUIGraphic)this.target;
|
||||
|
||||
EditorGUILayout.HelpBox("CurlyUI (CUI) should work with most of the Unity UI. For Image, use CUIImage; for Text, use CUIText; and for others (e.g. RawImage), use CUIGraphic", MessageType.Info);
|
||||
|
||||
if (script.UIGraphic == null)
|
||||
{
|
||||
EditorGUILayout.HelpBox("CUI is an extension to Unity's UI. You must set Ui Graphic with a Unity Graphic component (e.g. Image, Text, RawImage)", MessageType.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (script.UIGraphic is Image && script.GetType() != typeof(CUIImage))
|
||||
{
|
||||
EditorGUILayout.HelpBox("Although CUI components are generalized. It is recommended that for Image, use CUIImage", MessageType.Warning);
|
||||
}
|
||||
else if (script.UIGraphic is Text && script.GetType() != typeof(CUIText))
|
||||
{
|
||||
EditorGUILayout.HelpBox("Although CUI components are generalized. It is recommended that for Text, use CUIText", MessageType.Warning);
|
||||
}
|
||||
|
||||
EditorGUILayout.HelpBox("Now that CUI is ready, change the control points of the top and bottom bezier curves to curve/morph the UI. Improve resolution when the UI seems to look poorly when curved/morphed should help.", MessageType.Info);
|
||||
|
||||
}
|
||||
|
||||
DrawDefaultInspector();
|
||||
|
||||
// draw the editor that shows the position ratio of all control points from the two bezier curves
|
||||
isCurveGpFold = EditorGUILayout.Foldout(isCurveGpFold, "Curves Position Ratios");
|
||||
if (isCurveGpFold)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.LabelField("Top Curve");
|
||||
EditorGUI.indentLevel++;
|
||||
Vector3[] controlPoints = script.RefCurvesControlRatioPoints[1].array;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
for (int p = 0; p < controlPoints.Length; p++)
|
||||
{
|
||||
reuse_Vector3s[p] = EditorGUILayout.Vector3Field(string.Format("Control Points {0}", p + 1), controlPoints[p]);
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Undo.RecordObject(script, "Change Ratio Points");
|
||||
EditorUtility.SetDirty(script);
|
||||
|
||||
System.Array.Copy(reuse_Vector3s, script.RefCurvesControlRatioPoints[1].array, controlPoints.Length);
|
||||
script.UpdateCurveControlPointPositions();
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.LabelField("Bottom Curve");
|
||||
EditorGUI.indentLevel++;
|
||||
controlPoints = script.RefCurvesControlRatioPoints[0].array;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
for (int p = 0; p < controlPoints.Length; p++)
|
||||
{
|
||||
reuse_Vector3s[p] = EditorGUILayout.Vector3Field(string.Format("Control Points {0}", p + 1), controlPoints[p]);
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Undo.RecordObject(script, "Change Ratio Points");
|
||||
EditorUtility.SetDirty(script);
|
||||
|
||||
System.Array.Copy(reuse_Vector3s, controlPoints, controlPoints.Length);
|
||||
script.UpdateCurveControlPointPositions();
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
if (GUILayout.Button("Fit Bezier curves to rect transform"))
|
||||
{
|
||||
Undo.RecordObject(script, "Fit to Rect Transform");
|
||||
Undo.RecordObject(script.RefCurves[0], "Fit to Rect Transform");
|
||||
Undo.RecordObject(script.RefCurves[1], "Fit to Rect Transform");
|
||||
EditorUtility.SetDirty(script);
|
||||
|
||||
script.FixTextToRectTrans();
|
||||
|
||||
script.Refresh();
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
// disable group to prevent allowing the reference be used when there is no reference CUI
|
||||
EditorGUI.BeginDisabledGroup(script.RefCUIGraphic == null);
|
||||
|
||||
if (GUILayout.Button("Reference CUI component for curves"))
|
||||
{
|
||||
Undo.RecordObject(script, "Reference CUI");
|
||||
Undo.RecordObject(script.RefCurves[0], "Reference CUI");
|
||||
Undo.RecordObject(script.RefCurves[1], "Reference CUI");
|
||||
EditorUtility.SetDirty(script);
|
||||
|
||||
script.ReferenceCUIForBCurves();
|
||||
|
||||
script.Refresh();
|
||||
}
|
||||
|
||||
EditorGUILayout.HelpBox("Auto set the curves' control points by referencing another CUI. You need to set Ref CUI Graphic (e.g. CUIImage) first.", MessageType.Info);
|
||||
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
protected virtual void OnSceneGUI()
|
||||
{
|
||||
// for CUITextEditor, allow using scene UI to change the control points of the bezier curves
|
||||
|
||||
CUIGraphic script = (CUIGraphic)this.target;
|
||||
|
||||
script.ReportSet();
|
||||
|
||||
for (int c = 0; c < script.RefCurves.Length; c++)
|
||||
{
|
||||
|
||||
CUIBezierCurve curve = script.RefCurves[c];
|
||||
|
||||
if (curve.ControlPoints != null)
|
||||
{
|
||||
|
||||
Vector3[] controlPoints = curve.ControlPoints;
|
||||
|
||||
Transform handleTransform = curve.transform;
|
||||
Quaternion handleRotation = curve.transform.rotation;
|
||||
|
||||
for (int p = 0; p < CUIBezierCurve.CubicBezierCurvePtNum; p++)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
Handles.Label(handleTransform.TransformPoint(controlPoints[p]), string.Format("Control Point {0}", p + 1));
|
||||
Vector3 newPt = Handles.DoPositionHandle(handleTransform.TransformPoint(controlPoints[p]), handleRotation);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
|
||||
Undo.RecordObject(curve, "Move Point");
|
||||
Undo.RecordObject(script, "Move Point");
|
||||
EditorUtility.SetDirty(curve);
|
||||
controlPoints[p] = handleTransform.InverseTransformPoint(newPt);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Handles.color = Color.gray;
|
||||
Handles.DrawLine(handleTransform.TransformPoint(controlPoints[0]), handleTransform.TransformPoint(controlPoints[1]));
|
||||
Handles.DrawLine(handleTransform.TransformPoint(controlPoints[1]), handleTransform.TransformPoint(controlPoints[2]));
|
||||
Handles.DrawLine(handleTransform.TransformPoint(controlPoints[2]), handleTransform.TransformPoint(controlPoints[3]));
|
||||
|
||||
int sampleSize = 10;
|
||||
|
||||
Handles.color = Color.white;
|
||||
for (int s = 0; s < sampleSize; s++)
|
||||
{
|
||||
Handles.DrawLine(handleTransform.TransformPoint(curve.GetPoint((float)s / sampleSize)), handleTransform.TransformPoint(curve.GetPoint((float)(s + 1) / sampleSize)));
|
||||
}
|
||||
|
||||
curve.EDITOR_ControlPoints = controlPoints;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (script.RefCurves != null)
|
||||
{
|
||||
Handles.DrawLine(script.RefCurves[0].transform.TransformPoint(script.RefCurves[0].ControlPoints[0]), script.RefCurves[1].transform.TransformPoint(script.RefCurves[1].ControlPoints[0]));
|
||||
Handles.DrawLine(script.RefCurves[0].transform.TransformPoint(script.RefCurves[0].ControlPoints[3]), script.RefCurves[1].transform.TransformPoint(script.RefCurves[1].ControlPoints[3]));
|
||||
}
|
||||
|
||||
script.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7b84624f1ba7bd49b6cfc63b25f4b7c
|
||||
timeCreated: 1485671367
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
89
Assets/Editor/com.unity.uiextensions/CUIImageEditor.cs
Normal file
89
Assets/Editor/com.unity.uiextensions/CUIImageEditor.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
/// Credit Titinious (https://github.com/Titinious)
|
||||
/// Sourced from - https://github.com/Titinious/CurlyUI
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[CustomEditor(typeof(CUIImage))]
|
||||
public class CUIImageEditor : CUIGraphicEditor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
CUIImage script = (CUIImage)this.target;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUI.BeginDisabledGroup(!(script.UIImage.type == Image.Type.Sliced || script.UIImage.type == Image.Type.Tiled));
|
||||
Vector2 newCornerRatio = EditorGUILayout.Vector2Field("Corner Ratio", script.cornerPosRatio);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Undo.RecordObject(script, "Change Corner Ratio");
|
||||
EditorUtility.SetDirty(script);
|
||||
script.cornerPosRatio = newCornerRatio;
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Use native corner ratio"))
|
||||
{
|
||||
Undo.RecordObject(script, "Change Corner Ratio");
|
||||
EditorUtility.SetDirty(script);
|
||||
script.cornerPosRatio = script.OriCornerPosRatio;
|
||||
}
|
||||
|
||||
if (script.UIImage.type == Image.Type.Sliced || script.UIImage.type == Image.Type.Filled)
|
||||
{
|
||||
EditorGUILayout.HelpBox("With CUIImage, you can also adjust the size of the corners for filled or sliced Image. The grey sphere in the editor scene could also be moved to change the corner's size.", MessageType.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("With CUIImage, you can also adjust the size of the corners for filled or sliced Image. You need to set Image to filled or sliced to use this feature.", MessageType.Info);
|
||||
}
|
||||
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
protected override void OnSceneGUI()
|
||||
{
|
||||
base.OnSceneGUI();
|
||||
|
||||
CUIImage script = (CUIImage)this.target;
|
||||
|
||||
if (script.UIImage.type == Image.Type.Sliced || script.UIImage.type == Image.Type.Tiled)
|
||||
{
|
||||
Vector3 cornerPos = Vector3.zero;//
|
||||
|
||||
if (script.IsCurved)
|
||||
{
|
||||
cornerPos = script.GetBCurveSandwichSpacePoint(script.cornerPosRatio.x, script.cornerPosRatio.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
cornerPos.x = script.cornerPosRatio.x * script.RectTrans.rect.width - script.RectTrans.pivot.x * script.RectTrans.rect.width;
|
||||
cornerPos.y = script.cornerPosRatio.y * script.RectTrans.rect.height - script.RectTrans.pivot.y * script.RectTrans.rect.height;
|
||||
}
|
||||
|
||||
Handles.color = Color.gray;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
Vector3 newCornerPos = Handles.FreeMoveHandle(script.transform.TransformPoint(cornerPos), HandleUtility.GetHandleSize(script.transform.TransformPoint(cornerPos)) / 7, Vector3.one, Handles.SphereHandleCap);
|
||||
|
||||
Handles.Label(newCornerPos, string.Format("Corner Mover"));
|
||||
|
||||
newCornerPos = script.transform.InverseTransformPoint(newCornerPos);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Undo.RecordObject(script, "Move Corner");
|
||||
EditorUtility.SetDirty(script);
|
||||
|
||||
script.cornerPosRatio = new Vector2(newCornerPos.x, newCornerPos.y);
|
||||
script.cornerPosRatio.x = (script.cornerPosRatio.x + script.RectTrans.pivot.x * script.RectTrans.rect.width) / script.RectTrans.rect.width;
|
||||
script.cornerPosRatio.y = (script.cornerPosRatio.y + script.RectTrans.pivot.y * script.RectTrans.rect.height) / script.RectTrans.rect.height;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Editor/com.unity.uiextensions/CUIImageEditor.cs.meta
Normal file
12
Assets/Editor/com.unity.uiextensions/CUIImageEditor.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8445204f2ee16e0408274b8400deef53
|
||||
timeCreated: 1485929052
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
10
Assets/Editor/com.unity.uiextensions/CUITextEditor.cs
Normal file
10
Assets/Editor/com.unity.uiextensions/CUITextEditor.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
/// Credit Titinious (https://github.com/Titinious)
|
||||
/// Sourced from - https://github.com/Titinious/CurlyUI
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[CustomEditor(typeof(CUIText))]
|
||||
public class CUITextEditor : CUIGraphicEditor { }
|
||||
}
|
||||
12
Assets/Editor/com.unity.uiextensions/CUITextEditor.cs.meta
Normal file
12
Assets/Editor/com.unity.uiextensions/CUITextEditor.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 041976c43b8439747a030b45a4712b77
|
||||
timeCreated: 1485929052
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
116
Assets/Editor/com.unity.uiextensions/CanvasGroupActivator.cs
Normal file
116
Assets/Editor/com.unity.uiextensions/CanvasGroupActivator.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
/// Credit dakka
|
||||
/// Sourced from - http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/#post-1752415
|
||||
/// Notes - Mod from Yilmaz Kiymaz's editor scripts presentation at Unite 2013
|
||||
/// Updated simonDarksideJ - removed Linq use, not required.
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
public class CanvasGroupActivator : EditorWindow
|
||||
{
|
||||
[MenuItem("Window/UI/Extensions/Canvas Groups Activator")]
|
||||
public static void InitWindow()
|
||||
{
|
||||
EditorWindow.GetWindow<CanvasGroupActivator>();
|
||||
}
|
||||
|
||||
CanvasGroup[] canvasGroups;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
ObtainCanvasGroups();
|
||||
}
|
||||
|
||||
void OnFocus()
|
||||
{
|
||||
ObtainCanvasGroups();
|
||||
}
|
||||
|
||||
void ObtainCanvasGroups()
|
||||
{
|
||||
canvasGroups = GameObject.FindObjectsByType<CanvasGroup>(FindObjectsSortMode.None);
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
if (canvasGroups == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GUILayout.Space(10f);
|
||||
GUILayout.Label("Canvas Groups");
|
||||
|
||||
for (int i = 0; i < canvasGroups.Length; i++)
|
||||
{
|
||||
if (canvasGroups[i] == null) { continue; }
|
||||
|
||||
bool initialActive = false;
|
||||
if (canvasGroups[i].alpha == 1.0f)
|
||||
initialActive = true;
|
||||
|
||||
bool active = EditorGUILayout.Toggle(canvasGroups[i].name, initialActive);
|
||||
if (active != initialActive)
|
||||
{
|
||||
//If deactivated and initially active
|
||||
if (!active && initialActive)
|
||||
{
|
||||
//Deactivate this
|
||||
canvasGroups[i].alpha = 0f;
|
||||
canvasGroups[i].interactable = false;
|
||||
canvasGroups[i].blocksRaycasts = false;
|
||||
}
|
||||
//If activated and initially deactivate
|
||||
else if (active && !initialActive)
|
||||
{
|
||||
//Deactivate all others and activate this
|
||||
HideAllGroups();
|
||||
|
||||
canvasGroups[i].alpha = 1.0f;
|
||||
canvasGroups[i].interactable = true;
|
||||
canvasGroups[i].blocksRaycasts = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.Space(5f);
|
||||
|
||||
if (GUILayout.Button("Show All"))
|
||||
{
|
||||
ShowAllGroups();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Hide All"))
|
||||
{
|
||||
HideAllGroups();
|
||||
}
|
||||
}
|
||||
|
||||
void ShowAllGroups()
|
||||
{
|
||||
foreach (var group in canvasGroups)
|
||||
{
|
||||
if (group != null)
|
||||
{
|
||||
group.alpha = 1.0f;
|
||||
group.interactable = true;
|
||||
group.blocksRaycasts = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HideAllGroups()
|
||||
{
|
||||
foreach (var group in canvasGroups)
|
||||
{
|
||||
if (group != null)
|
||||
{
|
||||
group.alpha = 0;
|
||||
group.interactable = false;
|
||||
group.blocksRaycasts = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f60a419e63d329f43ba1bf57e98b34bf
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityEngine.UI.Extensions.ColorPicker
|
||||
{
|
||||
[CustomEditor(typeof(ColorPickerPresets))]
|
||||
public class ColorPickerPresetsEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
var colorPickerPresets = (ColorPickerPresets)target;
|
||||
if (colorPickerPresets.saveMode != ColorPickerPresets.SaveType.JsonFile)
|
||||
return;
|
||||
|
||||
string fileLocation = colorPickerPresets.JsonFilePath;
|
||||
|
||||
if (!System.IO.File.Exists(fileLocation))
|
||||
return;
|
||||
|
||||
if (GUILayout.Button("Open JSON file."))
|
||||
{
|
||||
Application.OpenURL(fileLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0dc729b738fb01043ac4c04b78575a98
|
||||
timeCreated: 1520733906
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77a80d348c62e93459753f8e704f474d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,119 @@
|
||||
/// Credit setchi (https://github.com/setchi)
|
||||
/// Sourced from - https://github.com/setchi/FancyScrollView
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEditor.AnimatedValues;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[CustomEditor(typeof(Scroller))]
|
||||
[CanEditMultipleObjects]
|
||||
public class ScrollerEditor : Editor
|
||||
{
|
||||
SerializedProperty viewport;
|
||||
SerializedProperty scrollDirection;
|
||||
SerializedProperty movementType;
|
||||
SerializedProperty elasticity;
|
||||
SerializedProperty scrollSensitivity;
|
||||
SerializedProperty inertia;
|
||||
SerializedProperty decelerationRate;
|
||||
SerializedProperty snap;
|
||||
SerializedProperty draggable;
|
||||
SerializedProperty scrollbar;
|
||||
|
||||
AnimBool showElasticity;
|
||||
AnimBool showInertiaRelatedValues;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
viewport = serializedObject.FindProperty("viewport");
|
||||
scrollDirection = serializedObject.FindProperty("scrollDirection");
|
||||
movementType = serializedObject.FindProperty("movementType");
|
||||
elasticity = serializedObject.FindProperty("elasticity");
|
||||
scrollSensitivity = serializedObject.FindProperty("scrollSensitivity");
|
||||
inertia = serializedObject.FindProperty("inertia");
|
||||
decelerationRate = serializedObject.FindProperty("decelerationRate");
|
||||
snap = serializedObject.FindProperty("snap");
|
||||
draggable = serializedObject.FindProperty("draggable");
|
||||
scrollbar = serializedObject.FindProperty("scrollbar");
|
||||
|
||||
showElasticity = new AnimBool(Repaint);
|
||||
showInertiaRelatedValues = new AnimBool(Repaint);
|
||||
SetAnimBools(true);
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
showElasticity.valueChanged.RemoveListener(Repaint);
|
||||
showInertiaRelatedValues.valueChanged.RemoveListener(Repaint);
|
||||
}
|
||||
|
||||
void SetAnimBools(bool instant)
|
||||
{
|
||||
SetAnimBool(showElasticity, !movementType.hasMultipleDifferentValues && movementType.enumValueIndex == (int)MovementType.Elastic, instant);
|
||||
SetAnimBool(showInertiaRelatedValues, !inertia.hasMultipleDifferentValues && inertia.boolValue, instant);
|
||||
}
|
||||
|
||||
void SetAnimBool(AnimBool a, bool value, bool instant)
|
||||
{
|
||||
if (instant)
|
||||
{
|
||||
a.value = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
a.target = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
SetAnimBools(false);
|
||||
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(viewport);
|
||||
EditorGUILayout.PropertyField(scrollDirection);
|
||||
EditorGUILayout.PropertyField(movementType);
|
||||
DrawMovementTypeRelatedValue();
|
||||
EditorGUILayout.PropertyField(scrollSensitivity);
|
||||
EditorGUILayout.PropertyField(inertia);
|
||||
DrawInertiaRelatedValues();
|
||||
EditorGUILayout.PropertyField(draggable);
|
||||
EditorGUILayout.PropertyField(scrollbar);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
void DrawMovementTypeRelatedValue()
|
||||
{
|
||||
using (var group = new EditorGUILayout.FadeGroupScope(showElasticity.faded))
|
||||
{
|
||||
if (!group.visible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using (new EditorGUI.IndentLevelScope())
|
||||
{
|
||||
EditorGUILayout.PropertyField(elasticity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawInertiaRelatedValues()
|
||||
{
|
||||
using (var group = new EditorGUILayout.FadeGroupScope(showInertiaRelatedValues.faded))
|
||||
{
|
||||
if (!group.visible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using (new EditorGUI.IndentLevelScope())
|
||||
{
|
||||
EditorGUILayout.PropertyField(decelerationRate);
|
||||
EditorGUILayout.PropertyField(snap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e82bfdd42ec254849830933cbaf350fa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
121
Assets/Editor/com.unity.uiextensions/MinMaxSliderEditor.cs
Normal file
121
Assets/Editor/com.unity.uiextensions/MinMaxSliderEditor.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
///Credit brogan89
|
||||
///Sourced from - https://github.com/brogan89/MinMaxSlider
|
||||
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEditor.UI;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[CustomEditor(typeof(MinMaxSlider), true)]
|
||||
[CanEditMultipleObjects]
|
||||
public class MinMaxSliderEditor : SelectableEditor
|
||||
{
|
||||
private SerializedProperty _customCamera;
|
||||
private SerializedProperty _sliderBounds;
|
||||
private SerializedProperty _minHandle;
|
||||
private SerializedProperty _maxHandle;
|
||||
private SerializedProperty _minText;
|
||||
private SerializedProperty _maxText;
|
||||
private SerializedProperty _textFormat;
|
||||
private SerializedProperty _middleGraphic;
|
||||
private SerializedProperty _minLimit;
|
||||
private SerializedProperty _maxLimit;
|
||||
private SerializedProperty _wholeNumbers;
|
||||
private SerializedProperty _minValue;
|
||||
private SerializedProperty _maxValue;
|
||||
|
||||
private SerializedProperty _onValueChanged;
|
||||
|
||||
private readonly GUIContent label = new GUIContent("Min Max Values");
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
_customCamera = serializedObject.FindProperty("customCamera");
|
||||
_sliderBounds = serializedObject.FindProperty("sliderBounds");
|
||||
_minHandle = serializedObject.FindProperty("minHandle");
|
||||
_maxHandle = serializedObject.FindProperty("maxHandle");
|
||||
_minText = serializedObject.FindProperty("minText");
|
||||
_maxText = serializedObject.FindProperty("maxText");
|
||||
_textFormat = serializedObject.FindProperty("textFormat");
|
||||
_middleGraphic = serializedObject.FindProperty("middleGraphic");
|
||||
_minLimit = serializedObject.FindProperty("minLimit");
|
||||
_maxLimit = serializedObject.FindProperty("maxLimit");
|
||||
_wholeNumbers = serializedObject.FindProperty("wholeNumbers");
|
||||
_minValue = serializedObject.FindProperty("minValue");
|
||||
_maxValue = serializedObject.FindProperty("maxValue");
|
||||
_onValueChanged = serializedObject.FindProperty("onValueChanged");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
float minLimitOld = _minLimit.floatValue;
|
||||
float maxLimitOld = _maxLimit.floatValue;
|
||||
float minValueOld = _minValue.floatValue;
|
||||
float maxValueOld = _maxValue.floatValue;
|
||||
|
||||
EditorGUILayout.PropertyField(_customCamera);
|
||||
EditorGUILayout.PropertyField(_sliderBounds);
|
||||
EditorGUILayout.PropertyField(_minHandle);
|
||||
EditorGUILayout.PropertyField(_maxHandle);
|
||||
EditorGUILayout.PropertyField(_middleGraphic);
|
||||
|
||||
EditorGUILayout.PropertyField(_minText);
|
||||
EditorGUILayout.PropertyField(_maxText);
|
||||
EditorGUILayout.PropertyField(_textFormat);
|
||||
|
||||
EditorGUILayout.PropertyField(_minLimit);
|
||||
EditorGUILayout.PropertyField(_maxLimit);
|
||||
|
||||
EditorGUILayout.PropertyField(_wholeNumbers);
|
||||
EditorGUILayout.PropertyField(_minValue);
|
||||
EditorGUILayout.PropertyField(_maxValue);
|
||||
|
||||
float minValue = Mathf.Clamp(_minValue.floatValue, _minLimit.floatValue, _maxLimit.floatValue);
|
||||
float maxValue = Mathf.Clamp(_maxValue.floatValue, _minLimit.floatValue, _maxLimit.floatValue);
|
||||
EditorGUILayout.MinMaxSlider(label, ref minValue, ref maxValue, _minLimit.floatValue, _maxLimit.floatValue);
|
||||
|
||||
bool anyValueChanged = !IsEqualFloat(minValueOld, minValue)
|
||||
|| !IsEqualFloat(maxValueOld, maxValue)
|
||||
|| !IsEqualFloat(minLimitOld, _minLimit.floatValue)
|
||||
|| !IsEqualFloat(maxLimitOld, _maxLimit.floatValue);
|
||||
|
||||
if (anyValueChanged)
|
||||
{
|
||||
MinMaxSlider slider = (MinMaxSlider)target;
|
||||
|
||||
// force limits to ints if whole numbers.
|
||||
// needed to do this here because it wouldn't set in component script for some reason
|
||||
if (slider.wholeNumbers)
|
||||
{
|
||||
_minLimit.floatValue = Mathf.RoundToInt(_minLimit.floatValue);
|
||||
_maxLimit.floatValue = Mathf.RoundToInt(_maxLimit.floatValue);
|
||||
}
|
||||
|
||||
// set slider values
|
||||
slider.SetValues(minValue, maxValue, _minLimit.floatValue, _maxLimit.floatValue);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.PropertyField(_onValueChanged);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if floating point numbers are within 0.01f (close enough to be considered equal)
|
||||
/// </summary>
|
||||
/// <param name="a"></param>
|
||||
/// <param name="b"></param>
|
||||
/// <returns></returns>
|
||||
private static bool IsEqualFloat(float a, float b)
|
||||
{
|
||||
return Math.Abs(a - b) < 0.01f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69352ed1561021b48ac258f81f48a988
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
/// Credit Slipp Douglas Thompson
|
||||
/// Sourced from - https://gist.github.com/capnslipp/349c18283f2fea316369
|
||||
///
|
||||
using UnityEditor;
|
||||
using UnityEditor.UI;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[CanEditMultipleObjects, CustomEditor(typeof(NonDrawingGraphic), false)]
|
||||
public class NonDrawingGraphicEditor : GraphicEditor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(base.m_Script, new GUILayoutOption[0]);
|
||||
// skipping AppearanceControlsGUI
|
||||
base.RaycastControlsGUI();
|
||||
base.serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee2802949feca4c4c934331b6a0dc379
|
||||
timeCreated: 1483566748
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
134
Assets/Editor/com.unity.uiextensions/RangeSliderEditor.cs
Normal file
134
Assets/Editor/com.unity.uiextensions/RangeSliderEditor.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
/// Credit Ben MacKinnon @Dover8
|
||||
/// Sourced from - https://github.com/Dover8/Unity-UI-Extensions/tree/range-slider
|
||||
/// Usage: Extension of the standard slider. Two handles determine a low and high value between a Min and Max.
|
||||
/// Raises a UnityEvent passing the low and high values
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEditor.UI;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[CustomEditor(typeof(RangeSlider), true)]
|
||||
[CanEditMultipleObjects]
|
||||
public class RangeSliderEditor : SelectableEditor
|
||||
{
|
||||
SerializedProperty m_Direction;
|
||||
SerializedProperty m_LowHandleRect;
|
||||
SerializedProperty m_HighHandleRect;
|
||||
SerializedProperty m_FillRect;
|
||||
|
||||
SerializedProperty m_MinValue;
|
||||
SerializedProperty m_MaxValue;
|
||||
SerializedProperty m_WholeNumbers;
|
||||
|
||||
SerializedProperty m_LowValue;
|
||||
SerializedProperty m_HighValue;
|
||||
|
||||
//need ref values for the editor MinMaxSlider
|
||||
float low = 0;
|
||||
float high = 1;
|
||||
|
||||
SerializedProperty m_OnValueChanged;
|
||||
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
m_LowHandleRect = serializedObject.FindProperty("m_LowHandleRect");
|
||||
m_HighHandleRect = serializedObject.FindProperty("m_HighHandleRect");
|
||||
m_FillRect = serializedObject.FindProperty("m_FillRect");
|
||||
m_Direction = serializedObject.FindProperty("m_Direction");
|
||||
|
||||
m_MinValue = serializedObject.FindProperty("m_MinValue");
|
||||
m_MaxValue = serializedObject.FindProperty("m_MaxValue");
|
||||
m_WholeNumbers = serializedObject.FindProperty("m_WholeNumbers");
|
||||
|
||||
m_LowValue = serializedObject.FindProperty("m_LowValue");
|
||||
low = m_LowValue.floatValue;
|
||||
m_HighValue = serializedObject.FindProperty("m_HighValue");
|
||||
high = m_HighValue.floatValue;
|
||||
|
||||
m_OnValueChanged = serializedObject.FindProperty("m_OnValueChanged");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
EditorGUILayout.Space();
|
||||
|
||||
serializedObject.Update();
|
||||
//grab the updated value affected by m_WholeNumbers
|
||||
low = m_LowValue.floatValue;
|
||||
high = m_HighValue.floatValue;
|
||||
|
||||
EditorGUILayout.PropertyField(m_LowHandleRect);
|
||||
EditorGUILayout.PropertyField(m_HighHandleRect);
|
||||
EditorGUILayout.PropertyField(m_FillRect);
|
||||
|
||||
if (m_LowHandleRect.objectReferenceValue != null && m_HighHandleRect.objectReferenceValue != null)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(m_Direction);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
RangeSlider.Direction direction = (RangeSlider.Direction)m_Direction.enumValueIndex;
|
||||
foreach (var obj in serializedObject.targetObjects)
|
||||
{
|
||||
RangeSlider rangeSlider = obj as RangeSlider;
|
||||
rangeSlider.SetDirection(direction, true);
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(m_MinValue);
|
||||
EditorGUILayout.PropertyField(m_MaxValue);
|
||||
EditorGUILayout.PropertyField(m_WholeNumbers);
|
||||
|
||||
//We're going to do a fair bit of layout here
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
//Low Label and value
|
||||
EditorGUILayout.BeginVertical();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.Label("Low");
|
||||
GUILayout.FlexibleSpace();
|
||||
EditorGUILayout.EndHorizontal();
|
||||
low = EditorGUILayout.DelayedFloatField(low, GUILayout.MaxWidth(100));
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
//Slider
|
||||
EditorGUILayout.BeginVertical();
|
||||
GUILayout.FlexibleSpace();
|
||||
EditorGUILayout.MinMaxSlider(ref low, ref high, m_MinValue.floatValue, m_MaxValue.floatValue, GUILayout.ExpandWidth(true));
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
//High label and value
|
||||
EditorGUILayout.BeginVertical();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.Label("High");
|
||||
GUILayout.FlexibleSpace();
|
||||
EditorGUILayout.EndHorizontal();
|
||||
high = EditorGUILayout.DelayedFloatField(high, GUILayout.MaxWidth(100));
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
m_LowValue.floatValue = low;
|
||||
m_HighValue.floatValue = high;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.PropertyField(m_OnValueChanged);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("Specify a RectTransform for the RangeSlider fill or the RangeSlider handles or both. Each must have a parent RectTransform that it can slide within.", MessageType.Info);
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac33445ed95315743983e4b657921146
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
19
Assets/Editor/com.unity.uiextensions/ReadOnlyDrawer.cs
Normal file
19
Assets/Editor/com.unity.uiextensions/ReadOnlyDrawer.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
/// Credit tanoshimi
|
||||
/// Sourced from - https://forum.unity3d.com/threads/read-only-fields.68976/
|
||||
///
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
|
||||
public class ReadOnlyDrawer : PropertyDrawer
|
||||
{
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
GUI.enabled = false;
|
||||
EditorGUI.PropertyField(position, property, label, true);
|
||||
GUI.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Editor/com.unity.uiextensions/ReadOnlyDrawer.cs.meta
Normal file
12
Assets/Editor/com.unity.uiextensions/ReadOnlyDrawer.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33c90f5149877a242981372f6cde9a35
|
||||
timeCreated: 1498392707
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,87 @@
|
||||
/// Credit setchi (https://github.com/setchi)
|
||||
/// Sourced from - https://github.com/setchi/FancyScrollView
|
||||
|
||||
// For maintenance, every new [SerializeField] variable in ScrollPositionController must be declared here
|
||||
|
||||
using System;
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[Obsolete("ScrollPositionController has been replaced by the Scroller component", true)]
|
||||
[CustomEditor(typeof(ScrollPositionController))]
|
||||
[CanEditMultipleObjects]
|
||||
public class ScrollPositionControllerEditor : Editor
|
||||
{
|
||||
SerializedProperty viewport;
|
||||
SerializedProperty directionOfRecognize;
|
||||
SerializedProperty movementType;
|
||||
SerializedProperty elasticity;
|
||||
SerializedProperty scrollSensitivity;
|
||||
SerializedProperty inertia;
|
||||
SerializedProperty decelerationRate;
|
||||
SerializedProperty snap;
|
||||
SerializedProperty snapEnable;
|
||||
SerializedProperty snapVelocityThreshold;
|
||||
SerializedProperty snapDuration;
|
||||
SerializedProperty dataCount;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
viewport = serializedObject.FindProperty("viewport");
|
||||
directionOfRecognize = serializedObject.FindProperty("directionOfRecognize");
|
||||
movementType = serializedObject.FindProperty("movementType");
|
||||
elasticity = serializedObject.FindProperty("elasticity");
|
||||
scrollSensitivity = serializedObject.FindProperty("scrollSensitivity");
|
||||
inertia = serializedObject.FindProperty("inertia");
|
||||
decelerationRate = serializedObject.FindProperty("decelerationRate");
|
||||
snap = serializedObject.FindProperty("snap");
|
||||
snapEnable = serializedObject.FindProperty("snap.Enable");
|
||||
snapVelocityThreshold = serializedObject.FindProperty("snap.VelocityThreshold");
|
||||
snapDuration = serializedObject.FindProperty("snap.Duration");
|
||||
dataCount = serializedObject.FindProperty("dataCount");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(viewport);
|
||||
EditorGUILayout.PropertyField(directionOfRecognize);
|
||||
EditorGUILayout.PropertyField(movementType);
|
||||
EditorGUILayout.PropertyField(elasticity);
|
||||
EditorGUILayout.PropertyField(scrollSensitivity);
|
||||
EditorGUILayout.PropertyField(inertia);
|
||||
DrawInertiaRelatedValues();
|
||||
EditorGUILayout.PropertyField(dataCount);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
void DrawInertiaRelatedValues()
|
||||
{
|
||||
if (inertia.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(decelerationRate);
|
||||
EditorGUILayout.PropertyField(snap);
|
||||
|
||||
using (new EditorGUI.IndentLevelScope())
|
||||
{
|
||||
DrawSnapRelatedValues();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawSnapRelatedValues()
|
||||
{
|
||||
if (snap.isExpanded)
|
||||
{
|
||||
EditorGUILayout.PropertyField(snapEnable);
|
||||
|
||||
if (snapEnable.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(snapVelocityThreshold);
|
||||
EditorGUILayout.PropertyField(snapDuration);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 986fda6476737da458576709b7f59ea3
|
||||
timeCreated: 1508699683
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
38
Assets/Editor/com.unity.uiextensions/TextPicEditor.cs
Normal file
38
Assets/Editor/com.unity.uiextensions/TextPicEditor.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
/// Credit drobina, w34edrtfg, playemgames
|
||||
/// Sourced from - http://forum.unity3d.com/threads/sprite-icons-with-text-e-g-emoticons.265927/
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(TextPic))]
|
||||
public class TextPicEditor : UnityEditor.UI.TextEditor
|
||||
{
|
||||
|
||||
private SerializedProperty ImageScalingFactorProp;
|
||||
private SerializedProperty hyperlinkColorProp;
|
||||
private SerializedProperty imageOffsetProp;
|
||||
private SerializedProperty iconList;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
ImageScalingFactorProp = serializedObject.FindProperty("ImageScalingFactor");
|
||||
hyperlinkColorProp = serializedObject.FindProperty("hyperlinkColor");
|
||||
imageOffsetProp = serializedObject.FindProperty("imageOffset");
|
||||
iconList = serializedObject.FindProperty("inspectorIconList");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(imageOffsetProp, new GUIContent("Image Offset"));
|
||||
EditorGUILayout.PropertyField(ImageScalingFactorProp, new GUIContent("Image Scaling Factor"));
|
||||
EditorGUILayout.PropertyField(hyperlinkColorProp, new GUIContent("Hyperlink Color"));
|
||||
EditorGUILayout.PropertyField(iconList, new GUIContent("Icon List"), true);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user