From dfa0e0f7702075b4e705ca29bc4afa259fb3a668 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Matkowski?= Date: Tue, 6 Jul 2021 16:46:34 +0200 Subject: [PATCH 01/22] Upgrade sample project to the Unity 2020.x --- .vsconfig | 6 + .../Scenes/SampleSceneSettings.lighting | 63 +++ .../Scenes/SampleSceneSettings.lighting.meta | 8 + Packages/manifest.json | 21 +- Packages/packages-lock.json | 394 ++++++++++++++++++ ProjectSettings/PackageManagerSettings.asset | 43 ++ ProjectSettings/ProjectSettings.asset | 171 +++++--- ProjectSettings/ProjectVersion.txt | 3 +- ProjectSettings/VersionControlSettings.asset | 8 + UserSettings/EditorUserSettings.asset | Bin 0 -> 4156 bytes 10 files changed, 648 insertions(+), 69 deletions(-) create mode 100644 .vsconfig create mode 100644 Assets/Examples/Scenes/SampleSceneSettings.lighting create mode 100644 Assets/Examples/Scenes/SampleSceneSettings.lighting.meta create mode 100644 Packages/packages-lock.json create mode 100644 ProjectSettings/PackageManagerSettings.asset create mode 100644 ProjectSettings/VersionControlSettings.asset create mode 100644 UserSettings/EditorUserSettings.asset diff --git a/.vsconfig b/.vsconfig new file mode 100644 index 00000000..1586a483 --- /dev/null +++ b/.vsconfig @@ -0,0 +1,6 @@ +{ + "version": "1.0", + "components": [ + "Microsoft.VisualStudio.Workload.ManagedGame" + ] +} diff --git a/Assets/Examples/Scenes/SampleSceneSettings.lighting b/Assets/Examples/Scenes/SampleSceneSettings.lighting new file mode 100644 index 00000000..83d93342 --- /dev/null +++ b/Assets/Examples/Scenes/SampleSceneSettings.lighting @@ -0,0 +1,63 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!850595691 &4890085278179872738 +LightingSettings: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: SampleSceneSettings + serializedVersion: 3 + m_GIWorkflowMode: 1 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_RealtimeEnvironmentLighting: 1 + m_BounceScale: 1 + m_AlbedoBoost: 1 + m_IndirectOutputScale: 1 + m_UsingShadowmask: 1 + m_BakeBackend: 1 + m_LightmapMaxSize: 512 + m_BakeResolution: 10 + m_Padding: 2 + m_TextureCompression: 1 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAO: 0 + m_MixedBakeMode: 2 + m_LightmapsBakeMode: 1 + m_FilterMode: 1 + m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0} + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_RealtimeResolution: 2 + m_ForceWhiteAlbedo: 0 + m_ForceUpdates: 0 + m_FinalGather: 0 + m_FinalGatherRayCount: 256 + m_FinalGatherFiltering: 1 + m_PVRCulling: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 256 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_LightProbeSampleCountMultiplier: 4 + m_PVRBounces: 2 + m_PVRMinBounces: 2 + m_PVREnvironmentMIS: 0 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 diff --git a/Assets/Examples/Scenes/SampleSceneSettings.lighting.meta b/Assets/Examples/Scenes/SampleSceneSettings.lighting.meta new file mode 100644 index 00000000..052b4e5a --- /dev/null +++ b/Assets/Examples/Scenes/SampleSceneSettings.lighting.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8aebe3ea7163bc84194ae1d81c850abb +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 4890085278179872738 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/manifest.json b/Packages/manifest.json index 5f5ff4a8..9247eafb 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -1,13 +1,22 @@ { "dependencies": { - "com.unity.ads": "2.0.8", - "com.unity.analytics": "3.2.3", - "com.unity.collab-proxy": "1.2.15", + "com.unity.2d.sprite": "1.0.0", + "com.unity.2d.tilemap": "1.0.0", + "com.unity.ads": "3.6.1", + "com.unity.analytics": "3.5.3", + "com.unity.collab-proxy": "1.3.9", "com.unity.editorcoroutines": "1.0.0", - "com.unity.package-manager-ui": "2.0.13", - "com.unity.purchasing": "2.0.3", - "com.unity.textmeshpro": "1.4.1", + "com.unity.ide.rider": "2.0.7", + "com.unity.ide.visualstudio": "2.0.7", + "com.unity.ide.vscode": "1.2.3", + "com.unity.purchasing": "2.2.2", + "com.unity.test-framework": "1.1.24", + "com.unity.textmeshpro": "3.0.1", + "com.unity.timeline": "1.4.6", + "com.unity.ugui": "1.0.0", + "com.unity.xr.legacyinputhelpers": "2.1.7", "com.unity.modules.ai": "1.0.0", + "com.unity.modules.androidjni": "1.0.0", "com.unity.modules.animation": "1.0.0", "com.unity.modules.assetbundle": "1.0.0", "com.unity.modules.audio": "1.0.0", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json new file mode 100644 index 00000000..d88f2ff1 --- /dev/null +++ b/Packages/packages-lock.json @@ -0,0 +1,394 @@ +{ + "dependencies": { + "com.unity.2d.sprite": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.2d.tilemap": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.ads": { + "version": "3.6.1", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.ugui": "1.0.0" + }, + "url": "https://packages.unity.com" + }, + "com.unity.analytics": { + "version": "3.5.3", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.ugui": "1.0.0" + }, + "url": "https://packages.unity.com" + }, + "com.unity.collab-proxy": { + "version": "1.3.9", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.editorcoroutines": { + "version": "1.0.0", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.ext.nunit": { + "version": "1.0.6", + "depth": 1, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.ide.rider": { + "version": "2.0.7", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.test-framework": "1.1.1" + }, + "url": "https://packages.unity.com" + }, + "com.unity.ide.visualstudio": { + "version": "2.0.7", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.test-framework": "1.1.9" + }, + "url": "https://packages.unity.com" + }, + "com.unity.ide.vscode": { + "version": "1.2.3", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.purchasing": { + "version": "2.2.2", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.ugui": "1.0.0" + }, + "url": "https://packages.unity.com" + }, + "com.unity.test-framework": { + "version": "1.1.24", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.ext.nunit": "1.0.6", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0" + }, + "url": "https://packages.unity.com" + }, + "com.unity.textmeshpro": { + "version": "3.0.1", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.ugui": "1.0.0" + }, + "url": "https://packages.unity.com" + }, + "com.unity.timeline": { + "version": "1.4.6", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.modules.director": "1.0.0", + "com.unity.modules.animation": "1.0.0", + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.particlesystem": "1.0.0" + }, + "url": "https://packages.unity.com" + }, + "com.unity.ugui": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.imgui": "1.0.0" + } + }, + "com.unity.xr.legacyinputhelpers": { + "version": "2.1.7", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.modules.vr": "1.0.0", + "com.unity.modules.xr": "1.0.0" + }, + "url": "https://packages.unity.com" + }, + "com.unity.modules.ai": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.androidjni": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.animation": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.assetbundle": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.audio": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.cloth": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0" + } + }, + "com.unity.modules.director": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.animation": "1.0.0" + } + }, + "com.unity.modules.imageconversion": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.imgui": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.jsonserialize": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.particlesystem": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.physics": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.physics2d": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.screencapture": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.imageconversion": "1.0.0" + } + }, + "com.unity.modules.subsystems": { + "version": "1.0.0", + "depth": 1, + "source": "builtin", + "dependencies": { + "com.unity.modules.jsonserialize": "1.0.0" + } + }, + "com.unity.modules.terrain": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.terrainphysics": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.terrain": "1.0.0" + } + }, + "com.unity.modules.tilemap": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics2d": "1.0.0" + } + }, + "com.unity.modules.ui": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.uielements": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.uielementsnative": "1.0.0" + } + }, + "com.unity.modules.uielementsnative": { + "version": "1.0.0", + "depth": 1, + "source": "builtin", + "dependencies": { + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0" + } + }, + "com.unity.modules.umbra": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.unityanalytics": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0" + } + }, + "com.unity.modules.unitywebrequest": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.unitywebrequestassetbundle": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.assetbundle": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0" + } + }, + "com.unity.modules.unitywebrequestaudio": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.audio": "1.0.0" + } + }, + "com.unity.modules.unitywebrequesttexture": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0" + } + }, + "com.unity.modules.unitywebrequestwww": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.unitywebrequestassetbundle": "1.0.0", + "com.unity.modules.unitywebrequestaudio": "1.0.0", + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.assetbundle": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0" + } + }, + "com.unity.modules.vehicles": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0" + } + }, + "com.unity.modules.video": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0" + } + }, + "com.unity.modules.vr": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.xr": "1.0.0" + } + }, + "com.unity.modules.wind": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.xr": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.subsystems": "1.0.0" + } + } + } +} diff --git a/ProjectSettings/PackageManagerSettings.asset b/ProjectSettings/PackageManagerSettings.asset new file mode 100644 index 00000000..be4a7974 --- /dev/null +++ b/ProjectSettings/PackageManagerSettings.asset @@ -0,0 +1,43 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &1 +MonoBehaviour: + m_ObjectHideFlags: 61 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} + m_Name: + m_EditorClassIdentifier: + m_EnablePreviewPackages: 0 + m_EnablePackageDependencies: 0 + m_AdvancedSettingsExpanded: 1 + m_ScopedRegistriesSettingsExpanded: 1 + oneTimeWarningShown: 0 + m_Registries: + - m_Id: main + m_Name: + m_Url: https://packages.unity.com + m_Scopes: [] + m_IsDefault: 1 + m_Capabilities: 7 + m_UserSelectedRegistryName: + m_UserAddingNewScopedRegistry: 0 + m_RegistryInfoDraft: + m_ErrorMessage: + m_Original: + m_Id: + m_Name: + m_Url: + m_Scopes: [] + m_IsDefault: 0 + m_Capabilities: 0 + m_Modified: 0 + m_Name: + m_Url: + m_Scopes: + - + m_SelectedScopeIndex: 0 diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index c59c4c9a..0cd78d8f 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -3,7 +3,7 @@ --- !u!129 &1 PlayerSettings: m_ObjectHideFlags: 0 - serializedVersion: 18 + serializedVersion: 22 productGUID: 8a5218c0d05cb524792aaa1333627b48 AndroidProfiler: 0 AndroidFilterTouchesWhenObscured: 0 @@ -49,10 +49,11 @@ PlayerSettings: m_StereoRenderingPath: 0 m_ActiveColorSpace: 0 m_MTRendering: 1 + mipStripping: 0 + numberOfMipsStripped: 0 m_StackTraceTypes: 010000000100000001000000010000000100000001000000 iosShowActivityIndicatorOnLoading: -1 androidShowActivityIndicatorOnLoading: -1 - displayResolutionDialog: 1 iosUseCustomAppBackgroundBehavior: 0 iosAllowHTTPDownload: 1 allowedAutorotateToPortrait: 1 @@ -65,6 +66,7 @@ PlayerSettings: disableDepthAndStencilBuffers: 0 androidStartInFullscreen: 1 androidRenderOutsideSafeArea: 0 + androidUseSwappy: 0 androidBlitType: 0 defaultIsNativeResolution: 1 macRetinaSupport: 1 @@ -79,11 +81,11 @@ PlayerSettings: usePlayerLog: 1 bakeCollisionMeshes: 0 forceSingleInstance: 0 + useFlipModelSwapchain: 1 resizableWindow: 0 useMacAppStoreValidation: 0 macAppStoreCategory: public.app-category.games gpuSkinning: 1 - graphicsJobs: 0 xboxPIXTextureCapture: 0 xboxEnableAvatar: 0 xboxEnableKinect: 0 @@ -91,7 +93,6 @@ PlayerSettings: xboxEnableFitness: 0 visibleInBackground: 1 allowFullscreenSwitch: 1 - graphicsJobMode: 0 fullscreenMode: 1 xboxSpeechDB: 0 xboxEnableHeadOrientation: 0 @@ -114,7 +115,12 @@ PlayerSettings: switchNVNOtherPoolsGranularity: 16777216 switchNVNMaxPublicTextureIDCount: 0 switchNVNMaxPublicSamplerIDCount: 0 + stadiaPresentMode: 0 + stadiaTargetFramerate: 0 + vulkanNumSwapchainBuffers: 3 vulkanEnableSetSRGBWrite: 0 + vulkanEnablePreTransform: 0 + vulkanEnableLateAcquireNextImage: 0 m_SupportedAspectRatios: 4:3: 1 5:4: 1 @@ -128,40 +134,26 @@ PlayerSettings: m_HolographicPauseOnTrackingLoss: 1 xboxOneDisableKinectGpuReservation: 1 xboxOneEnable7thCore: 1 - isWsaHolographicRemotingEnabled: 0 vrSettings: - cardboard: - depthFormat: 0 - enableTransitionView: 0 - daydream: - depthFormat: 0 - useSustainedPerformanceMode: 0 - enableVideoLayer: 0 - useProtectedVideoMemory: 0 - minimumSupportedHeadTracking: 0 - maximumSupportedHeadTracking: 1 - hololens: - depthFormat: 1 - depthBufferSharingEnabled: 1 - oculus: - sharedDepthBuffer: 1 - dashSupport: 1 - lowOverheadMode: 0 - protectedContext: 0 - v2Signing: 0 enable360StereoCapture: 0 - protectGraphicsMemory: 0 + isWsaHolographicRemotingEnabled: 0 enableFrameTimingStats: 0 useHDRDisplay: 0 + D3DHDRBitDepth: 0 m_ColorGamuts: 00000000 targetPixelDensity: 30 resolutionScalingMode: 0 androidSupportedAspectRatio: 1 androidMaxAspectRatio: 2.1 - applicationIdentifier: {} - buildNumber: {} + applicationIdentifier: + Standalone: com.BroWarCollective.EditorToolbox + buildNumber: + Standalone: 0 + iPhone: 0 + tvOS: 0 + overrideDefaultApplicationIdentifier: 0 AndroidBundleVersionCode: 1 - AndroidMinSdkVersion: 16 + AndroidMinSdkVersion: 19 AndroidTargetSdkVersion: 0 AndroidPreferredInstallLocation: 1 aotOptions: @@ -176,28 +168,16 @@ PlayerSettings: StripUnusedMeshComponents: 1 VertexChannelCompressionMask: 4054 iPhoneSdkVersion: 988 - iOSTargetOSVersionString: 9.0 + iOSTargetOSVersionString: 11.0 tvOSSdkVersion: 0 tvOSRequireExtendedGameController: 0 - tvOSTargetOSVersionString: 9.0 + tvOSTargetOSVersionString: 11.0 uIPrerenderedIcon: 0 uIRequiresPersistentWiFi: 0 uIRequiresFullScreen: 1 uIStatusBarHidden: 1 uIExitOnSuspend: 0 uIStatusBarStyle: 0 - iPhoneSplashScreen: {fileID: 0} - iPhoneHighResSplashScreen: {fileID: 0} - iPhoneTallHighResSplashScreen: {fileID: 0} - iPhone47inSplashScreen: {fileID: 0} - iPhone55inPortraitSplashScreen: {fileID: 0} - iPhone55inLandscapeSplashScreen: {fileID: 0} - iPhone58inPortraitSplashScreen: {fileID: 0} - iPhone58inLandscapeSplashScreen: {fileID: 0} - iPadPortraitSplashScreen: {fileID: 0} - iPadHighResPortraitSplashScreen: {fileID: 0} - iPadLandscapeSplashScreen: {fileID: 0} - iPadHighResLandscapeSplashScreen: {fileID: 0} appleTVSplashScreen: {fileID: 0} appleTVSplashScreen2x: {fileID: 0} tvOSSmallIconLayers: [] @@ -225,8 +205,8 @@ PlayerSettings: iOSLaunchScreeniPadFillPct: 100 iOSLaunchScreeniPadSize: 100 iOSLaunchScreeniPadCustomXibPath: - iOSUseLaunchScreenStoryboard: 0 iOSLaunchScreenCustomStoryboardPath: + iOSLaunchScreeniPadCustomStoryboardPath: iOSDeviceRequirements: [] iOSURLSchemes: [] iOSBackgroundModes: 0 @@ -234,6 +214,7 @@ PlayerSettings: metalEditorSupport: 1 metalAPIValidation: 1 iOSRenderExtraFrameOnPause: 0 + iosCopyPluginsCodeInsteadOfSymlink: 0 appleDeveloperTeamID: iOSManualSigningProvisioningProfileID: tvOSManualSigningProvisioningProfileID: @@ -243,9 +224,17 @@ PlayerSettings: iOSRequireARKit: 0 iOSAutomaticallyDetectAndAddCapabilities: 1 appleEnableProMotion: 0 + shaderPrecisionModel: 0 clonedFromGUID: c0afd0d1d80e3634a9dac47e8a0426ea templatePackageId: com.unity.template.3d@1.3.0 templateDefaultScene: Assets/Scenes/SampleScene.unity + useCustomMainManifest: 0 + useCustomLauncherManifest: 0 + useCustomMainGradleTemplate: 0 + useCustomLauncherGradleManifest: 0 + useCustomBaseGradleTemplate: 0 + useCustomGradlePropertiesTemplate: 0 + useCustomProguardFile: 0 AndroidTargetArchitectures: 5 AndroidSplashScreenScale: 0 androidSplashScreen: {fileID: 0} @@ -257,12 +246,17 @@ PlayerSettings: AndroidEnableTango: 0 androidEnableBanner: 1 androidUseLowAccuracyLocation: 0 + androidUseCustomKeystore: 0 m_AndroidBanners: - width: 320 height: 180 banner: {fileID: 0} androidGamepadSupportLevel: 0 - resolutionDialogBanner: {fileID: 0} + AndroidMinifyWithR8: 0 + AndroidMinifyRelease: 0 + AndroidMinifyDebug: 0 + AndroidValidateAppBundleSize: 1 + AndroidAppBundleSizeToValidate: 150 m_BuildTargetIcons: [] m_BuildTargetPlatformIcons: [] m_BuildTargetBatching: @@ -281,6 +275,46 @@ PlayerSettings: - m_BuildTarget: WebGL m_StaticBatching: 0 m_DynamicBatching: 0 + m_BuildTargetGraphicsJobs: + - m_BuildTarget: MacStandaloneSupport + m_GraphicsJobs: 0 + - m_BuildTarget: Switch + m_GraphicsJobs: 0 + - m_BuildTarget: MetroSupport + m_GraphicsJobs: 0 + - m_BuildTarget: GameCoreScarlettSupport + m_GraphicsJobs: 0 + - m_BuildTarget: AppleTVSupport + m_GraphicsJobs: 0 + - m_BuildTarget: BJMSupport + m_GraphicsJobs: 0 + - m_BuildTarget: LinuxStandaloneSupport + m_GraphicsJobs: 0 + - m_BuildTarget: GameCoreXboxOneSupport + m_GraphicsJobs: 0 + - m_BuildTarget: PS4Player + m_GraphicsJobs: 0 + - m_BuildTarget: iOSSupport + m_GraphicsJobs: 0 + - m_BuildTarget: PS5Player + m_GraphicsJobs: 0 + - m_BuildTarget: WindowsStandaloneSupport + m_GraphicsJobs: 0 + - m_BuildTarget: XboxOnePlayer + m_GraphicsJobs: 0 + - m_BuildTarget: LuminSupport + m_GraphicsJobs: 0 + - m_BuildTarget: CloudRendering + m_GraphicsJobs: 0 + - m_BuildTarget: AndroidPlayer + m_GraphicsJobs: 0 + - m_BuildTarget: WebGLSupport + m_GraphicsJobs: 0 + m_BuildTargetGraphicsJobMode: + - m_BuildTarget: PS4Player + m_GraphicsJobMode: 0 + - m_BuildTarget: XboxOnePlayer + m_GraphicsJobMode: 0 m_BuildTargetGraphicsAPIs: - m_BuildTarget: AndroidPlayer m_APIs: 0b00000008000000 @@ -290,7 +324,7 @@ PlayerSettings: m_Automatic: 1 - m_BuildTarget: AppleTVSupport m_APIs: 10000000 - m_Automatic: 0 + m_Automatic: 1 - m_BuildTarget: WebGLSupport m_APIs: 0b000000 m_Automatic: 1 @@ -300,9 +334,9 @@ PlayerSettings: m_Devices: - Oculus - OpenVR - m_BuildTargetEnableVuforiaSettings: [] openGLRequireES31: 0 openGLRequireES31AEP: 0 + openGLRequireES32: 0 m_TemplateCustomTags: {} mobileMTRendering: Android: 1 @@ -310,6 +344,7 @@ PlayerSettings: tvOS: 1 m_BuildTargetGroupLightmapEncodingQuality: [] m_BuildTargetGroupLightmapSettings: [] + m_BuildTargetNormalMapEncoding: [] playModeTestRunnerEnabled: 0 runPlayModeTestAsEditModeTest: 0 actionOnDotNetUnhandledException: 1 @@ -319,12 +354,14 @@ PlayerSettings: cameraUsageDescription: locationUsageDescription: microphoneUsageDescription: + switchNMETAOverride: switchNetLibKey: switchSocketMemoryPoolSize: 6144 switchSocketAllocatorPoolSize: 128 switchSocketConcurrencyLimit: 14 switchScreenResolutionBehavior: 2 switchUseCPUProfiler: 0 + switchUseGOLDLinker: 0 switchApplicationID: 0x01004b9000490000 switchNSODependencies: switchTitleNames_0: @@ -342,6 +379,7 @@ PlayerSettings: switchTitleNames_12: switchTitleNames_13: switchTitleNames_14: + switchTitleNames_15: switchPublisherNames_0: switchPublisherNames_1: switchPublisherNames_2: @@ -357,6 +395,7 @@ PlayerSettings: switchPublisherNames_12: switchPublisherNames_13: switchPublisherNames_14: + switchPublisherNames_15: switchIcons_0: {fileID: 0} switchIcons_1: {fileID: 0} switchIcons_2: {fileID: 0} @@ -372,6 +411,7 @@ PlayerSettings: switchIcons_12: {fileID: 0} switchIcons_13: {fileID: 0} switchIcons_14: {fileID: 0} + switchIcons_15: {fileID: 0} switchSmallIcons_0: {fileID: 0} switchSmallIcons_1: {fileID: 0} switchSmallIcons_2: {fileID: 0} @@ -387,6 +427,7 @@ PlayerSettings: switchSmallIcons_12: {fileID: 0} switchSmallIcons_13: {fileID: 0} switchSmallIcons_14: {fileID: 0} + switchSmallIcons_15: {fileID: 0} switchManualHTML: switchAccessibleURLs: switchLegalInformation: @@ -449,6 +490,7 @@ PlayerSettings: switchSocketInitializeEnabled: 1 switchNetworkInterfaceManagerInitializeEnabled: 1 switchPlayerConnectionEnabled: 1 + switchUseNewStyleFilepaths: 0 ps4NPAgeRating: 12 ps4NPTitleSecret: ps4NPTrophyPackPath: @@ -488,6 +530,7 @@ PlayerSettings: ps4DownloadDataSize: 0 ps4GarlicHeapSize: 2048 ps4ProGarlicHeapSize: 2560 + playerPrefsMaxSize: 32768 ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ ps4pnSessions: 1 ps4pnPresence: 1 @@ -500,6 +543,7 @@ PlayerSettings: ps4UseResolutionFallback: 0 ps4ReprojectionSupport: 0 ps4UseAudio3dBackend: 0 + ps4UseLowGarlicFragmentationMode: 1 ps4SocialScreenEnabled: 0 ps4ScriptOptimizationLevel: 0 ps4Audio3dVirtualSpeakerCount: 14 @@ -520,9 +564,11 @@ PlayerSettings: ps4GPU800MHz: 1 ps4attribEyeToEyeDistanceSettingVR: 0 ps4IncludedModules: [] + ps4attribVROutputEnabled: 0 monoEnv: splashScreenBackgroundSourceLandscape: {fileID: 0} splashScreenBackgroundSourcePortrait: {fileID: 0} + blurSplashScreenBackground: 1 spritePackerPolicy: webGLMemorySize: 256 webGLExceptionSupport: 1 @@ -535,17 +581,27 @@ PlayerSettings: webGLAnalyzeBuildSize: 0 webGLUseEmbeddedResources: 0 webGLCompressionFormat: 1 + webGLWasmArithmeticExceptions: 0 webGLLinkerTarget: 1 webGLThreadsSupport: 0 + webGLDecompressionFallback: 0 scriptingDefineSymbols: {} + additionalCompilerArguments: {} platformArchitecture: {} scriptingBackend: {} il2cppCompilerConfiguration: {} managedStrippingLevel: {} incrementalIl2cppBuild: {} + suppressCommonWarnings: 1 allowUnsafeCode: 0 + useDeterministicCompilation: 1 + useReferenceAssemblies: 1 + enableRoslynAnalyzers: 1 additionalIl2CppArgs: scriptingRuntimeVersion: 1 + gcIncremental: 1 + assemblyVersionValidation: 1 + gcWBarrierValidation: 0 apiCompatibilityLevelPerPlatform: {} m_RenderingPath: 1 m_MobileRenderingPath: 1 @@ -576,7 +632,6 @@ PlayerSettings: metroFTAName: metroFTAFileTypes: [] metroProtocolName: - metroCompilationOverrides: 1 XboxOneProductId: XboxOneUpdateKey: XboxOneSandboxId: @@ -595,18 +650,16 @@ PlayerSettings: XboxOneCapability: [] XboxOneGameRating: {} XboxOneIsContentPackage: 0 + XboxOneEnhancedXboxCompatibilityMode: 0 XboxOneEnableGPUVariability: 1 XboxOneSockets: {} XboxOneSplashScreen: {fileID: 0} XboxOneAllowedProductIds: [] XboxOnePersistentLocalStorageSize: 0 XboxOneXTitleMemory: 8 - xboxOneScriptCompiler: 1 XboxOneOverrideIdentityName: - vrEditorSettings: - daydream: - daydreamIconForeground: {fileID: 0} - daydreamIconBackground: {fileID: 0} + XboxOneOverrideIdentityPublisher: + vrEditorSettings: {} cloudServicesEnabled: UNet: 1 luminIcon: @@ -615,24 +668,18 @@ PlayerSettings: m_PortalFolderPath: luminCert: m_CertPath: - m_PrivateKeyPath: + m_SignPackage: 1 luminIsChannelApp: 0 luminVersion: m_VersionCode: 1 m_VersionName: - facebookSdkVersion: 7.9.4 - facebookAppId: - facebookCookies: 1 - facebookLogging: 1 - facebookStatus: 1 - facebookXfbml: 0 - facebookFrictionlessRequests: 1 apiCompatibilityLevel: 6 + activeInputHandler: 0 cloudProjectId: 7c3cffca-cc4e-4f8f-93f7-97568a17fdbb framebufferDepthMemorylessMode: 0 + qualitySettingsNames: [] projectName: Editor Toolbox organizationId: whitefox-studio cloudEnabled: 0 - enableNativePlatformBackendsForNewInputSystem: 0 - disableOldInputManagerSupport: 0 legacyClampBlendShapeWeights: 0 + virtualTexturingSupportEnabled: 0 diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index 85c44c83..6260f2cc 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1 +1,2 @@ -m_EditorVersion: 2018.4.26f1 +m_EditorVersion: 2020.3.2f1 +m_EditorVersionWithRevision: 2020.3.2f1 (8fd9074bf66c) diff --git a/ProjectSettings/VersionControlSettings.asset b/ProjectSettings/VersionControlSettings.asset new file mode 100644 index 00000000..dca28814 --- /dev/null +++ b/ProjectSettings/VersionControlSettings.asset @@ -0,0 +1,8 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!890905787 &1 +VersionControlSettings: + m_ObjectHideFlags: 0 + m_Mode: Visible Meta Files + m_CollabEditorSettings: + inProgressEnabled: 1 diff --git a/UserSettings/EditorUserSettings.asset b/UserSettings/EditorUserSettings.asset new file mode 100644 index 0000000000000000000000000000000000000000..f7df0ccb75b3bf05cec354add9110dbe87f0a10c GIT binary patch literal 4156 zcmeI0yN=UP5QfKbF0fpdU9Kx6Xs9D6?6O-Rw3Y!;WED`fp+Q0>K5-0ojBLjdooil! z0ztt8Adu*R23~-QcR-@X%zxrIYhHlnOmyU#@BE%Q`lA#lM0!AU<|Yws@RJ`zU8A$t z-fmy-jyv=x&vQ*<_!c{PzV-Uc_YYsc{oZOn{P^kq74s6)AH3?==GZ05_?2818Ii`H zcRFS7HOinttHsjj7i-UQ4SkKDlwq%?bvVNU*GsO`PiB|77y2ycX{6KD8f8xleWTRZ z=^kre6}(yUMx}p?xwenF%}W1c;BqzT0rxWWJc&s?0qFE?28E_jJh{($77v;lVmD1bpuC32w=J`Ax2Pzu+4Xb1e0bWKOgx z>56*=$M=JP9{#7CW9~UXj%A;hGABAO>59K8_=SJ?=Yn4Z-zU1`cu5!?#v&SsB=M$h zOu=I-oQ^%W1eKCf+n)&<`?i!0EpwKHft`3G({cFSp>!}Gmb@q^YS5lKb)KKi|Od_ zxnn1S{ec&&zz Date: Wed, 7 Jul 2021 00:34:14 +0200 Subject: [PATCH 02/22] Add FormattedNumberAttribute&Drawer --- .../FormattedNumberAttributeDrawer.cs | 80 +++++++++++++++++++ .../FormattedNumberAttributeDrawer.cs.meta | 11 +++ .../RegularDrawers/LayerAttributeDrawer.cs | 1 - .../FormattedNumberAttribute.cs | 33 ++++++++ .../FormattedNumberAttribute.cs.meta | 11 +++ Assets/Examples/Scenes/SampleScene.unity | 2 + Assets/Examples/Scripts/SampleBehaviour1.cs | 7 ++ 7 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/FormattedNumberAttributeDrawer.cs create mode 100644 Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/FormattedNumberAttributeDrawer.cs.meta create mode 100644 Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/FormattedNumberAttribute.cs create mode 100644 Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/FormattedNumberAttribute.cs.meta diff --git a/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/FormattedNumberAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/FormattedNumberAttributeDrawer.cs new file mode 100644 index 00000000..40d9ae01 --- /dev/null +++ b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/FormattedNumberAttributeDrawer.cs @@ -0,0 +1,80 @@ +using System; +using System.Globalization; + +using UnityEditor; +using UnityEngine; + +namespace Toolbox.Editor.Drawers +{ + [CustomPropertyDrawer(typeof(FormattedNumberAttribute))] + public class FormattedNumberAttributeDrawer : ToolboxNativePropertyDrawer + { + private readonly NumberFormatInfo formatInfo = new NumberFormatInfo() + { + NumberGroupSeparator = " ", + CurrencySymbol = "$", + CurrencyDecimalSeparator = "." + }; + + + private void ApplyControlName(string propertyKey) + { + GUI.SetNextControlName(propertyKey); + } + + private bool IsControlEditing(string propertyKey) + { + return EditorGUIUtility.editingTextField && GUI.GetNameOfFocusedControl() == propertyKey; + } + + private Single GetSingle(SerializedProperty property) + { + return property.propertyType == SerializedPropertyType.Integer + ? property.intValue + : property.floatValue; + } + + private string GetFormat(SerializedProperty property, FormattedNumberAttribute attribute) + { + var isInt = property.propertyType == SerializedPropertyType.Integer; + return string.Format("{0}{1}", attribute.Format, isInt ? 0 : attribute.DecimalsToShow); + } + + + protected override void OnGUISafe(Rect position, SerializedProperty property, GUIContent label) + { + var key = property.GetPropertyHashKey(); + ApplyControlName(key); + EditorGUI.PropertyField(position, property, label); + if (IsControlEditing(key)) + { + position.width = 0; + position.height = 0; + } + else + { + position.xMin += EditorGUIUtility.labelWidth + EditorGUIUtility.standardVerticalSpacing; + } + + var targetAttribute = attribute as FormattedNumberAttribute; + var single = GetSingle(property); + var format = GetFormat(property, targetAttribute); + + try + { + EditorGUI.TextField(position, single.ToString(format, formatInfo)); + } + catch (FormatException) + { + ToolboxEditorLog.AttributeUsageWarning(attribute, property, string.Format("{0} format is not supported.", format)); + } + } + + + public override bool IsPropertyValid(SerializedProperty property) + { + return property.propertyType == SerializedPropertyType.Integer || + property.propertyType == SerializedPropertyType.Float; + } + } +} \ No newline at end of file diff --git a/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/FormattedNumberAttributeDrawer.cs.meta b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/FormattedNumberAttributeDrawer.cs.meta new file mode 100644 index 00000000..df85779a --- /dev/null +++ b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/FormattedNumberAttributeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 68debf9d70bfb99489d951a43400c6c6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/LayerAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/LayerAttributeDrawer.cs index c396731a..9f2e205b 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/LayerAttributeDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/LayerAttributeDrawer.cs @@ -1,5 +1,4 @@ using UnityEditor; -using UnityEditorInternal; using UnityEngine; namespace Toolbox.Editor.Drawers diff --git a/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/FormattedNumberAttribute.cs b/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/FormattedNumberAttribute.cs new file mode 100644 index 00000000..e68fa3fa --- /dev/null +++ b/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/FormattedNumberAttribute.cs @@ -0,0 +1,33 @@ +using System; + +namespace UnityEngine +{ + /// + /// Creates customized property field for numeric values. + /// + /// + /// Supported formats: + /// + /// MS documentation + /// + /// + /// + /// Supported types: , , . + /// + [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] + public class FormattedNumberAttribute : PropertyAttribute + { + public FormattedNumberAttribute(string format = "n") + { + Format = format; + } + + public string Format { get; private set; } + + /// + /// Indicates number of visible decimals in the text field. + /// Integers will ignore this property. + /// + public int DecimalsToShow { get; set; } = 2; + } +} \ No newline at end of file diff --git a/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/FormattedNumberAttribute.cs.meta b/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/FormattedNumberAttribute.cs.meta new file mode 100644 index 00000000..3ea181f6 --- /dev/null +++ b/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/FormattedNumberAttribute.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0470a26cf0d6fec48b0f28a192159a43 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Examples/Scenes/SampleScene.unity b/Assets/Examples/Scenes/SampleScene.unity index d9192f71..e4013c51 100644 --- a/Assets/Examples/Scenes/SampleScene.unity +++ b/Assets/Examples/Scenes/SampleScene.unity @@ -699,6 +699,8 @@ MonoBehaviour: scene: sceneReference: {fileID: 102900000, guid: f11034f4657f51a47aac14f26410c500, type: 3} buildIndex: 0 + largeNumber: 5167000 + currency: 20.41 --- !u!4 &959025299 Transform: m_ObjectHideFlags: 2 diff --git a/Assets/Examples/Scripts/SampleBehaviour1.cs b/Assets/Examples/Scripts/SampleBehaviour1.cs index de44ed07..531e1c0b 100644 --- a/Assets/Examples/Scripts/SampleBehaviour1.cs +++ b/Assets/Examples/Scripts/SampleBehaviour1.cs @@ -202,4 +202,11 @@ public class SampleClass2 [Label("26", skinStyle: SkinStyle.Box)] public SerializedScene scene; + + [Label("27", skinStyle: SkinStyle.Box)] + + [FormattedNumber] + public int largeNumber; + [FormattedNumber("c")] + public float currency; } \ No newline at end of file From ae4e44ca74a2d87f40aaa528c35bdf1c579bb0ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Matkowski?= Date: Thu, 8 Jul 2021 00:15:50 +0200 Subject: [PATCH 03/22] Fix typo in BuildNativeDictionary method --- .../Scripts/Serialization/SerializedDictionary.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Assets/Editor Toolbox/Scripts/Serialization/SerializedDictionary.cs b/Assets/Editor Toolbox/Scripts/Serialization/SerializedDictionary.cs index e854321a..a65a9ad8 100644 --- a/Assets/Editor Toolbox/Scripts/Serialization/SerializedDictionary.cs +++ b/Assets/Editor Toolbox/Scripts/Serialization/SerializedDictionary.cs @@ -122,11 +122,17 @@ public void Clear() indexByKey.Clear(); } + [Obsolete("Use BuildNativeDictionary instead.")] public Dictionary BuiltNativeDictionary() { return new Dictionary(dictionary); } + public Dictionary BuildNativeDictionary() + { + return new Dictionary(dictionary); + } + void ICollection>.Add(KeyValuePair pair) { Add(pair.Key, pair.Value); From d997d03b004b46f97f70189ea3340483ec18a7eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Matkowski?= Date: Thu, 8 Jul 2021 00:27:43 +0200 Subject: [PATCH 04/22] Update documentation --- Assets/Editor Toolbox/README.md | 11 ++++++++++- Assets/Examples/Scenes/SampleScene.unity | 2 +- Assets/Examples/Scripts/SampleBehaviour1.cs | 2 +- Docs/formattednumber.png | Bin 0 -> 2189 bytes README.md | 11 ++++++++++- 5 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 Docs/formattednumber.png diff --git a/Assets/Editor Toolbox/README.md b/Assets/Editor Toolbox/README.md index 190c5fe6..f2a07724 100644 --- a/Assets/Editor Toolbox/README.md +++ b/Assets/Editor Toolbox/README.md @@ -243,6 +243,15 @@ public SampleClass1 var1; ![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/lefttoggle.png) +#### FormattedNumberAttribute + +```csharp +[FormattedNumber] +public int bigNumber; +``` + +![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/formattednumber.png) + --- ### Toolbox Drawers @@ -533,7 +542,7 @@ public void Usage() dictionary.Add(3, new GameObject("TestObject")); dictionary.ContainsKey(2); //etc. like standard System.Collections.Generic.Dictionary<> - var nativeDictionary = dictionary.BuiltNativeDictionary(); + var nativeDictionary = dictionary.BuildNativeDictionary(); } #endif ``` diff --git a/Assets/Examples/Scenes/SampleScene.unity b/Assets/Examples/Scenes/SampleScene.unity index e4013c51..a4120ed4 100644 --- a/Assets/Examples/Scenes/SampleScene.unity +++ b/Assets/Examples/Scenes/SampleScene.unity @@ -699,7 +699,7 @@ MonoBehaviour: scene: sceneReference: {fileID: 102900000, guid: f11034f4657f51a47aac14f26410c500, type: 3} buildIndex: 0 - largeNumber: 5167000 + bigNumber: 12345678 currency: 20.41 --- !u!4 &959025299 Transform: diff --git a/Assets/Examples/Scripts/SampleBehaviour1.cs b/Assets/Examples/Scripts/SampleBehaviour1.cs index 531e1c0b..0cf0f74a 100644 --- a/Assets/Examples/Scripts/SampleBehaviour1.cs +++ b/Assets/Examples/Scripts/SampleBehaviour1.cs @@ -206,7 +206,7 @@ public class SampleClass2 [Label("27", skinStyle: SkinStyle.Box)] [FormattedNumber] - public int largeNumber; + public int bigNumber; [FormattedNumber("c")] public float currency; } \ No newline at end of file diff --git a/Docs/formattednumber.png b/Docs/formattednumber.png new file mode 100644 index 0000000000000000000000000000000000000000..0799371121fcf7d625406b7523a5124bb038a065 GIT binary patch literal 2189 zcmV;82y*v{P)000yS0ssI2^oLmM00001b5ch_0Itp) z=>Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D2qH;DK~#8N?VS5l zO>G;;pI=<`I3$ND6ei>p>2(Z~ zF^FhJ!bC~-pYVR#_iD|Sw_UG!YPM&t&kyFhuC>;^_Dt9HUEh1P^;fwd2!imhL&RO^ z3i9*wa|J=@WEeDUc{!K(`T1$d{|~EmT2yk3+d_Utmg0UfBg7yRjIG9U%h%YA7Iw3StTVUs>t@1{`d6soH=vmojZ3_Q4p-3 zHpRV9pFWwHnM}yRg9n*`RjXD}ynp{bsXDj>I(6!X4I5s)dX+RdOwF4%uUcG8>Z;vi(xzV_C<;r#I*8Qi2R`2@v?%j*5KX~u}(_k!c>n(WK0ZDK z49SWWD^!t~;bGn~GBVQA(sFZiRb9d5GiJ<~GiQ!Ub#XUe0m8zadB~X@7|@N);V(I2&!@E z(j|48U_I#Kj;da`Z~>vz#l5kyk%qyZtCW6gWs_+_U08AGDJdx`hK7cQ(W6IWJIuvB zI5;>zKVM6J!QI{c#fujz#)1?V7Zb26McGvmvw!yNS-dkfhc-O973|n?~Hm9+gx3~B9?c2G_z<~qVl~ZK=uv9!+ z7A{;kapFWOtiysBK%NcwyXG4R)`TwZ3UhHc=fj5&&d$!YwY6IQGl(*MWiI`jHf@TD ziJ?)=#hn=Q5gHoGrc;+}MP+5BhldA-0Iz^!z!RuCMu7(70rT+TLpL`!wii#IJ{>h` zlsXD0PoCr)EfECk#*(-@I5;>tIoaCUju|sXePvRYW_&u`k9RhmTh6fkD(*ZRFyriG z*)q2)?mc_j+jzN5ma%Wy801>sBrQnSTBHb?ep*)z)&O5&cD}>+0%Si97y)MJ`^v7#$tWqoSs! zMmu0M(sDGmzrTM$K>-^A8dB-|vuDp-U0r+k?#(SQB~)nLNs}g-E^6k=l`E4cPu3Da zux>1gJJuU_Lw|>bg?V~f;vGA7v|3!SHaa5i{KRp`KYsks@}Hsp{P}YfmW`cC z=`I?TxRtn@6BHD*Z{I#GF&dF_~kPY-eZ3sk(Y1!Cqco>L_4>+7frJ<-vf&D{(I=DdCXm zl;%Si?GB22VPT;vW@Kb|dwZv)rTO{!@yyU+4n^FpoOZ=MK0Y4P@auncLU7S;EioF; zpFgh*HCCDxOkaojo3^1(2&k)9E2eXsiHL~6j%bPLzSwj9E|~YZbLW#^&mYB0D-dCM6{iq^73Y+S;}y?!eZV z%ayo8-@bhh95{fouV25ud-v`g6!*~3Py!~_$HyloCWeQE{_>p|MPL#0bp$KKvbd+G zr~CT)*45Q%xfzJNy}dn}PKAkND-wm(I@4 zrKP3BI@6|2WAjJw>C-2?d3JVoRaF(u^Z4;&iuLvNn0@s;K=%_85(qfK)zy{0B^Cth z$C9|?*44iwM~+nAfHYUnyu3UNyPKOEo9N)+U<=|7jE64n%#4kV4RRkF8{6^MGSSh| zLx&D!O0j15?%ku9m6gQ+GtXR$HKQWpZsk}I_nMj-p7gi`eu9cahYqPj3QYR2VZ#gt zgOig}NJt2xtQ}~f)oU44-re1u^9KwVz-~{gwoqAFiA!KX2M33!sHmotra`~kEn?(L$#1c$)DKwP|*bN~#v{>#{ogF{EY zwZsJLF!PMDmJ8NRD{=n~s;jF%fBvi`?SW*!d-v|wmpnQc|5o3oSC_OZ0{8v;^{bW$ z!k@rziaV-`!3hlw#mnHD9UUF@zd$AkZ9%tLkXk_y{wWx=-*@i#=-Aj;cCT@9amB^O zT2&C*M*YcO(RV@UR2VS^P5$Js(529D7z#lUIu-L*DI)HIAPE0D%FF)?aFr^uz`3K1 P00000NkvXXu0mjf1-wPG literal 0 HcmV?d00001 diff --git a/README.md b/README.md index 190c5fe6..f2a07724 100644 --- a/README.md +++ b/README.md @@ -243,6 +243,15 @@ public SampleClass1 var1; ![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/lefttoggle.png) +#### FormattedNumberAttribute + +```csharp +[FormattedNumber] +public int bigNumber; +``` + +![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/formattednumber.png) + --- ### Toolbox Drawers @@ -533,7 +542,7 @@ public void Usage() dictionary.Add(3, new GameObject("TestObject")); dictionary.ContainsKey(2); //etc. like standard System.Collections.Generic.Dictionary<> - var nativeDictionary = dictionary.BuiltNativeDictionary(); + var nativeDictionary = dictionary.BuildNativeDictionary(); } #endif ``` From c2ef7279489802bfe7a086cc99dfee9f94ec4fb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Matkowski?= Date: Thu, 8 Jul 2021 00:55:38 +0200 Subject: [PATCH 05/22] Minor refactor changes --- .../ToolboxDrawers/PropertyCondition.cs | 9 ++++++ .../ToolboxDrawers/PropertyCondition.cs.meta | 11 +++++++ .../InLineEditorAttributeDrawer.cs | 29 ++++++++++++------- .../ToolboxDrawers/ToolboxConditionDrawer.cs | 1 - .../ToolboxConditionDrawerBase.cs | 7 ----- .../ToolboxDrawers/ToolboxDecoratorDrawer.cs | 1 - .../ToolboxListPropertyDrawer.cs | 1 - .../ToolboxDrawers/ToolboxPropertyDrawer.cs | 16 +++++----- .../ToolboxPropertyDrawerBase.cs | 1 - 9 files changed, 45 insertions(+), 31 deletions(-) create mode 100644 Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyCondition.cs create mode 100644 Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyCondition.cs.meta diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyCondition.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyCondition.cs new file mode 100644 index 00000000..399df2e3 --- /dev/null +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyCondition.cs @@ -0,0 +1,9 @@ +namespace Toolbox.Editor.Drawers +{ + public enum PropertyCondition + { + Valid, + NonValid, + Disabled + } +} \ No newline at end of file diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyCondition.cs.meta b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyCondition.cs.meta new file mode 100644 index 00000000..21e42160 --- /dev/null +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyCondition.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: abbce97698323494db627fef98477965 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertySelfDrawers/InLineEditorAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertySelfDrawers/InLineEditorAttributeDrawer.cs index 7c87c101..44e222a6 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertySelfDrawers/InLineEditorAttributeDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertySelfDrawers/InLineEditorAttributeDrawer.cs @@ -39,6 +39,22 @@ static InLineEditorAttributeDrawer() private static readonly PropertyDataStorage storage; + private Editor GetTargetsEditor(SerializedProperty property, InLineEditorAttribute attribute) + { + var editor = storage.ReturnItem(property, attribute); + if (editor.target != property.objectReferenceValue) + { + editor = storage.CreateItem(property, attribute); + } + + return editor; + } + + private bool GetInspectorToggle(SerializedProperty property) + { + return GUILayout.Toggle(property.isExpanded, Style.foldoutContent, Style.foldoutStyle, Style.foldoutOptions); + } + private void DrawEditor(Editor editor, InLineEditorAttribute attribute) { using (new EditorGUILayout.VerticalScope(Style.backgroundStyle)) @@ -109,22 +125,13 @@ protected override void OnGuiSafe(SerializedProperty property, GUIContent label, return; } - property.isExpanded = GUILayout.Toggle(property.isExpanded, - Style.foldoutContent, - Style.foldoutStyle, - Style.foldoutOptions); + property.isExpanded = GetInspectorToggle(property); } //create additional Editor for the associated reference if (property.isExpanded) { - var editor = storage.ReturnItem(property, attribute); - if (editor.target != property.objectReferenceValue) - { - //validate target value change (e.g. list reorder) - editor = storage.CreateItem(property, attribute); - } - + var editor = GetTargetsEditor(property, attribute); InspectorUtility.SetIsEditorExpanded(editor, true); //make useage of the created (cached) Editor instance using (new FixedFieldsScope()) diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxConditionDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxConditionDrawer.cs index 672f778f..189b8158 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxConditionDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxConditionDrawer.cs @@ -21,7 +21,6 @@ public override sealed PropertyCondition OnGuiValidate(SerializedProperty proper return OnGuiValidate(property, attribute as T); } - public PropertyCondition OnGuiValidate(SerializedProperty property, T attribute) { if (attribute == null) diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxConditionDrawerBase.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxConditionDrawerBase.cs index 26c1f5f0..a5b270cd 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxConditionDrawerBase.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxConditionDrawerBase.cs @@ -3,13 +3,6 @@ namespace Toolbox.Editor.Drawers { - public enum PropertyCondition - { - Valid, - NonValid, - Disabled - } - public abstract class ToolboxConditionDrawerBase : ToolboxAttributeDrawer { public abstract PropertyCondition OnGuiValidate(SerializedProperty property); diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxDecoratorDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxDecoratorDrawer.cs index ddc64267..2830722e 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxDecoratorDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxDecoratorDrawer.cs @@ -27,7 +27,6 @@ public override sealed void OnGuiClose(ToolboxAttribute attribute) OnGuiClose(attribute as T); } - public void OnGuiBegin(T attribute) { if (attribute == null) diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxListPropertyDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxListPropertyDrawer.cs index 48865424..a767b7f3 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxListPropertyDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxListPropertyDrawer.cs @@ -7,7 +7,6 @@ public abstract class ToolboxListPropertyDrawer : ToolboxPropertyDrawer wh { public override bool IsPropertyValid(SerializedProperty property) { - //NOTE: this will be always true since the ToolboxPropertyHandler will validate each drawer return property.isArray; } } diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxPropertyDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxPropertyDrawer.cs index 03dbf3c7..fe8d693c 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxPropertyDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxPropertyDrawer.cs @@ -26,7 +26,6 @@ public override sealed void OnGui(SerializedProperty property, GUIContent label, OnGui(property, label, attribute as T); } - public void OnGui(SerializedProperty property, GUIContent label, T attribute) { if (attribute == null) @@ -37,15 +36,14 @@ public void OnGui(SerializedProperty property, GUIContent label, T attribute) if (IsPropertyValid(property)) { OnGuiSafe(property, label, attribute); + return; } - else - { - var warningContent = new GUIContent(property.displayName + " has invalid property drawer"); - //create additional warning log to the console window - ToolboxEditorLog.WrongAttributeUsageWarning(attribute, property); - //create additional warning label based on the property name - ToolboxEditorGui.DrawEmptyProperty(property, warningContent); - } + + var warningContent = new GUIContent(string.Format("{0} has invalid property drawer", property.displayName)); + //create additional warning log to the Console window + ToolboxEditorLog.WrongAttributeUsageWarning(attribute, property); + //create additional warning label based on the property name + ToolboxEditorGui.DrawEmptyProperty(property, warningContent); } } } \ No newline at end of file diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxPropertyDrawerBase.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxPropertyDrawerBase.cs index eabd4307..3f1347c8 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxPropertyDrawerBase.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxPropertyDrawerBase.cs @@ -11,7 +11,6 @@ public abstract class ToolboxPropertyDrawerBase : ToolboxAttributeDrawer public abstract void OnGui(SerializedProperty property, GUIContent label, ToolboxAttribute attribute); - public virtual void OnGuiReload() { } } From 93ea9730a34b07cf6d51dcd56da1cec194d6d99b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Matkowski?= Date: Thu, 8 Jul 2021 20:11:22 +0200 Subject: [PATCH 06/22] Rename 'composition' attributes to 'archetype' --- Assets/Editor Toolbox/Editor/ToolboxPropertyHandler.cs | 2 +- .../{CompositionAttributes.meta => ArchetypeAttributes.meta} | 0 .../TitleAttribute.cs | 2 +- .../TitleAttribute.cs.meta | 0 ...lboxCompositionAttribute.cs => ToolboxArchetypeAttribute.cs} | 2 +- ...itionAttribute.cs.meta => ToolboxArchetypeAttribute.cs.meta} | 0 6 files changed, 3 insertions(+), 3 deletions(-) rename Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/{CompositionAttributes.meta => ArchetypeAttributes.meta} (100%) rename Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/{CompositionAttributes => ArchetypeAttributes}/TitleAttribute.cs (94%) rename Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/{CompositionAttributes => ArchetypeAttributes}/TitleAttribute.cs.meta (100%) rename Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/{ToolboxCompositionAttribute.cs => ToolboxArchetypeAttribute.cs} (83%) rename Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/{ToolboxCompositionAttribute.cs.meta => ToolboxArchetypeAttribute.cs.meta} (100%) diff --git a/Assets/Editor Toolbox/Editor/ToolboxPropertyHandler.cs b/Assets/Editor Toolbox/Editor/ToolboxPropertyHandler.cs index f367de8d..409792f8 100644 --- a/Assets/Editor Toolbox/Editor/ToolboxPropertyHandler.cs +++ b/Assets/Editor Toolbox/Editor/ToolboxPropertyHandler.cs @@ -176,7 +176,7 @@ private void HandleNewAttribute(ToolboxAttribute attribute) case ToolboxConditionAttribute a: TryAssignConditionAttribute(a); break; - case ToolboxCompositionAttribute a: + case ToolboxArchetypeAttribute a: var composition = a.Process(); foreach (var newAttribute in composition) { diff --git a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/CompositionAttributes.meta b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/ArchetypeAttributes.meta similarity index 100% rename from Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/CompositionAttributes.meta rename to Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/ArchetypeAttributes.meta diff --git a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/CompositionAttributes/TitleAttribute.cs b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/ArchetypeAttributes/TitleAttribute.cs similarity index 94% rename from Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/CompositionAttributes/TitleAttribute.cs rename to Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/ArchetypeAttributes/TitleAttribute.cs index c3cac633..f2ac4b36 100644 --- a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/CompositionAttributes/TitleAttribute.cs +++ b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/ArchetypeAttributes/TitleAttribute.cs @@ -9,7 +9,7 @@ namespace UnityEngine /// Standardized header, it's composition of the and the . /// [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)] - public class TitleAttribute : ToolboxCompositionAttribute + public class TitleAttribute : ToolboxArchetypeAttribute { public TitleAttribute(string label) { diff --git a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/CompositionAttributes/TitleAttribute.cs.meta b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/ArchetypeAttributes/TitleAttribute.cs.meta similarity index 100% rename from Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/CompositionAttributes/TitleAttribute.cs.meta rename to Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/ArchetypeAttributes/TitleAttribute.cs.meta diff --git a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/ToolboxCompositionAttribute.cs b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/ToolboxArchetypeAttribute.cs similarity index 83% rename from Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/ToolboxCompositionAttribute.cs rename to Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/ToolboxArchetypeAttribute.cs index 0298aaff..53682a54 100644 --- a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/ToolboxCompositionAttribute.cs +++ b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/ToolboxArchetypeAttribute.cs @@ -6,7 +6,7 @@ namespace UnityEngine /// Base class for all attributes responsible for the creation of dedicated composition of s. /// [AttributeUsage(AttributeTargets.Field, AllowMultiple = true, Inherited = true)] - public abstract class ToolboxCompositionAttribute : ToolboxAttribute + public abstract class ToolboxArchetypeAttribute : ToolboxAttribute { public abstract ToolboxAttribute[] Process(); } diff --git a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/ToolboxCompositionAttribute.cs.meta b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/ToolboxArchetypeAttribute.cs.meta similarity index 100% rename from Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/ToolboxCompositionAttribute.cs.meta rename to Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/ToolboxArchetypeAttribute.cs.meta From 6b43fa6900176ee67000339e51f9ad5cfb550397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Matkowski?= Date: Thu, 8 Jul 2021 20:53:31 +0200 Subject: [PATCH 07/22] Update documentation --- Assets/Editor Toolbox/README.md | 4 ++-- README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Assets/Editor Toolbox/README.md b/Assets/Editor Toolbox/README.md index f2a07724..d0b0ee0e 100644 --- a/Assets/Editor Toolbox/README.md +++ b/Assets/Editor Toolbox/README.md @@ -414,14 +414,14 @@ public GameObject[] largeArray = new GameObject[19]; ![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/scrollableitems.png) -#### ToolboxCompositionAttributes +#### ToolboxArchetypeAttributes Using this attribute you are able to implement custom patterns of frequently grouped **ToolboxAttributes**. ```csharp [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)] -public class TitleAttribute : ToolboxCompositionAttribute +public class TitleAttribute : ToolboxArchetypeAttribute { public TitleAttribute(string label) { diff --git a/README.md b/README.md index f2a07724..d0b0ee0e 100644 --- a/README.md +++ b/README.md @@ -414,14 +414,14 @@ public GameObject[] largeArray = new GameObject[19]; ![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/scrollableitems.png) -#### ToolboxCompositionAttributes +#### ToolboxArchetypeAttributes Using this attribute you are able to implement custom patterns of frequently grouped **ToolboxAttributes**. ```csharp [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)] -public class TitleAttribute : ToolboxCompositionAttribute +public class TitleAttribute : ToolboxArchetypeAttribute { public TitleAttribute(string label) { From 14b6ab2fb696adb95880a369861550bb6f867d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Matkowski?= Date: Thu, 8 Jul 2021 21:24:33 +0200 Subject: [PATCH 08/22] Minor refactor changes --- .../Editor/ToolboxLayoutHelper.cs | 2 +- .../Editor/ToolboxPropertyHandler.cs | 29 +++++++++---------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/Assets/Editor Toolbox/Editor/ToolboxLayoutHelper.cs b/Assets/Editor Toolbox/Editor/ToolboxLayoutHelper.cs index bc6974d1..8633178f 100644 --- a/Assets/Editor Toolbox/Editor/ToolboxLayoutHelper.cs +++ b/Assets/Editor Toolbox/Editor/ToolboxLayoutHelper.cs @@ -7,7 +7,7 @@ namespace Toolbox.Editor /// /// Helper class to handle and validate creation of and groups. - /// Remark: can be used only within the Toolbox Editors. + /// Remark: can be used only within the Toolbox Editors. /// [InitializeOnLoad] internal static class ToolboxLayoutHelper diff --git a/Assets/Editor Toolbox/Editor/ToolboxPropertyHandler.cs b/Assets/Editor Toolbox/Editor/ToolboxPropertyHandler.cs index 409792f8..cfdc26f9 100644 --- a/Assets/Editor Toolbox/Editor/ToolboxPropertyHandler.cs +++ b/Assets/Editor Toolbox/Editor/ToolboxPropertyHandler.cs @@ -156,6 +156,7 @@ private void ProcessToolboxData() decoratorAttributes.Sort((a1, a2) => a1.Order.CompareTo(a2.Order)); hasToolboxDecoratorDrawer = true; } + //check if property has custom conditon drawer hasToolboxConditionDrawer = conditionAttribute != null; } @@ -165,10 +166,10 @@ private void HandleNewAttribute(ToolboxAttribute attribute) switch (attribute) { case ToolboxListPropertyAttribute a: - TryAssignPropertyAttribute(a); + TryAssignListPropertyAttribute(a); break; case ToolboxSelfPropertyAttribute a: - TryAssignPropertyAttribute(a); + TryAssignSelfPropertyAttribute(a); break; case ToolboxDecoratorAttribute a: TryAssignDecoratorAttribute(a); @@ -186,10 +187,10 @@ private void HandleNewAttribute(ToolboxAttribute attribute) } } - private bool TryAssignPropertyAttribute(ToolboxListPropertyAttribute attribute) + private bool TryAssignBasePropertyAttribute(ToolboxPropertyAttribute attribute) { - //we can only have one property attribute for an array property - if (propertyAttribute != null || !isArray) + //NOTE: we can only have one property attribute + if (propertyAttribute != null) { return false; } @@ -200,18 +201,14 @@ private bool TryAssignPropertyAttribute(ToolboxListPropertyAttribute attribute) } } - private bool TryAssignPropertyAttribute(ToolboxSelfPropertyAttribute attribute) + private bool TryAssignListPropertyAttribute(ToolboxListPropertyAttribute attribute) { - //we can only have one property attribute for a non-array property - if (propertyAttribute != null || isArray) - { - return false; - } - else - { - propertyAttribute = attribute; - return true; - } + return isArray && TryAssignBasePropertyAttribute(attribute); + } + + private bool TryAssignSelfPropertyAttribute(ToolboxSelfPropertyAttribute attribute) + { + return !isArray && TryAssignBasePropertyAttribute(attribute); } private bool TryAssignDecoratorAttribute(ToolboxDecoratorAttribute attribute) From 034318cd199f04be1f914c7fa4ec7367cf2946a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Matkowski?= Date: Fri, 9 Jul 2021 19:23:04 +0200 Subject: [PATCH 09/22] Minor refactor changes --- .../Editor Toolbox/Editor/Drawers/Internal.meta | 8 ++++++++ .../FolderDataDrawer.cs | 12 +++++------- .../FolderDataDrawer.cs.meta | 0 .../RegularDrawers/DirectoryAttributeDrawer.cs | 15 +++++++-------- .../ToolboxDrawers/ToolboxAttributeDrawer.cs | 8 ++++++++ .../ToolboxDrawers/ToolboxAttributeDrawer.cs.meta | 11 +++++++++++ .../Drawers/ToolboxDrawers/ToolboxDrawer.cs | 6 ------ .../ToolboxAttributes/ToolboxAttribute.cs | 6 ++++-- 8 files changed, 43 insertions(+), 23 deletions(-) create mode 100644 Assets/Editor Toolbox/Editor/Drawers/Internal.meta rename Assets/Editor Toolbox/Editor/Drawers/{RegularDrawers => Internal}/FolderDataDrawer.cs (98%) rename Assets/Editor Toolbox/Editor/Drawers/{RegularDrawers => Internal}/FolderDataDrawer.cs.meta (100%) create mode 100644 Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxAttributeDrawer.cs create mode 100644 Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxAttributeDrawer.cs.meta diff --git a/Assets/Editor Toolbox/Editor/Drawers/Internal.meta b/Assets/Editor Toolbox/Editor/Drawers/Internal.meta new file mode 100644 index 00000000..2e36b2b6 --- /dev/null +++ b/Assets/Editor Toolbox/Editor/Drawers/Internal.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d294f5bb5d903b44dab5dd7eb495a89e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/FolderDataDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/Internal/FolderDataDrawer.cs similarity index 98% rename from Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/FolderDataDrawer.cs rename to Assets/Editor Toolbox/Editor/Drawers/Internal/FolderDataDrawer.cs index 477a68f3..56eb9daa 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/FolderDataDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/Internal/FolderDataDrawer.cs @@ -8,8 +8,6 @@ namespace Toolbox.Editor.Drawers [CustomPropertyDrawer(typeof(FolderData))] internal class FolderDataDrawer : PropertyDrawer { - private const string selectorEventName = "ObjectSelectorUpdated"; - private const int largeIconPickedId = 1001; private const int smallIconPickedId = 1002; @@ -81,15 +79,15 @@ public override float GetPropertyHeight(SerializedProperty property, GUIContent var pathProperty = property.FindPropertyRelative("path"); var tooltipProperty = property.FindPropertyRelative("tooltip"); - //check if type is path-based or name-based - height += typeProperty.intValue == 0 - ? EditorGUI.GetPropertyHeight(pathProperty) - : EditorGUI.GetPropertyHeight(nameProperty); height += EditorGUI.GetPropertyHeight(tooltipProperty); height += Style.height; height += Style.height; height += Style.largeFolderHeight; height += Style.spacing * 4; + //check if type is path-based or name-based + height += typeProperty.intValue == 0 + ? EditorGUI.GetPropertyHeight(pathProperty) + : EditorGUI.GetPropertyHeight(nameProperty); return height; } @@ -210,7 +208,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten } //catch object selection event and assign it to proper property - if (Event.current.commandName == selectorEventName) + if (Event.current.commandName == "ObjectSelectorUpdated") { //get proper action id by removing unique property hash code var rawPickId = EditorGUIUtility.GetObjectPickerControlID(); diff --git a/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/FolderDataDrawer.cs.meta b/Assets/Editor Toolbox/Editor/Drawers/Internal/FolderDataDrawer.cs.meta similarity index 100% rename from Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/FolderDataDrawer.cs.meta rename to Assets/Editor Toolbox/Editor/Drawers/Internal/FolderDataDrawer.cs.meta diff --git a/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/DirectoryAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/DirectoryAttributeDrawer.cs index 0600960d..009d296d 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/DirectoryAttributeDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/DirectoryAttributeDrawer.cs @@ -39,14 +39,13 @@ protected override void OnGUISafe(Rect position, SerializedProperty property, GU } position.height = Style.rowHeight; - position.width -= Style.directoryButtonWidth + Style.spacing; - //draw the default string property field + position.xMax -= Style.pickerWidth + Style.spacing; EditorGUI.PropertyField(position, property, label); - position.x = position.xMax + Style.spacing; - position.width = Style.directoryButtonWidth; + position.xMin += position.width; + position.xMax += Style.pickerWidth + Style.spacing; //create additional pick directory button - if (GUI.Button(position, Style.directoryButtonContent, EditorStyles.miniButton)) + if (GUI.Button(position, Style.pickerContent, EditorStyles.miniButton)) { var relativePath = Attribute.RelativePath; var baseDataPath = Application.dataPath; @@ -94,13 +93,13 @@ private static class Style internal static readonly float boxHeight = EditorGUIUtility.singleLineHeight * 2.5f; #endif internal static readonly float spacing = EditorGUIUtility.standardVerticalSpacing; - internal static readonly float directoryButtonWidth = 30.0f; + internal static readonly float pickerWidth = 30.0f; - internal static readonly GUIContent directoryButtonContent; + internal static readonly GUIContent pickerContent; static Style() { - directoryButtonContent = new GUIContent(EditorGUIUtility.FindTexture("Folder Icon"), "Pick directory"); + pickerContent = new GUIContent(EditorGUIUtility.FindTexture("Folder Icon"), "Pick directory"); } } } diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxAttributeDrawer.cs new file mode 100644 index 00000000..d577b805 --- /dev/null +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxAttributeDrawer.cs @@ -0,0 +1,8 @@ +namespace Toolbox.Editor.Drawers +{ + /// + /// Base class for all drawers based on custom attributes. + /// + public abstract class ToolboxAttributeDrawer : ToolboxDrawer + { } +} diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxAttributeDrawer.cs.meta b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxAttributeDrawer.cs.meta new file mode 100644 index 00000000..22d61bb6 --- /dev/null +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxAttributeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0dff0704660db944cbbfb79bdd6791b3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxDrawer.cs index 6bc54b66..e4d1056d 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/ToolboxDrawer.cs @@ -5,10 +5,4 @@ /// public abstract class ToolboxDrawer { } - - /// - /// Base class for all drawers based on custom attributes. - /// - public abstract class ToolboxAttributeDrawer : ToolboxDrawer - { } } \ No newline at end of file diff --git a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/ToolboxAttribute.cs b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/ToolboxAttribute.cs index 56dcab0d..0a229654 100644 --- a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/ToolboxAttribute.cs +++ b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/ToolboxAttribute.cs @@ -1,8 +1,10 @@ -namespace UnityEngine +using System; + +namespace UnityEngine { /// /// Base class for all attributes used within Component Editors. /// - public abstract class ToolboxAttribute : System.Attribute + public abstract class ToolboxAttribute : Attribute { } } \ No newline at end of file From d403e1c4106b3216e2483904b6e4c8b0ede02b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Matkowski?= Date: Fri, 9 Jul 2021 19:23:50 +0200 Subject: [PATCH 10/22] Add possibility to pick Scenes in the SceneNameAttributeDrawer --- .../SceneNameAttributeDrawer.cs | 44 ++++++++++++++++--- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/SceneNameAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/SceneNameAttributeDrawer.cs index 29ab3235..b8f9f3d4 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/SceneNameAttributeDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/SceneNameAttributeDrawer.cs @@ -1,5 +1,6 @@ using UnityEditor; using UnityEngine; +using UnityEngine.SceneManagement; namespace Toolbox.Editor.Drawers { @@ -13,9 +14,9 @@ private static bool SceneExists(string sceneName) return false; } - for (var i = 0; i < UnityEngine.SceneManagement.SceneManager.sceneCountInBuildSettings; i++) + for (var i = 0; i < SceneManager.sceneCountInBuildSettings; i++) { - var scenePath = UnityEngine.SceneManagement.SceneUtility.GetScenePathByBuildIndex(i); + var scenePath = SceneUtility.GetScenePathByBuildIndex(i); var lastSlash = scenePath.LastIndexOf("/"); var name = scenePath.Substring(lastSlash + 1, scenePath.LastIndexOf(".") - lastSlash - 1); @@ -40,18 +41,40 @@ protected override void OnGUISafe(Rect position, SerializedProperty property, GU { if (!SceneExists(property.stringValue)) { - //set rect for the warning message field var helpBoxRect = new Rect(position.x, position.y, position.width, Style.boxHeight); EditorGUI.HelpBox(helpBoxRect, "Scene does not exist. " + "Check available Scenes in the Build options.", MessageType.Warning); - - //adjust rect for standard property field position.yMin += Style.boxHeight + Style.spacing * 2; } - EditorGUI.PropertyField(position, property, label, property.isExpanded); + position.height = Style.rowHeight; + position.xMax -= Style.pickerWidth + Style.spacing; + EditorGUI.PropertyField(position, property, label); + position.xMin += position.width; + position.xMax += Style.pickerWidth + Style.spacing; + + var controlId = GUIUtility.GetControlID(FocusType.Keyboard); + if (GUI.Button(position, Style.pickerButtonContent, EditorStyles.miniButton)) + { + EditorGUIUtility.ShowObjectPicker(null, false, null, controlId); + } + + if (Event.current.commandName == "ObjectSelectorUpdated") + { + if (controlId == EditorGUIUtility.GetObjectPickerControlID()) + { + var target = EditorGUIUtility.GetObjectPickerObject(); + if (target) + { + property.serializedObject.Update(); + property.stringValue = target.name; + property.serializedObject.ApplyModifiedProperties(); + GUI.changed = true; + } + } + } } @@ -70,7 +93,14 @@ private static class Style internal static readonly float boxHeight = EditorGUIUtility.singleLineHeight * 2.5f; #endif internal static readonly float spacing = EditorGUIUtility.standardVerticalSpacing; - internal static readonly float padding = 5.0f; + internal static readonly float pickerWidth = 30.0f; + + internal static readonly GUIContent pickerButtonContent; + + static Style() + { + pickerButtonContent = new GUIContent(EditorGUIUtility.FindTexture("UnityLogoLarge"), "Pick SceneAsset"); + } } } } \ No newline at end of file From 00a0cccb775b8d499dc92136bb38a810e837910c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Matkowski?= Date: Fri, 9 Jul 2021 20:19:45 +0200 Subject: [PATCH 11/22] Minor refactor changes --- Assets/Editor Toolbox/Editor/Utilities/InspectorUtility.cs | 1 - Assets/Editor Toolbox/Editor/Utilities/ReflectionUtility.cs | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Editor Toolbox/Editor/Utilities/InspectorUtility.cs b/Assets/Editor Toolbox/Editor/Utilities/InspectorUtility.cs index a3fa7a73..36803a2e 100644 --- a/Assets/Editor Toolbox/Editor/Utilities/InspectorUtility.cs +++ b/Assets/Editor Toolbox/Editor/Utilities/InspectorUtility.cs @@ -40,7 +40,6 @@ static InspectorUtility() }; } - private static Editor validationEditor; private static Editor lastCachedEditor; diff --git a/Assets/Editor Toolbox/Editor/Utilities/ReflectionUtility.cs b/Assets/Editor Toolbox/Editor/Utilities/ReflectionUtility.cs index b7861a36..0d3be0b9 100644 --- a/Assets/Editor Toolbox/Editor/Utilities/ReflectionUtility.cs +++ b/Assets/Editor Toolbox/Editor/Utilities/ReflectionUtility.cs @@ -9,6 +9,7 @@ internal static class ReflectionUtility { private readonly static Assembly editorAssembly = typeof(UnityEditor.Editor).Assembly; + /// /// Returns of the searched method within the Editor . /// From 9cb3e216cc80fee5c305b052890b3e54c31ee80a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Matkowski?= Date: Sat, 10 Jul 2021 00:53:38 +0200 Subject: [PATCH 12/22] Fix field width calculations for DirectoryAttributeDrawer and SceneNameAttributeDrawer --- .../DirectoryAttributeDrawer.cs | 79 +++++++++++-------- .../SceneNameAttributeDrawer.cs | 58 ++++++++------ 2 files changed, 80 insertions(+), 57 deletions(-) diff --git a/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/DirectoryAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/DirectoryAttributeDrawer.cs index 009d296d..2c9690e0 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/DirectoryAttributeDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/DirectoryAttributeDrawer.cs @@ -17,12 +17,48 @@ private static bool IsPathValid(string propertyPath, string assetRelativePath) return Directory.Exists(targetPath); } + private Rect DrawWarningMessage(Rect position) + { + position = new Rect(position.x, + position.y, + position.width, Style.boxHeight); + EditorGUI.HelpBox(position, "Provided directory does not exist.", MessageType.Warning); + return position; + } + + private void UseDirectoryPicker(SerializedProperty property, string relativePath) + { + var baseDataPath = Application.dataPath; + var baseOpenPath = Path.GetFileName(baseDataPath); + if (!string.IsNullOrEmpty(relativePath)) + { + baseDataPath = Path.Combine(baseDataPath, relativePath); + baseOpenPath = Path.Combine(baseOpenPath, relativePath); + } + + var selectedPath = EditorUtility.OpenFolderPanel("Pick directory", baseOpenPath, ""); + if (!string.IsNullOrEmpty(selectedPath)) + { + //Unity's API always returns slash + baseDataPath = baseDataPath.Replace('\\', '/'); + selectedPath = selectedPath.Replace(baseDataPath, ""); + selectedPath = selectedPath.Remove(0, 1); + + property.serializedObject.Update(); + property.stringValue = selectedPath; + property.serializedObject.ApplyModifiedProperties(); + } + + //NOTE: we have to exit GUI since the EditorUtility.OpenFolderPanel method will break the layouting system + GUIUtility.ExitGUI(); + } + protected override float GetPropertyHeightSafe(SerializedProperty property, GUIContent label) { //validate property type and serialized path - return IsPathValid(property.stringValue, Attribute.RelativePath) - ? base.GetPropertyHeightSafe(property, label) + return IsPathValid(property.stringValue, Attribute.RelativePath) + ? base.GetPropertyHeightSafe(property, label) : base.GetPropertyHeightSafe(property, label) + Style.boxHeight + Style.spacing * 2; } @@ -31,46 +67,20 @@ protected override void OnGUISafe(Rect position, SerializedProperty property, GU //validate currently serialized path value if (!IsPathValid(property.stringValue, Attribute.RelativePath)) { - var helpBoxRect = new Rect(position.x, - position.y, - position.width, Style.boxHeight); - EditorGUI.HelpBox(helpBoxRect, "Provided directory does not exist.", MessageType.Warning); - position.y += Style.boxHeight + Style.spacing + Style.spacing; + position = DrawWarningMessage(position); + position.yMin = position.yMax + Style.spacing; + position.yMax = position.yMin + Style.rowHeight; } - position.height = Style.rowHeight; position.xMax -= Style.pickerWidth + Style.spacing; EditorGUI.PropertyField(position, property, label); - position.xMin += position.width; position.xMax += Style.pickerWidth + Style.spacing; + position.xMin = position.xMax - Style.pickerWidth; //create additional pick directory button if (GUI.Button(position, Style.pickerContent, EditorStyles.miniButton)) { - var relativePath = Attribute.RelativePath; - var baseDataPath = Application.dataPath; - var baseOpenPath = "Assets"; - if (!string.IsNullOrEmpty(relativePath)) - { - baseDataPath = Path.Combine(baseDataPath, relativePath); - baseOpenPath = Path.Combine(baseOpenPath, relativePath); - } - - var selectedPath = EditorUtility.OpenFolderPanel("Pick directory", baseOpenPath, ""); - if (!string.IsNullOrEmpty(selectedPath)) - { - //Unity's API always returns slash - baseDataPath = baseDataPath.Replace('\\', '/'); - selectedPath = selectedPath.Replace(baseDataPath, ""); - selectedPath = selectedPath.Remove(0, 1); - - property.serializedObject.Update(); - property.stringValue = selectedPath; - property.serializedObject.ApplyModifiedProperties(); - } - - //NOTE: we have to exit GUI since the EditorUtility.OpenFolderPanel method will break the layouting system - GUIUtility.ExitGUI(); + UseDirectoryPicker(property, Attribute.RelativePath); } } @@ -99,7 +109,8 @@ private static class Style static Style() { - pickerContent = new GUIContent(EditorGUIUtility.FindTexture("Folder Icon"), "Pick directory"); + pickerContent = EditorGUIUtility.IconContent("Folder Icon"); + pickerContent.tooltip = "Pick directory"; } } } diff --git a/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/SceneNameAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/SceneNameAttributeDrawer.cs index b8f9f3d4..cb3bfb45 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/SceneNameAttributeDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/SceneNameAttributeDrawer.cs @@ -29,32 +29,18 @@ private static bool SceneExists(string sceneName) return false; } - - protected override float GetPropertyHeightSafe(SerializedProperty property, GUIContent label) + private Rect DrawWarningMessage(Rect position) { - return SceneExists(property.stringValue) - ? base.GetPropertyHeightSafe(property, label) - : base.GetPropertyHeightSafe(property, label) + Style.boxHeight + Style.spacing * 2; + position = new Rect(position.x, + position.y, + position.width, Style.boxHeight); + EditorGUI.HelpBox(position, "Scene does not exist. " + + "Check available Scenes in the Build options.", MessageType.Warning); + return position; } - protected override void OnGUISafe(Rect position, SerializedProperty property, GUIContent label) + private void HandleTargetPicker(Rect position, SerializedProperty property) { - if (!SceneExists(property.stringValue)) - { - var helpBoxRect = new Rect(position.x, - position.y, - position.width, Style.boxHeight); - EditorGUI.HelpBox(helpBoxRect, "Scene does not exist. " + - "Check available Scenes in the Build options.", MessageType.Warning); - position.yMin += Style.boxHeight + Style.spacing * 2; - } - - position.height = Style.rowHeight; - position.xMax -= Style.pickerWidth + Style.spacing; - EditorGUI.PropertyField(position, property, label); - position.xMin += position.width; - position.xMax += Style.pickerWidth + Style.spacing; - var controlId = GUIUtility.GetControlID(FocusType.Keyboard); if (GUI.Button(position, Style.pickerButtonContent, EditorStyles.miniButton)) { @@ -78,6 +64,31 @@ protected override void OnGUISafe(Rect position, SerializedProperty property, GU } + protected override float GetPropertyHeightSafe(SerializedProperty property, GUIContent label) + { + return SceneExists(property.stringValue) + ? base.GetPropertyHeightSafe(property, label) + : base.GetPropertyHeightSafe(property, label) + Style.boxHeight + Style.spacing * 2; + } + + protected override void OnGUISafe(Rect position, SerializedProperty property, GUIContent label) + { + if (!SceneExists(property.stringValue)) + { + position = DrawWarningMessage(position); + position.yMin = position.yMax + Style.spacing; + position.yMax = position.yMin + Style.rowHeight; + } + + position.xMax -= Style.pickerWidth + Style.spacing; + EditorGUI.PropertyField(position, property, label); + position.xMax += Style.pickerWidth + Style.spacing; + position.xMin = position.xMax - Style.pickerWidth; + + HandleTargetPicker(position, property); + } + + public override bool IsPropertyValid(SerializedProperty property) { return property.propertyType == SerializedPropertyType.String; @@ -99,7 +110,8 @@ private static class Style static Style() { - pickerButtonContent = new GUIContent(EditorGUIUtility.FindTexture("UnityLogoLarge"), "Pick SceneAsset"); + pickerButtonContent = EditorGUIUtility.IconContent("SceneAsset Icon"); + pickerButtonContent.tooltip = "Pick Scene"; } } } From 0f57e62afdf1bf29e7c02647264b1cf9580a4d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Matkowski?= Date: Sat, 10 Jul 2021 15:54:37 +0200 Subject: [PATCH 13/22] Add GuiColorAttribute&Drawer --- .../GuiColorAttributeDrawer.cs | 21 +++++++++++++++++ .../GuiColorAttributeDrawer.cs.meta | 11 +++++++++ .../Editor/Utilities/GuiLayoutUtility.cs | 2 +- Assets/Editor Toolbox/EditorSettings.asset | 1 + .../DecoratorAttributes/GuiColorAttribute.cs | 23 +++++++++++++++++++ .../GuiColorAttribute.cs.meta | 11 +++++++++ .../DecoratorAttributes/HighlightAttribute.cs | 7 ++---- 7 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/GuiColorAttributeDrawer.cs create mode 100644 Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/GuiColorAttributeDrawer.cs.meta create mode 100644 Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/GuiColorAttribute.cs create mode 100644 Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/GuiColorAttribute.cs.meta diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/GuiColorAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/GuiColorAttributeDrawer.cs new file mode 100644 index 00000000..cc862888 --- /dev/null +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/GuiColorAttributeDrawer.cs @@ -0,0 +1,21 @@ +using UnityEngine; + +namespace Toolbox.Editor.Drawers +{ + public class GuiColorAttributeDrawer : ToolboxDecoratorDrawer + { + private Color formerGuiColor; + + + protected override void OnGuiBeginSafe(GuiColorAttribute attribute) + { + formerGuiColor = GUI.color; + GUI.color = attribute.Color; + } + + protected override void OnGuiCloseSafe(GuiColorAttribute attribute) + { + GUI.color = formerGuiColor; + } + } +} \ No newline at end of file diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/GuiColorAttributeDrawer.cs.meta b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/GuiColorAttributeDrawer.cs.meta new file mode 100644 index 00000000..d7d9874a --- /dev/null +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/GuiColorAttributeDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d9f38cd1beaa9a044b8ee7e277dafeb3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor Toolbox/Editor/Utilities/GuiLayoutUtility.cs b/Assets/Editor Toolbox/Editor/Utilities/GuiLayoutUtility.cs index e02cb786..5967ba7c 100644 --- a/Assets/Editor Toolbox/Editor/Utilities/GuiLayoutUtility.cs +++ b/Assets/Editor Toolbox/Editor/Utilities/GuiLayoutUtility.cs @@ -16,7 +16,7 @@ public static class GuiLayoutUtility public static void BeginStrechedVertical() { - BeginFixedVertical(new GUIStyle()); + BeginFixedVertical(GUIStyle.none); } public static void BeginFixedVertical(GUIStyle style) diff --git a/Assets/Editor Toolbox/EditorSettings.asset b/Assets/Editor Toolbox/EditorSettings.asset index 0d1e0f7f..de280c5e 100644 --- a/Assets/Editor Toolbox/EditorSettings.asset +++ b/Assets/Editor Toolbox/EditorSettings.asset @@ -57,6 +57,7 @@ MonoBehaviour: - classReference: Toolbox.Editor.Drawers.EndHorizontalAttributeDrawer, Toolbox-Editor - classReference: Toolbox.Editor.Drawers.EndHorizontalGroupAttributeDrawer, Toolbox-Editor - classReference: Toolbox.Editor.Drawers.EndIndentAttributeDrawer, Toolbox-Editor + - classReference: Toolbox.Editor.Drawers.GuiColorAttributeDrawer, Toolbox-Editor - classReference: Toolbox.Editor.Drawers.HelpAttributeDrawer, Toolbox-Editor - classReference: Toolbox.Editor.Drawers.HighlightAttributeDrawer, Toolbox-Editor - classReference: Toolbox.Editor.Drawers.ImageAreaAttributeDrawer, Toolbox-Editor diff --git a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/GuiColorAttribute.cs b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/GuiColorAttribute.cs new file mode 100644 index 00000000..b381f770 --- /dev/null +++ b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/GuiColorAttribute.cs @@ -0,0 +1,23 @@ +using System; + +namespace UnityEngine +{ + /// + /// Changes GUI color of all related controls (other decorators and the property field). + /// + [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)] + public class GuiColorAttribute : ToolboxDecoratorAttribute + { + public GuiColorAttribute(float r, float g, float b) + { + Color = new Color(r, g, b); + } + + public GuiColorAttribute(string hexColor) + { + Color = ColorUtility.TryParseHtmlString(hexColor, out var color) ? color : Color.magenta; + } + + public Color Color { get; private set; } + } +} \ No newline at end of file diff --git a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/GuiColorAttribute.cs.meta b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/GuiColorAttribute.cs.meta new file mode 100644 index 00000000..e7c00d85 --- /dev/null +++ b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/GuiColorAttribute.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 89ad57d8ceb925e4aa22cca5c0554b52 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/HighlightAttribute.cs b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/HighlightAttribute.cs index 22dabef3..2fa1acc4 100644 --- a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/HighlightAttribute.cs +++ b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/HighlightAttribute.cs @@ -12,12 +12,9 @@ public HighlightAttribute(float r, float g, float b) public HighlightAttribute(string hexColor) { - if (ColorUtility.TryParseHtmlString(hexColor, out var color)) - { - Color = color; - } + Color = ColorUtility.TryParseHtmlString(hexColor, out var color) ? color : Color.magenta; } - public Color Color { get; private set; } = Color.white; + public Color Color { get; private set; } } } \ No newline at end of file From e6d97cad9394ef36c685e7adcbf7828a78e50add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Matkowski?= Date: Tue, 13 Jul 2021 22:52:43 +0200 Subject: [PATCH 14/22] Add possibility to draw foldout labels for ReorderableLists --- .../Editor/Internal/ReorderableListBase.cs | 77 +++++++++++++++++-- .../Editor/Internal/ToolboxEditorList.cs | 61 +++++++-------- 2 files changed, 100 insertions(+), 38 deletions(-) diff --git a/Assets/Editor Toolbox/Editor/Internal/ReorderableListBase.cs b/Assets/Editor Toolbox/Editor/Internal/ReorderableListBase.cs index cafdb066..008bd0b8 100644 --- a/Assets/Editor Toolbox/Editor/Internal/ReorderableListBase.cs +++ b/Assets/Editor Toolbox/Editor/Internal/ReorderableListBase.cs @@ -501,7 +501,7 @@ public virtual void DoList() } - #region Methods: Default interaction/draw calls + #region Methods: Default interaction/draw calls/controls /// /// Draws the default Footer. @@ -575,6 +575,33 @@ public virtual void DrawStandardFooterBackground(Rect rect) } } + public virtual void DrawStandardName(Rect rect, GUIContent label, bool useFoldout) + { + if (useFoldout) + { + DrawStandardFoldout(rect, label); + } + else + { + DrawStandardLabel(rect, label); + } + } + + public virtual void DrawStandardLabel(Rect rect, GUIContent label) + { + EditorGUI.LabelField(rect, label, Style.namePropertyStyle); + } + + public virtual void DrawStandardFoldout(Rect rect, GUIContent label) + { + var style = Style.foldoutLabelStyle; + var leftPadding = style.padding.left; + style.CalcMinMaxWidth(label, out var minWidth, out _); + rect.xMin += leftPadding; + rect.xMax -= rect.width - minWidth; + List.isExpanded = EditorGUI.Foldout(rect, List.isExpanded, label, true, style); + } + /// /// Draws the default Header. /// @@ -582,7 +609,7 @@ public virtual void DrawStandardHeader(Rect rect) { var label = EditorGUI.BeginProperty(rect, TitleLabel, List); //display the property label using the preprocessed name - EditorGUI.LabelField(rect, label, Style.namePropertyStyle); + DrawStandardName(rect, label, IsCollapsible); var diff = rect.height - Style.sizePropertyStyle.fixedHeight; //adjust OY position to the middle of the element row @@ -603,8 +630,10 @@ public virtual void DrawStandardHeader(Rect rect) { property.intValue = sizeValue; } + EditorGUI.EndProperty(); } + EditorGUI.EndProperty(); } @@ -685,7 +714,7 @@ public virtual void DrawStandardElementBackground(Rect rect, int index, bool sel /// - /// Index of the currently active element. + /// Index of the currently active (hovered) element. /// public int Index { @@ -716,6 +745,9 @@ public int Count } } + /// + /// Indicates if list should allow dragging elements. + /// public bool Draggable { get; set; @@ -726,11 +758,35 @@ public bool IsDragging get; protected set; } - public virtual bool FixedSize { get; set; } = true; + public bool IsCollapsible + { + get; set; + } + + public bool IsCollapsed + { + get => !List.isExpanded && IsCollapsible; + } - public virtual bool HasHeader { get; set; } = true; + public bool IsEmpty + { + get => Count == 0; + } + + public bool IsPropertyValid + { + get => List != null && List.isArray; + } + + /// + /// Indicates if list should have add/remove controls. + /// + public bool FixedSize { get; set; } + + public bool HasHeader { get; set; } = true; + + public bool HasLabels { get; set; } = true; - public virtual bool HasLabels { get; set; } = true; #if UNITY_2020_1_OR_NEWER public virtual float HeaderHeight { get; set; } = 20.0f; #else @@ -816,6 +872,7 @@ protected static class Style internal static readonly float handleHeight = 7.0f; internal static readonly float dragAreaWidth = 40.0f; internal static readonly float sizeAreaWidth = 19.0f; + internal static readonly float minEmptyHeight = 8.0f; internal static readonly GUIContent sizePropertyContent; internal static readonly GUIContent iconToolbarAddContent; @@ -824,7 +881,9 @@ protected static class Style internal static readonly GUIContent emptyOrInvalidListContent; internal static readonly GUIStyle namePropertyStyle; + internal static readonly GUIStyle foldoutLabelStyle; internal static readonly GUIStyle sizePropertyStyle; + internal static readonly GUIStyle contentGroupStyle; internal static readonly GUIStyle footerButtonStyle; internal static readonly GUIStyle dragHandleButtonStyle; internal static readonly GUIStyle headerBackgroundStyle; @@ -844,6 +903,10 @@ static Style() { alignment = TextAnchor.MiddleLeft }; + foldoutLabelStyle = new GUIStyle(EditorStyles.foldout) + { + alignment = TextAnchor.MiddleLeft + }; sizePropertyStyle = new GUIStyle(EditorStyles.miniTextField) { alignment = TextAnchor.MiddleRight, @@ -853,7 +916,9 @@ static Style() fontSize = 10 #endif }; + contentGroupStyle = new GUIStyle(EditorStyles.inspectorFullWidthMargins); + //built-in styles related to the ReorderableList controls footerButtonStyle = new GUIStyle("RL FooterButton"); dragHandleButtonStyle = new GUIStyle("RL DragHandle"); headerBackgroundStyle = new GUIStyle("RL Header"); diff --git a/Assets/Editor Toolbox/Editor/Internal/ToolboxEditorList.cs b/Assets/Editor Toolbox/Editor/Internal/ToolboxEditorList.cs index 41374ae4..f3978560 100644 --- a/Assets/Editor Toolbox/Editor/Internal/ToolboxEditorList.cs +++ b/Assets/Editor Toolbox/Editor/Internal/ToolboxEditorList.cs @@ -95,9 +95,8 @@ private void DrawElementRow(int index, bool isActive, bool isTarget, bool hasFoc } } - var style = EditorStyles.inspectorFullWidthMargins; //draw the real property in separate vertical group - using (var elementGroup = new EditorGUILayout.VerticalScope(style)) + using (var elementGroup = new EditorGUILayout.VerticalScope(Style.contentGroupStyle)) { var elementRect = elementGroup.rect; //adjust label width to the known dragging area @@ -120,10 +119,9 @@ private void DrawElementRow(int index, bool isActive, bool isTarget, bool hasFoc private void DrawVacantList() { - var style = EditorStyles.inspectorFullWidthMargins; - using (var vacantGroup = new EditorGUILayout.VerticalScope(style)) + using (var verticalGroup = new EditorGUILayout.VerticalScope(Style.contentGroupStyle)) { - var rect = EditorGUILayout.GetControlRect(GUILayout.Height(Style.lineHeight)); + var rect = EditorGUILayout.GetControlRect(GUILayout.Height(Style.minEmptyHeight)); if (drawVacantCallback != null) { drawVacantCallback(rect); @@ -228,43 +226,42 @@ protected override void DoListMiddle(Rect middleRect) //make sure rects array is valid ValidateElementsRects(arraySize); //handle empty or invalid array - if (List == null || List.isArray == false || arraySize == 0) + if (!IsPropertyValid || IsCollapsed || IsEmpty) { DrawVacantList(); + return; } - else - { - DrawEmptySpace(Style.padding); - //if there are elements, we need to draw them - we will do - //this differently depending on if we are dragging or not - for (var i = 0; i < arraySize; i++) - { - //cache related properties - var isActive = (i == Index); - var hasFocus = (i == Index && HasKeyboardFocus()); - var isTarget = (i == lastCoveredIndex && !isActive); - var isEnding = (i == arraySize - 1); - //draw current array element - DrawElementRow(i, isActive, isTarget, hasFocus); + DrawEmptySpace(Style.padding); + //if there are elements, we need to draw them - we will do + //this differently depending on if we are dragging or not + for (var i = 0; i < arraySize; i++) + { + //cache related properties + var isActive = (i == Index); + var hasFocus = (i == Index && HasKeyboardFocus()); + var isTarget = (i == lastCoveredIndex && !isActive); + var isEnding = (i == arraySize - 1); - //draw dragging target gap - if (isTarget) - { - DrawTargetGap(i, Index, GapColor, GapWidth, Style.dragAreaWidth); - } + //draw current array element + DrawElementRow(i, isActive, isTarget, hasFocus); - if (isEnding) - { - continue; - } + //draw dragging element gap + if (isTarget) + { + DrawTargetGap(i, Index, GapColor, GapWidth, Style.dragAreaWidth); + } - //create spacing for elements - DrawEmptySpace(ElementSpacing); + if (isEnding) + { + continue; } - DrawEmptySpace(Style.padding); + //create spacing for elements + DrawEmptySpace(ElementSpacing); } + + DrawEmptySpace(Style.padding); } protected override bool DoListHeader() From f38ff9e7cc3b5eb8ca3ab0676dee731b56f46e8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Matkowski?= Date: Tue, 13 Jul 2021 23:10:06 +0200 Subject: [PATCH 15/22] Minor refactor changes --- Assets/Editor Toolbox/Editor/Internal/ReorderableList.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Editor Toolbox/Editor/Internal/ReorderableList.cs b/Assets/Editor Toolbox/Editor/Internal/ReorderableList.cs index 94b2da63..7882895b 100644 --- a/Assets/Editor Toolbox/Editor/Internal/ReorderableList.cs +++ b/Assets/Editor Toolbox/Editor/Internal/ReorderableList.cs @@ -79,7 +79,7 @@ protected override void DoListMiddle(Rect middleRect) var elementContentRect = itemElementRect; //handle empty or invalid list - if (List == null || List.isArray == false || arraySize == 0) + if (!IsPropertyValid || IsCollapsed || IsEmpty) { //there was no content, so we will draw an empty element itemElementRect.y = middleRect.y; From dcd2e7cdf4c4b21fb3f504629f80cd25a5769e12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Matkowski?= Date: Wed, 14 Jul 2021 22:21:15 +0200 Subject: [PATCH 16/22] Minor refactor changes --- .../RegularAttributes/FormattedNumberAttribute.cs | 2 +- .../Attributes/RegularAttributes/NotNullAttribute.cs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/FormattedNumberAttribute.cs b/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/FormattedNumberAttribute.cs index e68fa3fa..73f16533 100644 --- a/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/FormattedNumberAttribute.cs +++ b/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/FormattedNumberAttribute.cs @@ -26,7 +26,7 @@ public FormattedNumberAttribute(string format = "n") /// /// Indicates number of visible decimals in the text field. - /// Integers will ignore this property. + /// For this property will be always ignored. /// public int DecimalsToShow { get; set; } = 2; } diff --git a/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/NotNullAttribute.cs b/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/NotNullAttribute.cs index 59f9ca1b..122403d4 100644 --- a/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/NotNullAttribute.cs +++ b/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/NotNullAttribute.cs @@ -10,10 +10,8 @@ namespace UnityEngine [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] public class NotNullAttribute : PropertyAttribute { - public NotNullAttribute() - { - Label = "Variable has to be assigned."; - } + public NotNullAttribute() : this("Variable has to be assigned.") + { } public NotNullAttribute(string label) { From 9c685955c91ea0b711982e1118c8440705c94c2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Matkowski?= Date: Wed, 14 Jul 2021 23:33:46 +0200 Subject: [PATCH 17/22] Add 'Foldable' property to the ReorderableList-related attributes --- .../ReorderableListAttributeDrawer.cs | 3 ++- .../ReorderableListExposedAttributeDrawer.cs | 3 ++- .../Editor/Internal/ReorderableList.cs | 8 ++++-- .../Editor/Internal/ReorderableListBase.cs | 27 +++++++++++-------- .../Editor/Internal/ToolboxEditorList.cs | 11 +++++--- .../Editor Toolbox/Editor/ToolboxEditorGui.cs | 24 ++++++++--------- .../ReorderableListAttribute.cs | 17 +++++++++--- Assets/Examples/Scripts/SampleBehaviour2.cs | 2 +- 8 files changed, 60 insertions(+), 35 deletions(-) diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyListDrawers/ReorderableListAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyListDrawers/ReorderableListAttributeDrawer.cs index 40be98ea..6c105f8f 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyListDrawers/ReorderableListAttributeDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyListDrawers/ReorderableListAttributeDrawer.cs @@ -17,7 +17,8 @@ static ReorderableListAttributeDrawer() a.FixedSize, a.Draggable, a.HasHeader, - a.HasLabels); + a.HasLabels, + a.Foldable); }); } diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyListDrawers/ReorderableListExposedAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyListDrawers/ReorderableListExposedAttributeDrawer.cs index 93834b2a..5063f642 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyListDrawers/ReorderableListExposedAttributeDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/PropertyListDrawers/ReorderableListExposedAttributeDrawer.cs @@ -21,7 +21,8 @@ static ReorderableListExposedAttributeDrawer() a.FixedSize, a.Draggable, a.HasHeader, - a.HasLabels); + a.HasLabels, + a.Foldable); //additionaly subscribe callbacks ConnectCallbacks(list, a); return list; diff --git a/Assets/Editor Toolbox/Editor/Internal/ReorderableList.cs b/Assets/Editor Toolbox/Editor/Internal/ReorderableList.cs index 7882895b..dd4e520f 100644 --- a/Assets/Editor Toolbox/Editor/Internal/ReorderableList.cs +++ b/Assets/Editor Toolbox/Editor/Internal/ReorderableList.cs @@ -37,10 +37,14 @@ public ReorderableList(SerializedProperty list, string elementLabel, bool dragga : base(list, elementLabel, draggable, hasHeader, fixedSize) { } - public ReorderableList(SerializedProperty list, string elementLabel, bool draggable, bool hasHeader, bool fixedSize, bool hasLabels) + public ReorderableList(SerializedProperty list, string elementLabel, bool draggable, bool hasHeader, bool fixedSize, bool hasLabels) : base(list, elementLabel, draggable, hasHeader, fixedSize, hasLabels) { } + public ReorderableList(SerializedProperty list, string elementLabel, bool draggable, bool hasHeader, bool fixedSize, bool hasLabels, bool foldable) + : base(list, elementLabel, draggable, hasHeader, fixedSize, hasLabels, foldable) + { } + protected override void DoListMiddle() { @@ -79,7 +83,7 @@ protected override void DoListMiddle(Rect middleRect) var elementContentRect = itemElementRect; //handle empty or invalid list - if (!IsPropertyValid || IsCollapsed || IsEmpty) + if (!IsPropertyValid || !IsExpanded || IsEmpty) { //there was no content, so we will draw an empty element itemElementRect.y = middleRect.y; diff --git a/Assets/Editor Toolbox/Editor/Internal/ReorderableListBase.cs b/Assets/Editor Toolbox/Editor/Internal/ReorderableListBase.cs index 008bd0b8..5117d856 100644 --- a/Assets/Editor Toolbox/Editor/Internal/ReorderableListBase.cs +++ b/Assets/Editor Toolbox/Editor/Internal/ReorderableListBase.cs @@ -74,6 +74,10 @@ public ReorderableListBase(SerializedProperty list, string elementLabel, bool dr { } public ReorderableListBase(SerializedProperty list, string elementLabel, bool draggable, bool hasHeader, bool fixedSize, bool hasLabels) + : this(list, elementLabel, draggable, hasHeader, fixedSize, hasLabels, false) + { } + + public ReorderableListBase(SerializedProperty list, string elementLabel, bool draggable, bool hasHeader, bool fixedSize, bool hasLabels, bool foldable) { //validate parameters if (list == null || list.isArray == false) @@ -88,10 +92,10 @@ public ReorderableListBase(SerializedProperty list, string elementLabel, bool dr HasHeader = hasHeader; FixedSize = fixedSize; HasLabels = hasLabels; - //set other properties ElementLabel = elementLabel; + Foldable = foldable; - //ser serialized data + //set serialized data List = list; Size = list.FindPropertyRelative("Array.size"); @@ -575,9 +579,9 @@ public virtual void DrawStandardFooterBackground(Rect rect) } } - public virtual void DrawStandardName(Rect rect, GUIContent label, bool useFoldout) + public virtual void DrawStandardName(Rect rect, GUIContent label, bool foldable) { - if (useFoldout) + if (foldable) { DrawStandardFoldout(rect, label); } @@ -609,13 +613,11 @@ public virtual void DrawStandardHeader(Rect rect) { var label = EditorGUI.BeginProperty(rect, TitleLabel, List); //display the property label using the preprocessed name - DrawStandardName(rect, label, IsCollapsible); + DrawStandardName(rect, label, Foldable); var diff = rect.height - Style.sizePropertyStyle.fixedHeight; - //adjust OY position to the middle of the element row rect.yMin += diff / 2; rect.yMax -= diff / 2; - //adjust OX position and width for the size property rect.xMin = rect.xMax - Style.sizeAreaWidth; using (new EditorGUI.DisabledScope(FixedSize)) @@ -624,7 +626,7 @@ public virtual void DrawStandardHeader(Rect rect) EditorGUI.BeginProperty(rect, Style.sizePropertyContent, property); EditorGUI.BeginChangeCheck(); - //cache a delayed size value using the delayed int field + //cache the size value using the delayed int field var sizeValue = Mathf.Max(EditorGUI.DelayedIntField(rect, property.intValue, Style.sizePropertyStyle), 0); if (EditorGUI.EndChangeCheck()) { @@ -758,14 +760,17 @@ public bool IsDragging get; protected set; } - public bool IsCollapsible + /// + /// Indicates if list should be able to fold itself. + /// + public bool Foldable { get; set; } - public bool IsCollapsed + public bool IsExpanded { - get => !List.isExpanded && IsCollapsible; + get => List.isExpanded || !Foldable; } public bool IsEmpty diff --git a/Assets/Editor Toolbox/Editor/Internal/ToolboxEditorList.cs b/Assets/Editor Toolbox/Editor/Internal/ToolboxEditorList.cs index f3978560..a6d79b45 100644 --- a/Assets/Editor Toolbox/Editor/Internal/ToolboxEditorList.cs +++ b/Assets/Editor Toolbox/Editor/Internal/ToolboxEditorList.cs @@ -39,6 +39,10 @@ public ToolboxEditorList(SerializedProperty list, string elementLabel, bool drag : base(list, elementLabel, draggable, hasHeader, fixedSize, hasLabels) { } + public ToolboxEditorList(SerializedProperty list, string elementLabel, bool draggable, bool hasHeader, bool fixedSize, bool hasLabels, bool foldable) + : base(list, elementLabel, draggable, hasHeader, fixedSize, hasLabels, foldable) + { } + private void ValidateElementsRects(int arraySize) { @@ -119,7 +123,7 @@ private void DrawElementRow(int index, bool isActive, bool isTarget, bool hasFoc private void DrawVacantList() { - using (var verticalGroup = new EditorGUILayout.VerticalScope(Style.contentGroupStyle)) + using (var emptyListGroup = new EditorGUILayout.VerticalScope(Style.contentGroupStyle)) { var rect = EditorGUILayout.GetControlRect(GUILayout.Height(Style.minEmptyHeight)); if (drawVacantCallback != null) @@ -226,7 +230,7 @@ protected override void DoListMiddle(Rect middleRect) //make sure rects array is valid ValidateElementsRects(arraySize); //handle empty or invalid array - if (!IsPropertyValid || IsCollapsed || IsEmpty) + if (!IsPropertyValid || !IsExpanded || IsEmpty) { DrawVacantList(); return; @@ -348,7 +352,8 @@ protected override int GetCoveredElementIndex(Vector2 mousePosition) public override void DrawStandardElement(Rect rect, int index, bool selected, bool focused, bool draggable) { var element = List.GetArrayElementAtIndex(index); - ToolboxEditorGui.DrawToolboxProperty(element, GetElementContent(element, index)); + var content = GetElementContent(element, index); + ToolboxEditorGui.DrawToolboxProperty(element, content); } #endregion diff --git a/Assets/Editor Toolbox/Editor/ToolboxEditorGui.cs b/Assets/Editor Toolbox/Editor/ToolboxEditorGui.cs index 977f1d2b..ad3f75c2 100644 --- a/Assets/Editor Toolbox/Editor/ToolboxEditorGui.cs +++ b/Assets/Editor Toolbox/Editor/ToolboxEditorGui.cs @@ -261,18 +261,18 @@ public static partial class ToolboxEditorGui /// /// Creates using standard background. /// - public static ReorderableListBase CreateRoundList(SerializedProperty property, string elementLabel = null, bool fixedSize = false, bool draggable = true, bool hasHeader = true, bool hasLabels = true) + public static ReorderableListBase CreateRoundList(SerializedProperty property, string elementLabel = null, bool fixedSize = false, bool draggable = true, bool hasHeader = true, bool hasLabels = true, bool foldable = false) { - return new ToolboxEditorList(property, elementLabel, draggable, hasHeader, fixedSize, hasLabels); + return new ToolboxEditorList(property, elementLabel, draggable, hasHeader, fixedSize, hasLabels, foldable); } /// /// Creates using a non-standard (boxed style) background. /// - public static ReorderableListBase CreateBoxedList(SerializedProperty property, string elementLabel = null, bool fixedSize = false, bool draggable = true, bool hasHeader = true, bool hasLabels = true) + public static ReorderableListBase CreateBoxedList(SerializedProperty property, string elementLabel = null, bool fixedSize = false, bool draggable = true, bool hasHeader = true, bool hasLabels = true, bool foldable = false) { var backgroundStyle = new GUIStyle("box"); - return new ToolboxEditorList(property, elementLabel, draggable, hasHeader, fixedSize, hasLabels) + return new ToolboxEditorList(property, elementLabel, draggable, hasHeader, fixedSize, hasLabels, foldable) { drawHeaderBackgroundCallback = (Rect rect) => { @@ -308,9 +308,9 @@ public static ReorderableListBase CreateBoxedList(SerializedProperty property, s /// /// Creates using a non-standard (lined style) background. /// - public static ReorderableListBase CreateLinedList(SerializedProperty property, string elementLabel = null, bool fixedSize = false, bool draggable = true, bool hasHeader = true, bool hasLabels = true) + public static ReorderableListBase CreateLinedList(SerializedProperty property, string elementLabel = null, bool fixedSize = false, bool draggable = true, bool hasHeader = true, bool hasLabels = true, bool foldable = false) { - return new ToolboxEditorList(property, elementLabel, draggable, hasHeader, fixedSize, hasLabels) + return new ToolboxEditorList(property, elementLabel, draggable, hasHeader, fixedSize, hasLabels, foldable) { drawHeaderBackgroundCallback = (Rect rect) => { @@ -339,9 +339,9 @@ public static ReorderableListBase CreateLinedList(SerializedProperty property, s /// /// Creates without any additional background. /// - public static ReorderableListBase CreateClearList(SerializedProperty property, string elementLabel = null, bool fixedSize = false, bool draggable = true, bool hasHeader = true, bool hasLabels = true) + public static ReorderableListBase CreateClearList(SerializedProperty property, string elementLabel = null, bool fixedSize = false, bool draggable = true, bool hasHeader = true, bool hasLabels = true, bool foldable = false) { - return new ToolboxEditorList(property, elementLabel, draggable, hasHeader, fixedSize, hasLabels) + return new ToolboxEditorList(property, elementLabel, draggable, hasHeader, fixedSize, hasLabels, foldable) { drawHeaderBackgroundCallback = (Rect rect) => { }, @@ -360,13 +360,13 @@ public static ReorderableListBase CreateClearList(SerializedProperty property, s /// /// Creates using provided type. /// - public static ReorderableListBase CreateList(SerializedProperty property, ListStyle style, string elementLabel = null, bool fixedSize = false, bool draggable = true, bool hasHeader = true, bool hasLabels = true) + public static ReorderableListBase CreateList(SerializedProperty property, ListStyle style, string elementLabel = null, bool fixedSize = false, bool draggable = true, bool hasHeader = true, bool hasLabels = true, bool foldable = false) { switch (style) { - case ListStyle.Boxed: return CreateBoxedList(property, elementLabel, fixedSize, draggable, hasHeader, hasLabels); - case ListStyle.Lined: return CreateLinedList(property, elementLabel, fixedSize, draggable, hasHeader, hasLabels); - case ListStyle.Round: return CreateRoundList(property, elementLabel, fixedSize, draggable, hasHeader, hasLabels); + case ListStyle.Boxed: return CreateBoxedList(property, elementLabel, fixedSize, draggable, hasHeader, hasLabels, foldable); + case ListStyle.Lined: return CreateLinedList(property, elementLabel, fixedSize, draggable, hasHeader, hasLabels, foldable); + case ListStyle.Round: return CreateRoundList(property, elementLabel, fixedSize, draggable, hasHeader, hasLabels, foldable); default: return null; } } diff --git a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/PropertyListAttributes/ReorderableListAttribute.cs b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/PropertyListAttributes/ReorderableListAttribute.cs index 076edcef..b0aeabae 100644 --- a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/PropertyListAttributes/ReorderableListAttribute.cs +++ b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/PropertyListAttributes/ReorderableListAttribute.cs @@ -18,14 +18,23 @@ public ReorderableListAttribute(ListStyle style = ListStyle.Round, string elemen ElementLabel = elementLabel; } - public bool HasHeader { get; set; } = true; - public bool HasLabels { get; set; } = true; public bool Draggable { get; private set; } public bool FixedSize { get; private set; } - public ListStyle ListStyle { get; private set; } - public string ElementLabel { get; private set; } + + /// + /// Indicates whether list should be allowed to fold in and out. + /// + public bool Foldable { get; set; } + /// + /// Indicates whether list should have a label above elements. + /// + public bool HasHeader { get; set; } = true; + /// + /// Indicates whether each element should have an additional label. + /// + public bool HasLabels { get; set; } = true; } public enum ListStyle diff --git a/Assets/Examples/Scripts/SampleBehaviour2.cs b/Assets/Examples/Scripts/SampleBehaviour2.cs index bcbe00d9..3b909b10 100644 --- a/Assets/Examples/Scripts/SampleBehaviour2.cs +++ b/Assets/Examples/Scripts/SampleBehaviour2.cs @@ -167,7 +167,7 @@ public int GetValue() [Label("15", skinStyle: SkinStyle.Box)] [BeginHorizontalGroup(label: "Horizontal Group")] - [ReorderableList, InLineEditor] + [ReorderableList(Foldable = true), InLineEditor] public GameObject[] gameObjects; [SpaceArea] [EndHorizontalGroup] From 21438324aaa87df057644389f8b2fdf8044d6ea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Matkowski?= Date: Thu, 15 Jul 2021 19:59:05 +0200 Subject: [PATCH 18/22] Fix visibility of the foldout-based properties in the horizontal group --- .../BeginHorizontalGroupAttributeDrawer.cs | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/BeginHorizontalGroupAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/BeginHorizontalGroupAttributeDrawer.cs index 4b68a047..a64b86e3 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/BeginHorizontalGroupAttributeDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/ToolboxDrawers/DecoratorDrawers/BeginHorizontalGroupAttributeDrawer.cs @@ -24,16 +24,11 @@ private void HandleScrollView(float fixedHeight) var controlId = storage.GetControlId(); var oldScroll = storage.ReturnItem(controlId, Vector2.zero); var newScroll = fixedHeight > 0.0f - ? EditorGUILayout.BeginScrollView(oldScroll, GUILayout.Height(fixedHeight)) - : EditorGUILayout.BeginScrollView(oldScroll); + ? EditorGUILayout.BeginScrollView(oldScroll, Style.scrollViewGroupStyle, GUILayout.Height(fixedHeight)) + : EditorGUILayout.BeginScrollView(oldScroll, Style.scrollViewGroupStyle); storage.AppendItem(controlId, newScroll); } - private void ApplyIndentLevel() - { - GUILayout.Space(Style.extraIndentLevel); - } - protected override void OnGuiBeginSafe(BeginHorizontalGroupAttribute attribute) { @@ -50,18 +45,13 @@ protected override void OnGuiBeginSafe(BeginHorizontalGroupAttribute attribute) HandleScrollView(fixedHeight); ToolboxLayoutHelper.BeginHorizontal(); - ApplyIndentLevel(); } private static class Style { - /// - /// Additional indent applied to keep foldout-based labels within the group. - /// - internal static readonly float extraIndentLevel = 8.0f; - internal static readonly GUIStyle groupBackgroundStyle; + internal static readonly GUIStyle scrollViewGroupStyle; static Style() { @@ -73,6 +63,12 @@ static Style() { padding = new RectOffset(13, 12, 5, 5) }; + + //NOTE: we need to add the right padding to keep foldout-based properties fully visible + scrollViewGroupStyle = new GUIStyle("scrollView") + { + padding = new RectOffset(13, 8, 2, 2) + }; } } } From 3c7fa6385dba1ccfc14d396899afbb5dec192a49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Matkowski?= Date: Sun, 18 Jul 2021 20:31:26 +0200 Subject: [PATCH 19/22] Minor refactor changes --- .../RegularDrawers/ClampAttributeDrawer.cs | 20 +++++--- .../LabelByChildAttributeDrawer.cs | 4 +- .../ProgressBarAttributeDrawer.cs | 15 +++--- .../AssetPreviewAttribute.cs | 6 +-- .../RegularAttributes/ProgressBarAttribute.cs | 23 ++++----- .../TypeConstraintAttribute.cs | 50 +++++++++---------- .../DecoratorAttributes/LabelAttribute.cs | 11 ++-- .../DecoratorAttributes/SpaceAreaAttribute.cs | 2 +- 8 files changed, 68 insertions(+), 63 deletions(-) diff --git a/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/ClampAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/ClampAttributeDrawer.cs index 2f85587b..6268c64b 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/ClampAttributeDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/ClampAttributeDrawer.cs @@ -15,17 +15,25 @@ protected override void OnGUISafe(Rect position, SerializedProperty property, GU { var minValue = Attribute.MinValue; var maxValue = Attribute.MaxValue; - - if (property.propertyType == SerializedPropertyType.Float) + if (property.hasMultipleDifferentValues) { - property.floatValue = Mathf.Clamp(property.floatValue, minValue, maxValue); + EditorGUI.PropertyField(position, property, label); + return; } - else + + switch (property.propertyType) { - property.intValue = Mathf.Clamp(property.intValue, (int)minValue, (int)maxValue); + case SerializedPropertyType.Float: + property.floatValue = Mathf.Clamp(property.floatValue, minValue, maxValue); + break; + case SerializedPropertyType.Integer: + property.intValue = (int)Mathf.Clamp(property.intValue, minValue, maxValue); + break; + default: + break; } - EditorGUI.PropertyField(position, property, label, property.isExpanded); + EditorGUI.PropertyField(position, property, label); } diff --git a/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/LabelByChildAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/LabelByChildAttributeDrawer.cs index 274d81b9..73bdaf37 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/LabelByChildAttributeDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/LabelByChildAttributeDrawer.cs @@ -88,12 +88,12 @@ protected override void OnGUISafe(Rect position, SerializedProperty property, GU //validate availability of the child property if (childProperty != null) { - //set new label if found (unknown values will be ignored) + //set new label if found (unknown types will be ignored) label = GetLabelByValue(childProperty, label); } else { - ToolboxEditorLog.AttributeUsageWarning(attribute, property, propertyName + " does not exists."); + ToolboxEditorLog.AttributeUsageWarning(attribute, property, string.Format("{0} does not exists.", propertyName)); } EditorGUI.PropertyField(position, property, label, property.isExpanded); diff --git a/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/ProgressBarAttributeDrawer.cs b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/ProgressBarAttributeDrawer.cs index c5a5b4ee..70db2aab 100644 --- a/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/ProgressBarAttributeDrawer.cs +++ b/Assets/Editor Toolbox/Editor/Drawers/RegularDrawers/ProgressBarAttributeDrawer.cs @@ -14,18 +14,21 @@ protected override float GetPropertyHeightSafe(SerializedProperty property, GUIC protected override void OnGUISafe(Rect position, SerializedProperty property, GUIContent label) { var attribute = Attribute; - //determine the real value of the property - var value = property.propertyType == SerializedPropertyType.Integer ? property.intValue : property.floatValue; + var value = property.propertyType == SerializedPropertyType.Integer + ? property.intValue + : property.floatValue; - var color = attribute.GetBarColor(); + var fillLabel = attribute.Name; + var fillColor = attribute.Color; var minValue = attribute.MinValue; var maxValue = attribute.MaxValue; //set the value text label (add name if needed) var valueText = property.hasMultipleDifferentValues ? "-" : value.ToString(); - var labelText = !string.IsNullOrEmpty(attribute.Name) - ? attribute.Name + " " + valueText + "|" + maxValue : valueText + "|" + maxValue; + var labelText = !string.IsNullOrEmpty(fillLabel) + ? string.Format("{0} {1}|{2}", fillLabel, valueText, maxValue) + : string.Format("{0}|{1}", valueText, maxValue); //clamp current value between min and max values value = Mathf.Clamp(value, minValue, maxValue); @@ -39,7 +42,7 @@ protected override void OnGUISafe(Rect position, SerializedProperty property, GU //draw the background and fill colors EditorGUI.DrawRect(position, Style.backgroundColor); - EditorGUI.DrawRect(fillRect, color); + EditorGUI.DrawRect(fillRect, fillColor); //adjust rect for the shadow label var diff = Style.barHeight - Style.rowHeight; diff --git a/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/AssetPreviewAttribute.cs b/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/AssetPreviewAttribute.cs index 5806142d..163e2d37 100644 --- a/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/AssetPreviewAttribute.cs +++ b/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/AssetPreviewAttribute.cs @@ -12,15 +12,15 @@ public class AssetPreviewAttribute : PropertyAttribute { public AssetPreviewAttribute(float width = 64, float height = 64, bool useLabel = true) { - Height = height; Width = width; + Height = height; UseLabel = useLabel; } - public float Height { get; private set; } - public float Width { get; private set; } + public float Height { get; private set; } + public bool UseLabel { get; private set; } } } \ No newline at end of file diff --git a/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/ProgressBarAttribute.cs b/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/ProgressBarAttribute.cs index 5814abac..8f467dfa 100644 --- a/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/ProgressBarAttribute.cs +++ b/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/ProgressBarAttribute.cs @@ -18,24 +18,19 @@ public ProgressBarAttribute(string name = "", float minValue = 0, float maxValue MaxValue = Mathf.Max(maxValue, minValue); } - public Color GetBarColor() - { - if (ColorUtility.TryParseHtmlString(HexColor, out var color)) - { - return color; - } - else - { - return new Color(0.28f, 0.38f, 0.88f); - } - } - public string Name { get; private set; } - public string HexColor { get; set; } - public float MinValue { get; private set; } public float MaxValue { get; private set; } + + public Color Color + { + get => ColorUtility.TryParseHtmlString(HexColor, out var color) + ? color + : new Color(0.28f, 0.38f, 0.88f); + } + + public string HexColor { get; set; } } } \ No newline at end of file diff --git a/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/TypeConstraintAttribute.cs b/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/TypeConstraintAttribute.cs index f214bb04..80ac3717 100644 --- a/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/TypeConstraintAttribute.cs +++ b/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/TypeConstraintAttribute.cs @@ -6,31 +6,6 @@ namespace UnityEngine { - /// - /// Indicates how selectable classes should be collated in drop-down menu. - /// - public enum ClassGrouping - { - /// - /// No grouping, just show type names in a list; for instance, "Some.Nested.Namespace.SpecialClass". - /// - None, - /// - /// Group classes by namespace and show foldout menus for nested namespaces; for - /// instance, "Some > Nested > Namespace > SpecialClass". - /// - ByNamespace, - /// - /// Group classes by namespace; for instance, "Some.Nested.Namespace > SpecialClass". - /// - ByNamespaceFlat, - /// - /// Group classes in the same way as Unity does for its component menu. This - /// grouping method must only be used for types. - /// - ByAddComponentMenu, - } - /// /// Allows to pick proper type using popup control. /// @@ -205,4 +180,29 @@ public override bool IsConstraintSatisfied(Type type) return false; } } + + /// + /// Indicates how selectable classes should be collated in drop-down menu. + /// + public enum ClassGrouping + { + /// + /// No grouping, just show type names in a list; for instance, "Some.Nested.Namespace.SpecialClass". + /// + None, + /// + /// Group classes by namespace and show foldout menus for nested namespaces; for + /// instance, "Some > Nested > Namespace > SpecialClass". + /// + ByNamespace, + /// + /// Group classes by namespace; for instance, "Some.Nested.Namespace > SpecialClass". + /// + ByNamespaceFlat, + /// + /// Group classes in the same way as Unity does for its component menu. This + /// grouping method must only be used for types. + /// + ByAddComponentMenu, + } } \ No newline at end of file diff --git a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/LabelAttribute.cs b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/LabelAttribute.cs index 62d8b9bc..478e3e8b 100644 --- a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/LabelAttribute.cs +++ b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/LabelAttribute.cs @@ -17,22 +17,21 @@ public LabelAttribute(string label, FontStyle fontStyle = FontStyle.Bold, SkinSt public string Label { get; private set; } - /// - /// Name of the built-in icon that should be placed into the label. - /// - public string Asset { get; set; } - public FontStyle FontStyle { get; private set; } public SkinStyle SkinStyle { get; private set; } public TextAnchor Alignment { get; set; } = TextAnchor.MiddleLeft; + /// + /// Name of the built-in icon that should be placed into the label. + /// + public string Asset { get; set; } + /// /// Additional space to apply before the label field. /// public float SpaceBefore { get; set; } = 5.0f; - /// /// Additional space to apply after the label field. /// diff --git a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/SpaceAreaAttribute.cs b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/SpaceAreaAttribute.cs index cdfa1733..7b7362f8 100644 --- a/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/SpaceAreaAttribute.cs +++ b/Assets/Editor Toolbox/Scripts/Attributes/ToolboxAttributes/DecoratorAttributes/SpaceAreaAttribute.cs @@ -4,7 +4,7 @@ namespace UnityEngine { /// /// Extended version of the built-in . - /// Allows creating space before and after serialized field. + /// Creates additional space before and after serialized field. /// [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)] public class SpaceAreaAttribute : ToolboxDecoratorAttribute From a790f5ee9fcdddb8bebcb67e1feb6a5ac48053bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Matkowski?= Date: Mon, 19 Jul 2021 20:44:48 +0200 Subject: [PATCH 20/22] Update documentation --- Assets/Editor Toolbox/CHANGELOG.md | 8 ++++++++ Assets/Editor Toolbox/README.md | 2 +- Assets/Editor Toolbox/package.json | 2 +- README.md | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Assets/Editor Toolbox/CHANGELOG.md b/Assets/Editor Toolbox/CHANGELOG.md index f90251c6..bdf873e9 100644 --- a/Assets/Editor Toolbox/CHANGELOG.md +++ b/Assets/Editor Toolbox/CHANGELOG.md @@ -1,3 +1,11 @@ +## 0.8.15 [19.07.2021] + +### Added: +- FormattedNumberAttribute +- SceneAsset picker for the SceneNameAttribute +- Optional foldout for the ReorderableList and related attributes +- GuiColorAttribute + ## 0.8.13 [04.07.2021] ### Added: diff --git a/Assets/Editor Toolbox/README.md b/Assets/Editor Toolbox/README.md index d0b0ee0e..6d254dff 100644 --- a/Assets/Editor Toolbox/README.md +++ b/Assets/Editor Toolbox/README.md @@ -466,7 +466,7 @@ public Canvas[] vars1; ``` ![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/list4.png) ```csharp -[ReorderableList(ListStyle.Lined, "Item")] +[ReorderableList(ListStyle.Lined, "Item", Foldable = false)] public List linedStyleList; ``` ![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/list1.png) diff --git a/Assets/Editor Toolbox/package.json b/Assets/Editor Toolbox/package.json index 114ca648..db2e8001 100644 --- a/Assets/Editor Toolbox/package.json +++ b/Assets/Editor Toolbox/package.json @@ -1,7 +1,7 @@ { "name": "com.arimger.editor-toolbox", "displayName": "Editor Toolbox", - "version": "0.8.13", + "version": "0.8.15", "unity": "2018.1", "description": "Tools, custom attributes, drawers, hierarchy overlay, and other extensions for the Unity Editor.", "keywords": [ diff --git a/README.md b/README.md index d0b0ee0e..6d254dff 100644 --- a/README.md +++ b/README.md @@ -466,7 +466,7 @@ public Canvas[] vars1; ``` ![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/list4.png) ```csharp -[ReorderableList(ListStyle.Lined, "Item")] +[ReorderableList(ListStyle.Lined, "Item", Foldable = false)] public List linedStyleList; ``` ![inspector](https://github.com/arimger/Unity-Editor-Toolbox/blob/develop/Docs/list1.png) From 532bc8560a692e4d7ab396aceb2e68bffc2ee4c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Matkowski?= Date: Mon, 19 Jul 2021 20:51:28 +0200 Subject: [PATCH 21/22] Remove obsolete attributes --- .../RegularAttributes/IndentAttribute.cs | 26 ------------------- .../RegularAttributes/IndentAttribute.cs.meta | 11 -------- .../RegularAttributes/SeparatorAttribute.cs | 21 --------------- .../SeparatorAttribute.cs.meta | 11 -------- 4 files changed, 69 deletions(-) delete mode 100644 Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/IndentAttribute.cs delete mode 100644 Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/IndentAttribute.cs.meta delete mode 100644 Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/SeparatorAttribute.cs delete mode 100644 Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/SeparatorAttribute.cs.meta diff --git a/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/IndentAttribute.cs b/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/IndentAttribute.cs deleted file mode 100644 index 65bb6edc..00000000 --- a/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/IndentAttribute.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -namespace UnityEngine -{ - /// - /// Creates indent scope. - /// - /// Supported types: all. - /// - [Obsolete("Use IndentAreaAttribute instead.")] - [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] - public class IndentAttribute : PropertyAttribute - { - public IndentAttribute() - { - IndentLevelChange = 1; - } - - public IndentAttribute(int indentLevelChange) - { - IndentLevelChange = indentLevelChange; - } - - public int IndentLevelChange { get; private set; } - } -} \ No newline at end of file diff --git a/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/IndentAttribute.cs.meta b/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/IndentAttribute.cs.meta deleted file mode 100644 index 193b5690..00000000 --- a/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/IndentAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 965992a56fe4ca748b2294ac72e058f2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/SeparatorAttribute.cs b/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/SeparatorAttribute.cs deleted file mode 100644 index 89f41776..00000000 --- a/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/SeparatorAttribute.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -namespace UnityEngine -{ - [Obsolete("Use LineAttribute instead.")] - [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)] - public class SeparatorAttribute : PropertyAttribute - { - public SeparatorAttribute(float thickness = 0.75f, float padding = 6.0f) - { - //validate the thickness property - Thickness = Mathf.Max(thickness, 0); - //validate the padding property - Padding = Mathf.Max(padding, 0); - } - - public float Thickness { get; private set; } - - public float Padding { get; private set; } - } -} \ No newline at end of file diff --git a/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/SeparatorAttribute.cs.meta b/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/SeparatorAttribute.cs.meta deleted file mode 100644 index cbb2d708..00000000 --- a/Assets/Editor Toolbox/Scripts/Attributes/RegularAttributes/SeparatorAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 190bce7ba8157df44aff01a1c51ae258 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: From 074d5e2d75ee678862cdf025fd69bde02897064b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Matkowski?= Date: Mon, 19 Jul 2021 20:55:01 +0200 Subject: [PATCH 22/22] Update package info --- Assets/Editor Toolbox/CHANGELOG.md | 7 ++++++- Assets/Editor Toolbox/package.json | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Assets/Editor Toolbox/CHANGELOG.md b/Assets/Editor Toolbox/CHANGELOG.md index bdf873e9..332809d8 100644 --- a/Assets/Editor Toolbox/CHANGELOG.md +++ b/Assets/Editor Toolbox/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.8.15 [19.07.2021] +## 0.9.0 [19.07.2021] ### Added: - FormattedNumberAttribute @@ -6,6 +6,11 @@ - Optional foldout for the ReorderableList and related attributes - GuiColorAttribute +### Changed: + +- Remove obsolete attributes +- Rename ToolboxCompositionAttribute class to ToolboxArchetypeAttribute + ## 0.8.13 [04.07.2021] ### Added: diff --git a/Assets/Editor Toolbox/package.json b/Assets/Editor Toolbox/package.json index db2e8001..a6f276a9 100644 --- a/Assets/Editor Toolbox/package.json +++ b/Assets/Editor Toolbox/package.json @@ -1,7 +1,7 @@ { "name": "com.arimger.editor-toolbox", "displayName": "Editor Toolbox", - "version": "0.8.15", + "version": "0.9.0", "unity": "2018.1", "description": "Tools, custom attributes, drawers, hierarchy overlay, and other extensions for the Unity Editor.", "keywords": [