VR模拟枪支打靶,消灭鬼怪,换弹以及上弦等等硬核枪支操作。 使用HTCVive设备,开启SteamVR进行游玩。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

68 lines
2.6 KiB

//========= Copyright 2016-2018, HTC Corporation. All rights reserved. ===========
using System;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace HTC.UnityPlugin.Utility
{
[CustomPropertyDrawer(typeof(CustomOrderedEnumAttribute))]
public class CusromOrderedEnumAttributeDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
// First get the attribute since it contains the range for the slider
var attr = attribute as CustomOrderedEnumAttribute;
EditorGUI.BeginProperty(position, label, property);
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent(property.displayName));
// determine which enum type to display
Type displayedEnumType = null;
if (property.propertyType == SerializedPropertyType.Enum)
{
if (attr.overrideEnumType != null && attr.overrideEnumType.IsEnum)
{
displayedEnumType = attr.overrideEnumType;
}
else
{
displayedEnumType = fieldInfo.FieldType;
}
}
else if (property.propertyType == SerializedPropertyType.Integer)
{
if (attr.overrideEnumType != null && attr.overrideEnumType.IsEnum)
{
displayedEnumType = attr.overrideEnumType;
}
}
// display enum popup if displayedEnumType is determined, otherwise, display the default property field
if (displayedEnumType == null)
{
EditorGUI.PropertyField(position, property);
}
else
{
var enumInfo = EnumUtils.GetDisplayInfo(displayedEnumType);
var displayedNames = enumInfo.displayedNames;
var displayedValues = enumInfo.displayedValues;
if (!enumInfo.value2displayedIndex.ContainsKey(property.intValue))
{
displayedNames = displayedNames.Concat(new string[] { property.intValue.ToString() }).ToArray();
displayedValues = displayedValues.Concat(new int[] { property.intValue }).ToArray();
}
property.intValue = EditorGUI.IntPopup(position, property.intValue, displayedNames, displayedValues);
}
property.serializedObject.ApplyModifiedProperties();
EditorGUI.EndProperty();
}
}
}