Added lots of examples for editor customization

This commit is contained in:
2026-06-23 18:33:11 +02:00
parent bbb7062c5b
commit 0512201ce0
58 changed files with 920 additions and 116 deletions
@@ -1,5 +1,142 @@
%YAML 1.1 %YAML 1.1
%TAG !u! tag:unity3d.com,2011: %TAG !u! tag:unity3d.com,2011:
--- !u!1 &269854784225261030
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 755255642672769916}
- component: {fileID: 2228697218851437297}
- component: {fileID: 3065416413902700698}
m_Layer: 5
m_Name: DeadMessage
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &755255642672769916
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 269854784225261030}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5969081416407912556}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: -20, y: -20}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2228697218851437297
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 269854784225261030}
m_CullTransparentMesh: 1
--- !u!114 &3065416413902700698
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 269854784225261030}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.TextMeshPro::TMPro.TextMeshProUGUI
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Dead
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 31.3
m_fontSizeBase: 36
m_fontWeight: 400
m_enableAutoSizing: 1
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 17
m_HorizontalAlignment: 2
m_VerticalAlignment: 8192
m_textAlignment: 65535
m_characterSpacing: 0
m_characterHorizontalScale: 1
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_TextWrappingMode: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 0
m_ActiveFontFeatures: 6e72656b
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_EmojiFallbackSupport: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &828612461749225481 --- !u!1 &828612461749225481
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -31,6 +168,7 @@ RectTransform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 8398907280277716531} - {fileID: 8398907280277716531}
- {fileID: 755255642672769916}
m_Father: {fileID: 7072266447349178485} m_Father: {fileID: 7072266447349178485}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0} m_AnchorMin: {x: 1, y: 0}
@@ -278,14 +416,14 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} m_Sprite: {fileID: 21300000, guid: e3cc3bf28e4b3480d96788a24c343552, type: 3}
m_Type: 3 m_Type: 3
m_PreserveAspect: 0 m_PreserveAspect: 0
m_FillCenter: 1 m_FillCenter: 1
m_FillMethod: 0 m_FillMethod: 0
m_FillAmount: 1 m_FillAmount: 1
m_FillClockwise: 1 m_FillClockwise: 1
m_FillOrigin: 1 m_FillOrigin: 0
m_UseSpriteMesh: 0 m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1 m_PixelsPerUnitMultiplier: 1
--- !u!1 &7725325710485131526 --- !u!1 &7725325710485131526
@@ -299,6 +437,7 @@ GameObject:
- component: {fileID: 7072266447349178485} - component: {fileID: 7072266447349178485}
- component: {fileID: 4769054629970349065} - component: {fileID: 4769054629970349065}
- component: {fileID: 5934645046861820108} - component: {fileID: 5934645046861820108}
- component: {fileID: 2306433496064254094}
m_Layer: 5 m_Layer: 5
m_Name: HealthBar m_Name: HealthBar
m_TagString: Untagged m_TagString: Untagged
@@ -365,3 +504,20 @@ MonoBehaviour:
m_FillOrigin: 0 m_FillOrigin: 0
m_UseSpriteMesh: 0 m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1 m_PixelsPerUnitMultiplier: 1
--- !u!114 &2306433496064254094
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7725325710485131526}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7d9616fe18084f1bb99a58e30eea20e1, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::UI.HealthBar
eventBroker: {fileID: 11400000, guid: d3d201ac03d9744bc85390aa5b74aef5, type: 2}
maxHealth: {fileID: 11400000, guid: b61e2bd6ca6d247fb8577ae9c094f1ae, type: 2}
currentHealth: {fileID: 11400000, guid: 0b05fcf292ed04876a6376d1ef94f0da, type: 2}
fillingImage: {fileID: 2810982769414486938}
deadMessageText: {fileID: 3065416413902700698}
@@ -153,7 +153,19 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: af490b7ae815401291d83fe0b6e6a4b7, type: 3} m_Script: {fileID: 11500000, guid: af490b7ae815401291d83fe0b6e6a4b7, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: Assembly-CSharp::DefaultNamespace.PlayerController m_EditorClassIdentifier: Assembly-CSharp::DefaultNamespace.PlayerController
eventBroker: {fileID: 11400000, guid: d3d201ac03d9744bc85390aa5b74aef5, type: 2}
speed: 5 speed: 5
rotationSpeed: 60 rotationSpeed: 60
maxHealth: 100 maxHealth: {fileID: 11400000, guid: b61e2bd6ca6d247fb8577ae9c094f1ae, type: 2}
healthBarFillingImage: {fileID: 0} currentHealth: {fileID: 11400000, guid: 0b05fcf292ed04876a6376d1ef94f0da, type: 2}
characterAttributes: {fileID: 11400000, guid: 3ddd1f71d925a48a788bd41e2abb3103, type: 2}
ability:
Name:
Value: 0
abilities:
- Name: Speed
Value: 0
- Name: Strength
Value: 0
- Name: Inteligence
Value: 0
@@ -383,17 +383,6 @@ MonoBehaviour:
m_ShadowLayerMask: 1 m_ShadowLayerMask: 1
m_RenderingLayers: 1 m_RenderingLayers: 1
m_ShadowRenderingLayers: 1 m_ShadowRenderingLayers: 1
--- !u!114 &669832977 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 2810982769414486938, guid: 9c9a21089189c459b9c6ea1b32152dc4, type: 3}
m_PrefabInstance: {fileID: 7071613369498931541}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image
--- !u!1 &832575517 --- !u!1 &832575517
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -545,6 +534,63 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0} m_Pivot: {x: 0, y: 0}
--- !u!1001 &892205134
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 3828686756138395984, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_Name
value: Player
objectReference: {fileID: 0}
- target: {fileID: 6873632029419311933, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_LocalPosition.x
value: 160
objectReference: {fileID: 0}
- target: {fileID: 6873632029419311933, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_LocalPosition.y
value: 544.5
objectReference: {fileID: 0}
- target: {fileID: 6873632029419311933, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6873632029419311933, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6873632029419311933, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6873632029419311933, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6873632029419311933, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6873632029419311933, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6873632029419311933, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6873632029419311933, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
--- !u!224 &949329152 stripped --- !u!224 &949329152 stripped
RectTransform: RectTransform:
m_CorrespondingSourceObject: {fileID: 7072266447349178485, guid: 9c9a21089189c459b9c6ea1b32152dc4, type: 3} m_CorrespondingSourceObject: {fileID: 7072266447349178485, guid: 9c9a21089189c459b9c6ea1b32152dc4, type: 3}
@@ -750,14 +796,6 @@ PrefabInstance:
serializedVersion: 3 serializedVersion: 3
m_TransformParent: {fileID: 884244192} m_TransformParent: {fileID: 884244192}
m_Modifications: m_Modifications:
- target: {fileID: 2810982769414486938, guid: 9c9a21089189c459b9c6ea1b32152dc4, type: 3}
propertyPath: m_Sprite
value:
objectReference: {fileID: 21300000, guid: e3cc3bf28e4b3480d96788a24c343552, type: 3}
- target: {fileID: 2810982769414486938, guid: 9c9a21089189c459b9c6ea1b32152dc4, type: 3}
propertyPath: m_FillAmount
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7072266447349178485, guid: 9c9a21089189c459b9c6ea1b32152dc4, type: 3} - target: {fileID: 7072266447349178485, guid: 9c9a21089189c459b9c6ea1b32152dc4, type: 3}
propertyPath: m_Pivot.x propertyPath: m_Pivot.x
value: 0 value: 0
@@ -847,67 +885,6 @@ PrefabInstance:
m_AddedGameObjects: [] m_AddedGameObjects: []
m_AddedComponents: [] m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 9c9a21089189c459b9c6ea1b32152dc4, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 9c9a21089189c459b9c6ea1b32152dc4, type: 3}
--- !u!1001 &8263333300151463791
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 2288145426711396226, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: healthBarFillingImage
value:
objectReference: {fileID: 669832977}
- target: {fileID: 3828686756138395984, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_Name
value: Player
objectReference: {fileID: 0}
- target: {fileID: 6873632029419311933, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6873632029419311933, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_LocalPosition.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6873632029419311933, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6873632029419311933, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6873632029419311933, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6873632029419311933, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6873632029419311933, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6873632029419311933, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6873632029419311933, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6873632029419311933, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 4cce8d77e06e0444ba83c136705ec39e, type: 3}
--- !u!1660057539 &9223372036854775807 --- !u!1660057539 &9223372036854775807
SceneRoots: SceneRoots:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -915,7 +892,7 @@ SceneRoots:
- {fileID: 330585546} - {fileID: 330585546}
- {fileID: 410087041} - {fileID: 410087041}
- {fileID: 832575519} - {fileID: 832575519}
- {fileID: 8263333300151463791} - {fileID: 892205134}
- {fileID: 2038460497} - {fileID: 2038460497}
- {fileID: 884244192} - {fileID: 884244192}
- {fileID: 1362584173} - {fileID: 1362584173}
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 951a34700e94a4e97828b2571f5b6de8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 36f69ac19e40842a8a901d8ee76781b2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
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: 11500000, guid: 4f21d365f6b74c6eae7bc9c0431c2695, type: 3}
m_Name: HeavyOrc
m_EditorClassIdentifier: Assembly-CSharp::Data.CharacterAttributes
Name: Heavy Orc
Health: 0
Strength: 0
Dexterity: 0
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ef57c4dc3648642f68d9f10dccf294bd
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
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: 11500000, guid: 4f21d365f6b74c6eae7bc9c0431c2695, type: 3}
m_Name: Hero
m_EditorClassIdentifier: Assembly-CSharp::Data.CharacterAttributes
Name: Hero
Health: 0
Strength: 0
Dexterity: 0
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3ddd1f71d925a48a788bd41e2abb3103
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
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: 11500000, guid: 4f21d365f6b74c6eae7bc9c0431c2695, type: 3}
m_Name: Knight
m_EditorClassIdentifier: Assembly-CSharp::Data.CharacterAttributes
Name: Knight
Health: 200
Strength: 2
Dexterity: 20
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f038e5bf799be46b4b0319a8a1a487f7
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
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: 11500000, guid: 4f21d365f6b74c6eae7bc9c0431c2695, type: 3}
m_Name: Orc
m_EditorClassIdentifier: Assembly-CSharp::Data.CharacterAttributes
Name: Orc
Health: 100
Strength: 5
Dexterity: 10
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f04083efc2fa447af84a18919707da0f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
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: 11500000, guid: 4f21d365f6b74c6eae7bc9c0431c2695, type: 3}
m_Name: Troll
m_EditorClassIdentifier: Assembly-CSharp::Data.CharacterAttributes
Name: Troll
Health: 50
Strength: 2
Dexterity: 20
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c8a5e9650053a474eabab7ea6b1b933c
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5e8e7f08d636d478aa93d9e21f4cbbda
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,14 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
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: 11500000, guid: 7c8e9a4f877141c4b1f3e248fcef8803, type: 3}
m_Name: EventBroker
m_EditorClassIdentifier: Assembly-CSharp::Events.EventBroker
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d3d201ac03d9744bc85390aa5b74aef5
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ca7ec574d13d143059fb6a748e11cee8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,15 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
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: 11500000, guid: e94c4e9b6648485ca46c67afaab715ac, type: 3}
m_Name: CurrentHealth
m_EditorClassIdentifier: Assembly-CSharp::Data.FloatValue
Value: 100
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0b05fcf292ed04876a6376d1ef94f0da
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,15 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
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: 11500000, guid: e94c4e9b6648485ca46c67afaab715ac, type: 3}
m_Name: MaxHealth
m_EditorClassIdentifier: Assembly-CSharp::Data.FloatValue
Value: 100
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b61e2bd6ca6d247fb8577ae9c094f1ae
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3584f915c56743079c64ff8e5a01d40c
timeCreated: 1782226871
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d54ab03c1c0c44d791dc4924077e6721
timeCreated: 1782227128
@@ -0,0 +1,35 @@
using UnityEditor;
using UnityEngine;
namespace Attributes.Editor
{
[CustomPropertyDrawer(typeof(RequiredAttribute))]
public class RequiredAttributeDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
bool isNull = property.objectReferenceValue == null;
if (isNull) position.height = EditorGUIUtility.singleLineHeight;
// draw property itself
EditorGUI.PropertyField(position, property, label);
// draw error if property is null
if (!isNull) return;
position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
position.height += 10.0f;
EditorGUI.HelpBox(position, "Property has to be set!", MessageType.Error);
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
if (property.objectReferenceValue == null)
{
return EditorGUIUtility.singleLineHeight * 2 + EditorGUIUtility.standardVerticalSpacing + 10.0f;
}
return EditorGUIUtility.singleLineHeight;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6e50e9fdc60c4539822a5697fb9ca70f
timeCreated: 1782227142
@@ -0,0 +1,11 @@
using System;
using UnityEngine;
namespace Attributes
{
[AttributeUsage(AttributeTargets.Field)]
public class RequiredAttribute : PropertyAttribute
{
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 24b0639b8cb74a8199a77a007236bce1
timeCreated: 1782226882
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 998a8db57ee2457188c2c9885f46354b
timeCreated: 1782224148
@@ -0,0 +1,11 @@
using System;
namespace Data
{
[Serializable]
public class Ability
{
public string Name;
public float Value;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: aa5b1ad84d0e43608052c6a8eaf2168f
timeCreated: 1782228009
@@ -0,0 +1,13 @@
using UnityEngine;
namespace Data
{
[CreateAssetMenu(fileName = "CharacterAttributes", menuName = "Data/Character Attribute", order = 0)]
public class CharacterAttributes : ScriptableObject
{
public string Name;
public int Health;
public int Strength;
public int Dexterity;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4f21d365f6b74c6eae7bc9c0431c2695
timeCreated: 1782229191
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ab00c23a3d5e424285496daaa587c857
timeCreated: 1782228299
@@ -0,0 +1,38 @@
using UnityEditor;
using UnityEngine;
namespace Data.Editor
{
[CustomPropertyDrawer(typeof(Ability))]
public class AbilityDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
position = EditorGUI.PrefixLabel(position, label);
// everything in one line
float totalWidth = position.width;
position.width = totalWidth * 0.75f;
EditorGUI.PropertyField(position, property.FindPropertyRelative("Name"), GUIContent.none);
position.x += position.width + totalWidth * 0.05f;
position.width = totalWidth * 0.2f;
EditorGUI.PropertyField(position, property.FindPropertyRelative("Value"), GUIContent.none);
// below each other without foldout
// position.height = EditorGUIUtility.singleLineHeight;
// EditorGUI.PropertyField(position, property.FindPropertyRelative("Name"), GUIContent.none);
//
// position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
// EditorGUI.PropertyField(position, property.FindPropertyRelative("Value"), GUIContent.none);
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return EditorGUIUtility.singleLineHeight; // draw everything in one line
// draw properties below each other without foldout
// return EditorGUIUtility.singleLineHeight * 2 + EditorGUIUtility.standardVerticalSpacing;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: cc96966d439940cab8ee55f1803af147
timeCreated: 1782228309
@@ -0,0 +1,30 @@
using UnityEditor;
using UnityEngine;
namespace Data.Editor
{
[CustomPropertyDrawer(typeof(CharacterAttributes))]
public class CharacterAttributesDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
bool isNull = property.objectReferenceValue == null;
position = EditorGUI.PrefixLabel(position, label);
if (!isNull) position.width *= 0.75f;
EditorGUI.PropertyField(position, property, GUIContent.none);
if (isNull) return;
position.x += position.width;
position.width *= 0.3333333f;
if (GUI.Button(position, "Open"))
{
CharacterAttributesWindow window = EditorWindow.GetWindow<CharacterAttributesWindow>();
window.CharacterAttributesToEdit = property.objectReferenceValue as CharacterAttributes;
window.Show();
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d56ef7d56a2f46f7af43982d7c693996
timeCreated: 1782231785
@@ -0,0 +1,21 @@
using UnityEditor;
using UnityEngine;
namespace Data.Editor
{
[CustomEditor(typeof(CharacterAttributes))]
public class CharacterAttributesEditor : UnityEditor.Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
if (GUILayout.Button("Open Character Attributes Window"))
{
CharacterAttributesWindow window = (CharacterAttributesWindow)EditorWindow.GetWindow(typeof(CharacterAttributesWindow));
window.CharacterAttributesToEdit = target as CharacterAttributes;
window.Show();
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 29b2341a96d04825a2dcc97cdce1f640
timeCreated: 1782232217
@@ -0,0 +1,96 @@
using UnityEditor;
using UnityEditor.VersionControl;
using UnityEngine;
namespace Data.Editor
{
public class CharacterAttributesWindow : EditorWindow
{
public CharacterAttributes CharacterAttributesToEdit;
// for an overview about the shortcuts
// https://docs.unity3d.com/6000.4/Documentation/ScriptReference/MenuItem.html
[MenuItem("Tools/Character Attributes #%&c")]
private static void ShowWindow()
{
CharacterAttributesWindow window = GetWindow<CharacterAttributesWindow>();
window.titleContent = new GUIContent("Character Attributes");
window.Show();
}
private void OnGUI()
{
// EditorGUILayout.BeginHorizontal();
//
// EditorGUILayout.LabelField("Label", EditorStyles.boldLabel, GUILayout.Width(100));
// EditorGUILayout.LabelField("Second Label", GUILayout.ExpandWidth(true));
//
// EditorGUILayout.BeginVertical();
//
// EditorGUILayout.LabelField("Another Label");
// EditorGUILayout.LabelField("Another Label");
// EditorGUILayout.LabelField("Another Label");
// EditorGUILayout.LabelField("Another Label");
// EditorGUILayout.TextField("Textfield");
//
// EditorGUILayout.EndVertical();
//
// EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginVertical();
EditorGUILayout.LabelField("Character Attributes", EditorStyles.boldLabel);
// show all project-wide character attribute assets
GUID[] characterAttributeGUIDs = AssetDatabase.FindAssetGUIDs("t:CharacterAttributes");
foreach (GUID characterAttributeGUID in characterAttributeGUIDs)
{
CharacterAttributes characterAttributes =
AssetDatabase.LoadAssetByGUID<CharacterAttributes>(characterAttributeGUID);
if (characterAttributes == null) continue;
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(characterAttributes.Name);
if (GUILayout.Button("Edit")) CharacterAttributesToEdit = characterAttributes;
EditorGUILayout.EndHorizontal();
}
if (CharacterAttributesToEdit != null)
{
EditorGUILayout.Separator();
SerializedObject serializedObject = new SerializedObject(CharacterAttributesToEdit);
// whenever a serialized object is used, update and apply properties
serializedObject.Update();
// here you can change the serialized object
EditorGUILayout.PropertyField(serializedObject.FindProperty("Name"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("Health"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("Strength"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("Dexterity"));
serializedObject.ApplyModifiedProperties();
}
EditorGUILayout.Separator();
if (GUILayout.Button("Create"))
{
CharacterAttributes characterAttributes = CreateInstance<CharacterAttributes>();
string path = EditorUtility.SaveFilePanelInProject("Save Character Attributes", "New Character Attributes", "asset", "Save Character Attributes", "Assets/CharacterAttributes.asset");
if (!string.IsNullOrEmpty(path))
{
CharacterAttributesToEdit = characterAttributes;
AssetDatabase.CreateAsset(characterAttributes, path);
AssetDatabase.SaveAssets(); // always call this to be sure that the new assets is being saved
}
}
EditorGUILayout.EndVertical();
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 91c41f34951643a4bfd4a2b3efa4e2d6
timeCreated: 1782229380
@@ -0,0 +1,10 @@
using UnityEngine;
namespace Data
{
[CreateAssetMenu(fileName = "FloatValue", menuName = "Data/Values/Float", order = 0)]
public class FloatValue : ScriptableObject
{
public float Value;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e94c4e9b6648485ca46c67afaab715ac
timeCreated: 1782224168
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 04cd260b7b7b4433beec3903ba437de4
timeCreated: 1782225082
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 94ea6f71efde4bd4ae34bde539c2c68c
timeCreated: 1782225959
@@ -0,0 +1,21 @@
using UnityEditor;
using UnityEngine;
namespace Events.Editor
{
[CustomEditor(typeof(EventBroker))]
public class EventBrokerEditor : UnityEditor.Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
if (!EditorApplication.isPlaying) return;
if (GUILayout.Button("Player Died"))
{
(target as EventBroker)?.RaisePlayerDied();
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ea036d9930184985a5a989eeb914e5fe
timeCreated: 1782226034
@@ -0,0 +1,13 @@
using System;
using UnityEngine;
namespace Events
{
[CreateAssetMenu(fileName = "EventBroker", menuName = "Events/Event Broker")]
public class EventBroker : ScriptableObject
{
public event Action PlayerDied;
public void RaisePlayerDied() => PlayerDied?.Invoke();
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7c8e9a4f877141c4b1f3e248fcef8803
timeCreated: 1782225093
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b3597a6e4b534b9baf57981a436382ba
timeCreated: 1782224267
@@ -0,0 +1,49 @@
using Attributes;
using Data;
using Events;
using UnityEngine;
namespace Player
{
[RequireComponent(typeof(CharacterController))]
public class PlayerController : MonoBehaviour
{
[Header("Events")]
[SerializeField, Required] private EventBroker eventBroker;
[Header("Movement")]
[SerializeField] private float speed = 5f;
[SerializeField] private float rotationSpeed = 60f;
[Header("Values")]
// [SerializeField] private float maxHealth = 100f;
[SerializeField, Required] private FloatValue maxHealth;
[SerializeField, Required] private FloatValue currentHealth;
[SerializeField] private CharacterAttributes characterAttributes;
// [Header("References")]
// [SerializeField] private Image healthBarFillingImage;
[Header("Abilities")]
[SerializeField] private Ability ability;
[SerializeField] private Ability[] abilities;
// private float _currentHealth;
private void Awake()
{
// _currentHealth = maxHealth;
// set health
currentHealth.Value = maxHealth.Value;
}
private void Update()
{
// healthBarFillingImage.fillAmount = _currentHealth / maxHealth;
if (currentHealth.Value <= 0.0f) eventBroker.RaisePlayerDied();
}
}
}
@@ -1,31 +0,0 @@
using UnityEngine;
using UnityEngine.UI;
namespace DefaultNamespace
{
[RequireComponent(typeof(CharacterController))]
public class PlayerController : MonoBehaviour
{
[Header("Movement")]
[SerializeField] private float speed = 5f;
[SerializeField] private float rotationSpeed = 60f;
[Header("Values")]
[SerializeField] private float maxHealth = 100f;
[Header("References")]
[SerializeField] private Image healthBarFillingImage;
private float _currentHealth;
private void Awake()
{
_currentHealth = maxHealth;
}
private void Update()
{
healthBarFillingImage.fillAmount = _currentHealth / maxHealth;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4c22ee53ed204a81a5a83315733d1656
timeCreated: 1782224277
@@ -0,0 +1,52 @@
using Data;
using Events;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace UI
{
public class HealthBar : MonoBehaviour
{
[Header("Events")]
[SerializeField] private EventBroker eventBroker;
[Header("Values")]
[SerializeField] private FloatValue maxHealth;
[SerializeField] private FloatValue currentHealth;
[Header("References")]
[SerializeField] private Image fillingImage;
[SerializeField] private TextMeshProUGUI deadMessageText;
private void Awake()
{
fillingImage.type = Image.Type.Filled;
fillingImage.fillMethod = Image.FillMethod.Horizontal;
fillingImage.fillOrigin = 0;
deadMessageText.gameObject.SetActive(false);
}
private void OnEnable()
{
eventBroker.PlayerDied += OnPlayerDied;
}
private void OnDisable()
{
eventBroker.PlayerDied -= OnPlayerDied;
}
private void Update()
{
fillingImage.fillAmount = currentHealth.Value / maxHealth.Value;
}
private void OnPlayerDied()
{
fillingImage.fillAmount = 0.0f;
currentHealth.Value = 0.0f;
deadMessageText.gameObject.SetActive(true);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7d9616fe18084f1bb99a58e30eea20e1
timeCreated: 1782224286