Initial commit of Unity files, Network Library, Project settings (Compiler flags for networking to work on Unity), Unity Version 2019.4 LTS
This commit is contained in:
parent
8ec6828fa0
commit
9b69003715
119 changed files with 15444 additions and 0 deletions
15
Assets/Runtime/Drawers/ArrayElementTitleAttribute.cs
Normal file
15
Assets/Runtime/Drawers/ArrayElementTitleAttribute.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ArrayElementTitleAttribute : PropertyAttribute {
|
||||
public string fieldName;
|
||||
|
||||
public ArrayElementTitleAttribute() {
|
||||
this.fieldName = "name";
|
||||
}
|
||||
|
||||
public ArrayElementTitleAttribute(string fieldName) {
|
||||
this.fieldName = fieldName;
|
||||
}
|
||||
}
|
11
Assets/Runtime/Drawers/ArrayElementTitleAttribute.cs.meta
Normal file
11
Assets/Runtime/Drawers/ArrayElementTitleAttribute.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e8550d86f434d784e98b16c3530703d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Runtime/Drawers/Editor.meta
Normal file
8
Assets/Runtime/Drawers/Editor.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a0346cc8c59a10f4a966240dd9e440b3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
71
Assets/Runtime/Drawers/Editor/ArrayElementTitleDrawer.cs
Normal file
71
Assets/Runtime/Drawers/Editor/ArrayElementTitleDrawer.cs
Normal file
|
@ -0,0 +1,71 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
[CustomPropertyDrawer(typeof(ArrayElementTitleAttribute))]
|
||||
public class ArrayElementTitleDrawer : PropertyDrawer {
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) {
|
||||
return EditorGUI.GetPropertyHeight(property, label, true);
|
||||
}
|
||||
|
||||
protected virtual ArrayElementTitleAttribute titleAttribute => (ArrayElementTitleAttribute)attribute;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
|
||||
string fullpath = property.propertyPath + "." + titleAttribute.fieldName;
|
||||
var prop = property.serializedObject.FindProperty(fullpath);
|
||||
string newlabel = GetTitle(prop);
|
||||
if (string.IsNullOrEmpty(newlabel))
|
||||
newlabel = label.text;
|
||||
|
||||
EditorGUI.PropertyField(position, property, new GUIContent(newlabel, label.tooltip), true);
|
||||
}
|
||||
|
||||
|
||||
private string GetTitle(SerializedProperty prop) {
|
||||
switch (prop.propertyType) {
|
||||
case SerializedPropertyType.Generic:
|
||||
break;
|
||||
case SerializedPropertyType.Integer:
|
||||
return prop.intValue.ToString();
|
||||
case SerializedPropertyType.Boolean:
|
||||
return prop.boolValue.ToString();
|
||||
case SerializedPropertyType.Float:
|
||||
return prop.floatValue.ToString();
|
||||
case SerializedPropertyType.String:
|
||||
return prop.stringValue;
|
||||
case SerializedPropertyType.Color:
|
||||
return prop.colorValue.ToString();
|
||||
case SerializedPropertyType.ObjectReference:
|
||||
return prop.objectReferenceValue.ToString();
|
||||
case SerializedPropertyType.LayerMask:
|
||||
break;
|
||||
case SerializedPropertyType.Enum:
|
||||
return prop.enumNames[prop.enumValueIndex];
|
||||
case SerializedPropertyType.Vector2:
|
||||
return prop.vector2Value.ToString();
|
||||
case SerializedPropertyType.Vector3:
|
||||
return prop.vector3Value.ToString();
|
||||
case SerializedPropertyType.Vector4:
|
||||
return prop.vector4Value.ToString();
|
||||
case SerializedPropertyType.Rect:
|
||||
break;
|
||||
case SerializedPropertyType.ArraySize:
|
||||
break;
|
||||
case SerializedPropertyType.Character:
|
||||
break;
|
||||
case SerializedPropertyType.AnimationCurve:
|
||||
break;
|
||||
case SerializedPropertyType.Bounds:
|
||||
break;
|
||||
case SerializedPropertyType.Gradient:
|
||||
break;
|
||||
case SerializedPropertyType.Quaternion:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e22b2b5dabe661b4498b020007dbb838
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
35
Assets/Runtime/Drawers/Editor/EnumFlagDrawer.cs
Normal file
35
Assets/Runtime/Drawers/Editor/EnumFlagDrawer.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomPropertyDrawer(typeof(EnumFlagAttribute))]
|
||||
public class EnumFlagDrawer : PropertyDrawer {
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
|
||||
EnumFlagAttribute flagSettings = (EnumFlagAttribute)attribute;
|
||||
Enum targetEnum = GetBaseProperty<Enum>(property);
|
||||
|
||||
string propName = flagSettings.enumName;
|
||||
if (string.IsNullOrEmpty(propName))
|
||||
propName = property.displayName;
|
||||
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
Enum enumNew = EditorGUI.EnumFlagsField(position, propName, targetEnum);
|
||||
property.intValue = (int)Convert.ChangeType(enumNew, targetEnum.GetType());
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
|
||||
static T GetBaseProperty<T>(SerializedProperty prop) {
|
||||
// Separate the steps it takes to get to this property
|
||||
string[] separatedPaths = prop.propertyPath.Split('.');
|
||||
|
||||
// Go down to the root of this serialized property
|
||||
System.Object reflectionTarget = prop.serializedObject.targetObject as object;
|
||||
// Walk down the path to get the target object
|
||||
foreach (var path in separatedPaths) {
|
||||
FieldInfo fieldInfo = reflectionTarget.GetType().GetField(path);
|
||||
reflectionTarget = fieldInfo.GetValue(reflectionTarget);
|
||||
}
|
||||
return (T)reflectionTarget;
|
||||
}
|
||||
}
|
11
Assets/Runtime/Drawers/Editor/EnumFlagDrawer.cs.meta
Normal file
11
Assets/Runtime/Drawers/Editor/EnumFlagDrawer.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bde9bcb8cf46e7e4090257fbff464d17
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
14
Assets/Runtime/Drawers/Editor/ReadOnlyDrawer.cs
Normal file
14
Assets/Runtime/Drawers/Editor/ReadOnlyDrawer.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
|
||||
public class ReadOnlyDrawer : PropertyDrawer {
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
|
||||
GUI.enabled = false;
|
||||
EditorGUI.PropertyField(position, property, label, true);
|
||||
GUI.enabled = true;
|
||||
}
|
||||
|
||||
}
|
11
Assets/Runtime/Drawers/Editor/ReadOnlyDrawer.cs.meta
Normal file
11
Assets/Runtime/Drawers/Editor/ReadOnlyDrawer.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e772dac1e610df54fbbf25f1073012dc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
11
Assets/Runtime/Drawers/EnumFlagAttribute.cs
Normal file
11
Assets/Runtime/Drawers/EnumFlagAttribute.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class EnumFlagAttribute : PropertyAttribute {
|
||||
public string enumName;
|
||||
|
||||
public EnumFlagAttribute() { }
|
||||
|
||||
public EnumFlagAttribute(string name) {
|
||||
enumName = name;
|
||||
}
|
||||
}
|
11
Assets/Runtime/Drawers/EnumFlagAttribute.cs.meta
Normal file
11
Assets/Runtime/Drawers/EnumFlagAttribute.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6c03bbb4c7afaf746ab43c4fbeb3ae9e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
5
Assets/Runtime/Drawers/ReadOnlyAttribute.cs
Normal file
5
Assets/Runtime/Drawers/ReadOnlyAttribute.cs
Normal file
|
@ -0,0 +1,5 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class ReadOnlyAttribute : PropertyAttribute {
|
||||
public ReadOnlyAttribute() { }
|
||||
}
|
11
Assets/Runtime/Drawers/ReadOnlyAttribute.cs.meta
Normal file
11
Assets/Runtime/Drawers/ReadOnlyAttribute.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2175955395688374191c019f19c355be
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue