clean project

This commit is contained in:
Helar Jaadla
2022-03-07 17:52:41 +02:00
parent a174b45bd2
commit cbeb10ec35
5100 changed files with 837159 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0e93701f7111c8343b48fc4a99b918d5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,179 @@
/************************************************************************************
Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
https://developer.oculus.com/licenses/oculussdk/
Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
ANY KIND, either express or implied. See the License for the specific language governing
permissions and limitations under the License.
************************************************************************************/
using System;
using System.Linq;
using System.Reflection;
using UnityEngine;
using UnityEditor;
namespace Oculus.Interaction.InterfaceSupport
{
/// <summary>
/// This property drawer is the meat of the interface support implementation. When
/// the value of field with this attribute is modified, the new value is tested
/// against the interface expected. If the component matches, the new value is
/// accepted. Otherwise, the old value is maintained.
/// </summary>
[CustomPropertyDrawer(typeof(InterfaceAttribute))]
public class InterfaceDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
if (property.serializedObject.isEditingMultipleObjects) return;
if (property.propertyType != SerializedPropertyType.ObjectReference)
{
EditorGUI.LabelField(position, label.text, "InterfaceType Attribute can only be used with MonoBehaviour Components.");
return;
}
Type[] attTypes = GetInterfaceTypes(property);
// Pick a specific component
MonoBehaviour oldComponent = property.objectReferenceValue as MonoBehaviour;
string oldComponentName = "";
GameObject temporaryGameObject = null;
string attTypesName = GetTypesName(attTypes);
if (Event.current.type == EventType.Repaint)
{
if (oldComponent == null)
{
temporaryGameObject = new GameObject("None (" + attTypesName + ")");
oldComponent = temporaryGameObject.AddComponent<InterfaceMono>();
}
else
{
oldComponentName = oldComponent.name;
oldComponent.name = oldComponentName + " (" + attTypesName + ")";
}
}
MonoBehaviour currentComponent = EditorGUI.ObjectField(position, label, oldComponent, typeof(MonoBehaviour), true) as MonoBehaviour;
if (Event.current.type == EventType.Repaint)
{
if (temporaryGameObject != null)
GameObject.DestroyImmediate(temporaryGameObject);
else
oldComponent.name = oldComponentName;
}
// If a component is assigned, make sure it is the interface we are looking for.
if (currentComponent != null)
{
// Make sure component is of the right interface
if(!IsAssignableFromTypes(currentComponent.GetType(), attTypes))
// Component failed. Check game object.
foreach (Type attType in attTypes)
{
currentComponent = currentComponent.gameObject.GetComponent(attType) as MonoBehaviour;
if (currentComponent == null)
{
break;
}
}
// Item failed test. Do not override old component
if (currentComponent == null)
{
if (oldComponent != null && !IsAssignableFromTypes(oldComponent.GetType(), attTypes))
{
temporaryGameObject = new GameObject("None (" + attTypesName + ")");
MonoBehaviour temporaryComponent = temporaryGameObject.AddComponent<InterfaceMono>();
currentComponent = EditorGUI.ObjectField(position, label, temporaryComponent, typeof(MonoBehaviour), true) as MonoBehaviour;
GameObject.DestroyImmediate(temporaryGameObject);
}
}
}
property.objectReferenceValue = currentComponent;
property.serializedObject.ApplyModifiedProperties();
}
private bool IsAssignableFromTypes(Type source, Type[] targets)
{
foreach (Type t in targets)
{
if (!t.IsAssignableFrom(source))
{
return false;
}
}
return true;
}
private static string GetTypesName(Type[] attTypes)
{
if (attTypes.Length == 1)
{
return GetTypeName(attTypes[0]);
}
string typesString = "";
for (int i = 0; i < attTypes.Length; i++)
{
if (i > 0)
{
typesString += ", ";
}
typesString += GetTypeName(attTypes[i]);
}
return typesString;
}
private static string GetTypeName(Type attType)
{
if (!attType.IsGenericType)
{
return attType.Name;
}
var genericTypeNames = attType.GenericTypeArguments.Select(GetTypeName);
return $"{attType.Name}<{string.Join(", ", genericTypeNames)}>";
}
private Type[] GetInterfaceTypes(SerializedProperty property)
{
InterfaceAttribute att = (InterfaceAttribute)attribute;
Type[] t = att.Types;
if (!String.IsNullOrEmpty(att.TypeFromFieldName))
{
var thisType = property.serializedObject.targetObject.GetType();
while (thisType != null)
{
var referredFieldInfo = thisType.GetField(att.TypeFromFieldName,
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
if (referredFieldInfo != null)
{
t = new Type[1] { referredFieldInfo.FieldType };
break;
}
thisType = thisType.BaseType;
}
}
return t ?? singleMonoBehaviourType;
}
private static readonly Type[] singleMonoBehaviourType = new Type[1] {typeof(MonoBehaviour)};
}
public sealed class InterfaceMono : MonoBehaviour { }
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b2fd211401b34f246897eb204ff3ca43
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,17 @@
{
"name": "Oculus.Interaction.InterfaceSupport",
"references": [
"GUID:2a230cb87a1d3ba4a98bdc0ddae76e6c"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": true,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 62f0806efa855234fa40d98ad397e1ca
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,47 @@
/************************************************************************************
Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
https://developer.oculus.com/licenses/oculussdk/
Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
ANY KIND, either express or implied. See the License for the specific language governing
permissions and limitations under the License.
************************************************************************************/
using UnityEngine;
using System;
namespace Oculus.Interaction
{
/// <summary>
/// When this attribute is attached to a MonoBehaviour field within a
/// Unity Object, this allows an interface to be specified in to to
/// entire only a specific type of MonoBehaviour can be attached.
/// </summary>
public class InterfaceAttribute : PropertyAttribute
{
public Type[] Types = null;
public string TypeFromFieldName;
/// <summary>
/// Creates a new Interface attribute.
/// </summary>
/// <param name="type">The type of interface which is allowed.</param>
public InterfaceAttribute(Type type, params Type[] types)
{
Types = new Type[types.Length + 1];
Types[0] = type;
for (int i = 0; i < types.Length; i++)
{
Types[i + 1] = types[i];
}
}
public InterfaceAttribute(string typeFromFieldName)
{
this.TypeFromFieldName = typeFromFieldName;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 548b4f28547edc44d95c20e74bcc8c70
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,24 @@
MIT License
Copyright (c) 2020 TheDudeFromCI
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
// Unity Interface Support based on
// https://github.com/TheDudeFromCI/Unity-Interface-Support/

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b4104bbb012ef2b4b9e1d89fcb33b495
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: