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,38 @@
/*
* 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.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace Meta.Voice.Hub.Utilities
{
public static class ContextFinder
{
public static List<T> FindAllContextAssets<T>() where T: ScriptableObject
{
string[] guids = AssetDatabase.FindAssets("t:" + typeof(T).Name);
List<T> assets = new List<T>();
foreach (string guid in guids)
{
string assetPath = AssetDatabase.GUIDToAssetPath(guid);
T asset = AssetDatabase.LoadAssetAtPath<T>(assetPath);
if (asset != null)
{
if (!assets.Contains(asset))
{
assets.Add(asset);
}
}
}
return assets;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c235113b0b6c484a8f361e84786d7467
timeCreated: 1680655637
@@ -0,0 +1,64 @@
/*
* 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 System.Collections.Generic;
using Meta.Voice.Hub.Attributes;
using UnityEditor;
using UnityEngine;
namespace Meta.Voice.Hub.Utilities
{
internal static class PageFinder
{
private static List<Type> _pages;
internal static List<Type> FindPages()
{
if (null == _pages)
{
_pages = ReflectionUtils.GetTypesWithAttribute<MetaHubPageAttribute>();
}
return _pages;
}
internal static MetaHubPageAttribute GetPageInfo(Type type)
{
var attributes = type.GetCustomAttributes(typeof(MetaHubPageAttribute), false);
return attributes.Length > 0 ? (MetaHubPageAttribute) attributes[0] : null;
}
internal static List<ScriptableObject> FindPages(Type t)
{
if (!typeof(ScriptableObject).IsAssignableFrom(t))
{
throw new ArgumentException("The specified type must be a ScriptableObject.");
}
return FindPages(t.Name);
}
public static List<ScriptableObject> FindPages(string type)
{
List<ScriptableObject> pages = new List<ScriptableObject>();
string[] guids = AssetDatabase.FindAssets($"t:{type}");
foreach (string guid in guids)
{
string assetPath = AssetDatabase.GUIDToAssetPath(guid);
ScriptableObject asset = AssetDatabase.LoadAssetAtPath<ScriptableObject>(assetPath);
if (asset != null)
{
pages.Add(asset);
}
}
return pages;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b5b71dcbc6c2475a831e119b0d8701cf
timeCreated: 1680655836
@@ -0,0 +1,47 @@
/*
* 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 System.Collections.Generic;
using System.Linq;
namespace Meta.Voice.Hub.Utilities
{
internal static class ReflectionUtils
{
private const string NAMESPACE_PREFIX = "Meta";
private static bool IsValidNamespace(Type type) =>
type.Namespace != null && type.Namespace.StartsWith(NAMESPACE_PREFIX);
private static List<Type> GetTypes<T>(Func<Type, bool> isValid)
{
return AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(assembly =>
{
try
{
return assembly.GetTypes();
}
catch
{
return new Type[]{};
}
})
.Where(IsValidNamespace)
.Where(isValid)
.ToList();
}
internal static List<Type> GetTypesWithAttribute<T>() where T : Attribute
{
var attributeType = typeof(T);
return GetTypes<T>(type => type.GetCustomAttributes(attributeType, false).Length > 0);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c9dfa99b5c354fc9b6cd8f560ca1ff02
timeCreated: 1680790475