add unity project for engine customization
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4568a534f016476e831917a7d2a63ab3
|
||||
timeCreated: 1749225228
|
||||
@@ -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: ed642210c6734a609db9c71d21f6818c
|
||||
timeCreated: 1749225255
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91fa21e0d9ba4f899609410a3ecc575c
|
||||
timeCreated: 1749225544
|
||||
@@ -0,0 +1,36 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Ability))]
|
||||
public class AbilityDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
position = EditorGUI.PrefixLabel(position, label);
|
||||
|
||||
|
||||
// next to each other
|
||||
// float width = position.width;
|
||||
// position.width *= 0.45f;
|
||||
// EditorGUI.PropertyField(position, property.FindPropertyRelative("Name"), GUIContent.none);
|
||||
//
|
||||
// position.x += (width - position.width);
|
||||
// EditorGUI.PropertyField(position, property.FindPropertyRelative("Value"), GUIContent.none);
|
||||
|
||||
// below each other
|
||||
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; // next to each other
|
||||
return EditorGUIUtility.singleLineHeight * 2 + EditorGUIUtility.standardVerticalSpacing; // below each other
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89671c5541ad4af085e2f49e431148c3
|
||||
timeCreated: 1749225566
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d5b62f85e1940f690aff413526d16b9
|
||||
timeCreated: 1749224638
|
||||
@@ -0,0 +1,19 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace Core
|
||||
{
|
||||
[CustomEditor(typeof(PlayerController))]
|
||||
public class PlayerControllerEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
// serializedObject.Update();
|
||||
//
|
||||
// // update your serialized properties
|
||||
//
|
||||
// serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f997231a87504dcbb30b3bb611015389
|
||||
timeCreated: 1749224756
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using Data;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[RequireComponent(typeof(CharacterController))]
|
||||
public class PlayerController : MonoBehaviour
|
||||
{
|
||||
[Header("Movement")]
|
||||
[SerializeField] private float speed;
|
||||
[SerializeField] private float rotationSpeed;
|
||||
|
||||
[Header("Values")]
|
||||
[SerializeField] private float maxHealth = 100.0f;
|
||||
|
||||
[Header("References")]
|
||||
[SerializeField] private Image healthBarFillingImage;
|
||||
|
||||
[Header("Abilities")] [SerializeField] private Ability ability;
|
||||
[SerializeField] private Ability[] abilities;
|
||||
|
||||
public float _currentHealth; // stupid public value for testing
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_currentHealth = maxHealth;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
healthBarFillingImage.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal,
|
||||
Mathf.Clamp01(_currentHealth / maxHealth) * 200.0f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0047a716a65b04aedba74211b7d0dd43
|
||||
Reference in New Issue
Block a user