Initial Commit

This commit is contained in:
2025-07-04 20:33:06 +03:00
commit 8f09347ae0
9219 changed files with 2447903 additions and 0 deletions
@@ -0,0 +1,63 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System.Reflection;
using Meta.WitAi.Utilities;
using UnityEditor;
using UnityEngine;
namespace Meta.WitAi.Drawers
{
[CustomPropertyDrawer(typeof(DynamicRangeAttribute))]
public class DynamicRangeAttributeDrawer : PropertyDrawer
{
private Object _targetObject;
private float _min;
private float _max;
private PropertyInfo _rangePropertyField;
private object _parentValue;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var value = property.floatValue;
var attr = attribute as DynamicRangeAttribute;
var parentPropertyName =
property.propertyPath.Substring(0, property.propertyPath.IndexOf("."));
var parentProperty = property.serializedObject.FindProperty(parentPropertyName);
var targetObject = property.serializedObject.targetObject;
if(targetObject != _targetObject)
{
_targetObject = targetObject;
var targetObjectClassType = targetObject.GetType();
var field = targetObjectClassType.GetField(parentProperty.propertyPath,
BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
if (null != field)
{
_parentValue = field.GetValue(targetObject);
var parentType = _parentValue.GetType();
_rangePropertyField = parentType.GetProperty(attr.RangeProperty,
BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
}
}
_min = attr.DefaultMin;
_max = attr.DefaultMax;
if (null != _rangePropertyField)
{
var range = (Vector2) _rangePropertyField.GetValue(_parentValue);
_min = range.x;
_max = range.y;
}
property.floatValue = EditorGUI.Slider(position, label, property.floatValue,
_min, _max);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c71bbccdffacf4cfea501a346b0b9d1b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,88 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using Meta.WitAi.Data.ValueReferences;
using UnityEditor;
using UnityEngine;
namespace Meta.WitAi.Drawers
{
[CustomPropertyDrawer(typeof(StringReference<>), true)]
public class StringReferenceDrawer : PropertyDrawer
{
private const int buttonWidth = 20;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
SerializedProperty stringValueProperty = property.FindPropertyRelative("stringValue");
SerializedProperty stringObjectProperty = property.FindPropertyRelative("stringObject");
EditorGUI.BeginProperty(position, label, property);
// Draw the label
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
// Draw the text field
Rect textFieldRect = new Rect(position);
textFieldRect.width -= buttonWidth;
Rect objFieldRect = new Rect(position.x + textFieldRect.width, position.y, buttonWidth,
EditorGUIUtility.singleLineHeight);
EditorGUI.PropertyField(stringObjectProperty.objectReferenceValue == null ? objFieldRect : position,
stringObjectProperty, GUIContent.none);
if (stringObjectProperty.objectReferenceValue == null)
{
stringValueProperty.stringValue = EditorGUI.TextField(textFieldRect, stringValueProperty.stringValue);
}
else
{
stringValueProperty.stringValue = ((IStringReference)stringObjectProperty.objectReferenceValue).Value;
}
Type targetType = fieldInfo.FieldType.BaseType.GenericTypeArguments[0];
// Handle drag and drop
if (Event.current.type == EventType.DragUpdated && textFieldRect.Contains(Event.current.mousePosition))
{
var validType = false;
foreach (var draggedObject in DragAndDrop.objectReferences)
{
if (draggedObject.GetType() == targetType)
{
validType = true;
break;
}
}
if (validType)
{
DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
}
Event.current.Use();
}
else if (Event.current.type == EventType.DragPerform && textFieldRect.Contains(Event.current.mousePosition))
{
DragAndDrop.AcceptDrag();
foreach (var draggedObject in DragAndDrop.objectReferences)
{
if (draggedObject.GetType() == targetType)
{
stringObjectProperty.objectReferenceValue = draggedObject;
property.serializedObject.ApplyModifiedProperties();
break;
}
}
Event.current.Use();
}
EditorGUI.EndProperty();
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e885f2612e2647c1813153fb6981e5e9
timeCreated: 1680299773
@@ -0,0 +1,52 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using Meta.WitAi.Attributes;
using Meta.WitAi.Windows;
using UnityEditor;
using UnityEngine;
namespace Meta.WitAi.Drawers
{
[CustomPropertyDrawer(typeof(TooltipBoxAttribute))]
public class TooltipBoxDrawer : DecoratorDrawer
{
private float _spaceAfterBox = 4;
private float _iconSize = 32;
private float _lastViewWidth;
public override float GetHeight()
{
if (!WitWindow.ShowTooltips) return 0;
TooltipBoxAttribute infoBoxAttribute = (TooltipBoxAttribute)attribute;
var height = EditorStyles.helpBox.CalcHeight(new GUIContent(infoBoxAttribute.Text), _lastViewWidth - _iconSize);
return Mathf.Max(_iconSize, height) + _spaceAfterBox;
}
public override void OnGUI(Rect position)
{
if (!WitWindow.ShowTooltips) return;
_lastViewWidth = EditorGUIUtility.currentViewWidth;
var iconRect = EditorGUI.IndentedRect(position);
iconRect.width = _iconSize;
iconRect.height = _iconSize;
GUIContent infoIcon = EditorGUIUtility.IconContent("console.infoicon");
infoIcon.tooltip = "You can turn off these tooltips in Voice SDK Settings.";
EditorGUI.LabelField(iconRect, infoIcon);
var tooltip = (TooltipBoxAttribute) attribute;
var rect = EditorGUI.IndentedRect(position);
rect.x += _iconSize;
rect.width -= _iconSize;
rect.height -= _spaceAfterBox;
EditorGUI.TextArea(rect, tooltip.Text, EditorStyles.helpBox);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5be6165094d84fbb9377d595397a1dbc
timeCreated: 1680127468