Here are the examples of the csharp api System.Collections.Generic.List.Clear() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
18695 Examples
19
Source : UMAAssetIndexerEditor.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
private void Cleanup()
{
if (AddedDuringGui.Count > 0 || DeletedDuringGUI.Count > 0 || AddedTypes.Count > 0 || RemovedTypes.Count > 0)
{
foreach (Object o in AddedDuringGui)
{
AddObject(o);
}
foreach (replacedereplacedem ai in DeletedDuringGUI)
{
UAI.Removereplacedet(ai._Type, ai._Name);
}
foreach (System.Type st in RemovedTypes)
{
UAI.RemoveType(st);
}
foreach (System.Type st in AddedTypes)
{
UAI.AddType(st);
}
AddedTypes.Clear();
RemovedTypes.Clear();
DeletedDuringGUI.Clear();
AddedDuringGui.Clear();
UAI.ForceSave();
Repaint();
}
}
19
Source : UMAAssetIndexer.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
private void UpdateSerializedList()
{
SerializedItems.Clear();
foreach (System.Type type in TypeToLookup.Keys)
{
if (type == TypeToLookup[type])
{
Dictionary<string, replacedereplacedem> TypeDic = GetreplacedetDictionary(type);
foreach (replacedereplacedem ai in TypeDic.Values)
{
// Don't add replacedet bundle or resource items to index. They are loaded on demand.
if (ai.IsreplacedetBundle == false && ai.IsResource == false)
{
SerializedItems.Add(ai);
}
}
}
}
}
19
Source : MaxRectsBinPack.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public void Init(int width, int height, bool rotations) {
binWidth = width;
binHeight = height;
allowRotations = rotations;
Rect n = new Rect();
n.x = 0;
n.y = 0;
n.width = width;
n.height = height;
usedRectangles.Clear();
freeRectangles.Clear();
freeRectangles.Add(n);
}
19
Source : MaxRectsBinPack.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public void Insert(List<Rect> rects, List<Rect> dst, FreeRectChoiceHeuristic method) {
dst.Clear();
while(rects.Count > 0) {
int bestScore1 = int.MaxValue;
int bestScore2 = int.MaxValue;
int bestRectIndex = -1;
Rect bestNode = new Rect();
for(int i = 0; i < rects.Count; ++i) {
int score1 = 0;
int score2 = 0;
Rect newNode = ScoreRect((int)rects[i].width, (int)rects[i].height, method, ref score1, ref score2);
if (score1 < bestScore1 || (score1 == bestScore1 && score2 < bestScore2)) {
bestScore1 = score1;
bestScore2 = score2;
bestNode = newNode;
bestRectIndex = i;
}
}
if (bestRectIndex == -1)
return;
PlaceRect(bestNode);
rects.RemoveAt(bestRectIndex);
}
}
19
Source : SkinnedMeshCombiner.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public static void CombineMeshes(UMAMeshData target, CombineInstance[] sources, UMAData.BlendShapeSettings blendShapeSettings = null)
{
if (blendShapeSettings == null)
blendShapeSettings = new UMAData.BlendShapeSettings();
int vertexCount = 0;
int bindPoseCount = 0;
int transformHierarchyCount = 0;
int blendShapeCount = 0;
MeshComponents meshComponents = MeshComponents.none;
int subMeshCount = FindTargetSubMeshCount(sources);
var subMeshTriangleLength = new int[subMeshCount];
replacedyzeSources(sources, subMeshTriangleLength, ref vertexCount, ref bindPoseCount, ref transformHierarchyCount, ref meshComponents, ref blendShapeCount);
int[][] submeshTriangles = new int[subMeshCount][];
for (int i = 0; i < subMeshTriangleLength.Length; i++)
{
submeshTriangles[i] = target.GetSubmeshBuffer(subMeshTriangleLength[i], i);
subMeshTriangleLength[i] = 0;
}
bool has_normals = (meshComponents & MeshComponents.has_normals) != MeshComponents.none;
bool has_tangents = (meshComponents & MeshComponents.has_tangents) != MeshComponents.none;
bool has_uv = (meshComponents & MeshComponents.has_uv) != MeshComponents.none;
bool has_uv2 = (meshComponents & MeshComponents.has_uv2) != MeshComponents.none;
bool has_uv3 = (meshComponents & MeshComponents.has_uv3) != MeshComponents.none;
bool has_uv4 = (meshComponents & MeshComponents.has_uv4) != MeshComponents.none;
bool has_colors32 = (meshComponents & MeshComponents.has_colors32) != MeshComponents.none;
bool has_blendShapes = (meshComponents & MeshComponents.has_blendShapes) != MeshComponents.none;
if (blendShapeSettings.ignoreBlendShapes)
has_blendShapes = false;
bool has_clothSkinning = (meshComponents & MeshComponents.has_clothSkinning) != MeshComponents.none;
Vector3[] vertices = EnsureArrayLength(target.vertices, vertexCount);
BoneWeight[] boneWeights = EnsureArrayLength(target.unityBoneWeights, vertexCount);
Vector3[] normals = has_normals ? EnsureArrayLength(target.normals, vertexCount) : null;
Vector4[] tangents = has_tangents ? EnsureArrayLength(target.tangents, vertexCount) : null;
Vector2[] uv = has_uv ? EnsureArrayLength(target.uv, vertexCount) : null;
Vector2[] uv2 = has_uv2 ? EnsureArrayLength(target.uv2, vertexCount) : null;
Vector2[] uv3 = has_uv3 ? EnsureArrayLength(target.uv3, vertexCount) : null;
Vector2[] uv4 = has_uv4 ? EnsureArrayLength(target.uv4, vertexCount) : null;
Color32[] colors32 = has_colors32 ? EnsureArrayLength(target.colors32, vertexCount) : null;
UMABlendShape[] blendShapes = has_blendShapes ? new UMABlendShape[blendShapeCount] : null;
UMATransform[] umaTransforms = EnsureArrayLength(target.umaBones, transformHierarchyCount);
ClothSkinningCoefficient[] clothSkinning = has_clothSkinning ? EnsureArrayLength(target.clothSkinning, vertexCount) : null;
Dictionary<Vector3, int> clothVertices = has_clothSkinning ? new Dictionary<Vector3, int>(vertexCount) : null;
Dictionary<Vector3, int> localClothVertices = has_clothSkinning ? new Dictionary<Vector3, int>(vertexCount) : null;
int boneCount = 0;
foreach (var source in sources)
{
MergeSortedTransforms(umaTransforms, ref boneCount, source.meshData.umaBones);
}
int vertexIndex = 0;
if (bonesCollection == null)
bonesCollection = new Dictionary<int, BoneIndexEntry>(boneCount);
else
bonesCollection.Clear();
if (bindPoses == null)
bindPoses = new List<Matrix4x4>(bindPoseCount);
else
bindPoses.Clear();
if (bonesList == null)
bonesList = new List<int>(boneCount);
else
bonesList.Clear();
int blendShapeIndex = 0;
foreach (var source in sources)
{
int sourceVertexCount = source.meshData.vertices.Length;
BuildBoneWeights(source.meshData.boneWeights, 0, boneWeights, vertexIndex, sourceVertexCount, source.meshData.boneNameHashes, source.meshData.bindPoses, bonesCollection, bindPoses, bonesList);
Array.Copy(source.meshData.vertices, 0, vertices, vertexIndex, sourceVertexCount);
if (has_normals)
{
if (source.meshData.normals != null && source.meshData.normals.Length > 0)
{
Array.Copy(source.meshData.normals, 0, normals, vertexIndex, sourceVertexCount);
}
else
{
FillArray(tangents, vertexIndex, sourceVertexCount, Vector3.zero);
}
}
if (has_tangents)
{
if (source.meshData.tangents != null && source.meshData.tangents.Length > 0)
{
Array.Copy(source.meshData.tangents, 0, tangents, vertexIndex, sourceVertexCount);
}
else
{
FillArray(tangents, vertexIndex, sourceVertexCount, Vector4.zero);
}
}
if (has_uv)
{
if (source.meshData.uv != null && source.meshData.uv.Length >= sourceVertexCount)
{
Array.Copy(source.meshData.uv, 0, uv, vertexIndex, sourceVertexCount);
}
else
{
FillArray(uv, vertexIndex, sourceVertexCount, Vector4.zero);
}
}
if (has_uv2)
{
if (source.meshData.uv2 != null && source.meshData.uv2.Length >= sourceVertexCount)
{
Array.Copy(source.meshData.uv2, 0, uv2, vertexIndex, sourceVertexCount);
}
else
{
FillArray(uv2, vertexIndex, sourceVertexCount, Vector4.zero);
}
}
if (has_uv3)
{
if (source.meshData.uv3 != null && source.meshData.uv3.Length >= sourceVertexCount)
{
Array.Copy(source.meshData.uv3, 0, uv3, vertexIndex, sourceVertexCount);
}
else
{
FillArray(uv3, vertexIndex, sourceVertexCount, Vector4.zero);
}
}
if (has_uv4)
{
if (source.meshData.uv4 != null && source.meshData.uv4.Length >= sourceVertexCount)
{
Array.Copy(source.meshData.uv4, 0, uv4, vertexIndex, sourceVertexCount);
}
else
{
FillArray(uv4, vertexIndex, sourceVertexCount, Vector4.zero);
}
}
if (has_colors32)
{
if (source.meshData.colors32 != null && source.meshData.colors32.Length > 0)
{
Array.Copy(source.meshData.colors32, 0, colors32, vertexIndex, sourceVertexCount);
}
else
{
Color32 white32 = Color.white;
FillArray(colors32, vertexIndex, sourceVertexCount, white32);
}
}
if (has_blendShapes)
{
if (source.meshData.blendShapes != null && source.meshData.blendShapes.Length > 0)
{
for (int shapeIndex = 0; shapeIndex < source.meshData.blendShapes.Length; shapeIndex++)
{
#region BlendShape Baking
if(blendShapeSettings.bakeBlendShapes != null || blendShapeSettings.bakeBlendShapes.Count == 0)
{
// If there are names in the bakeBlendShape dictionary and we find them in the meshData blendshape list, then lets bake them instead of adding them.
UMABlendShape currentShape = source.meshData.blendShapes[shapeIndex];
if( blendShapeSettings.bakeBlendShapes.ContainsKey(currentShape.shapeName))
{
float weight = blendShapeSettings.bakeBlendShapes[currentShape.shapeName] * 100.0f;
if (weight <= 0f) continue; // Baking in nothing, so skip it entirely
// Let's find the frame this weight is in
int frameIndex;
int prevIndex;
for (frameIndex = 0; frameIndex < currentShape.frames.Length; frameIndex++)
{
if (currentShape.frames[frameIndex].frameWeight >= weight)
break;
}
// Let's calculate the weight for the frame we're in
float frameWeight = 1f;
float prevWeight = 0f;
bool doLerp = false;
// Weight is higher than the last frame, shape is over 100%
if (frameIndex >= currentShape.frames.Length)
{
frameIndex = currentShape.frames.Length - 1;
frameWeight = (weight / currentShape.frames[frameIndex].frameWeight);
}
else if (frameIndex > 0)
{
doLerp = true;
prevWeight = currentShape.frames[frameIndex - 1].frameWeight;
frameWeight = ((weight - prevWeight) / (currentShape.frames[frameIndex].frameWeight - prevWeight));
prevWeight = 1f - frameWeight;
}
else
{
frameWeight = (weight / currentShape.frames[frameIndex].frameWeight);
}
prevIndex = frameIndex - 1;
// The blend shape frames lerp between the deltas of two adjacent frames.
int vertIndex = vertexIndex;
for (int bakeIndex = 0; bakeIndex < currentShape.frames[frameIndex].deltaVertices.Length; bakeIndex++, vertIndex++)
{
// Add the current frame's deltas
vertices[vertIndex] += currentShape.frames[frameIndex].deltaVertices[bakeIndex] * frameWeight;
// Add in the previous frame's deltas
if (doLerp)
vertices[vertIndex] += currentShape.frames[prevIndex].deltaVertices[bakeIndex] * prevWeight;
}
if (has_normals)
{
vertIndex = vertexIndex;
for (int bakeIndex = 0; bakeIndex < currentShape.frames[frameIndex].deltaNormals.Length; bakeIndex++, vertIndex++)
{
normals[vertIndex] += currentShape.frames[frameIndex].deltaNormals[bakeIndex] * frameWeight;
if (doLerp)
normals[vertIndex] += currentShape.frames[prevIndex].deltaNormals[bakeIndex] * prevWeight;
}
}
if (has_tangents)
{
vertIndex = vertexIndex;
for (int bakeIndex = 0; bakeIndex < currentShape.frames[frameIndex].deltaTangents.Length; bakeIndex++, vertIndex++)
{
tangents[vertIndex] += (Vector4)currentShape.frames[frameIndex].deltaTangents[bakeIndex] * frameWeight;
if (doLerp)
tangents[vertIndex] += (Vector4)currentShape.frames[prevIndex].deltaTangents[bakeIndex] * prevWeight;
}
}
continue; // If we bake then don't perform the rest of this interation of the loop.
}
}
#endregion
bool nameAlreadyExists = false;
int i = 0;
//Probably this would be better with a dictionary
for (i = 0; i < blendShapeIndex; i++)
{
if (blendShapes[i].shapeName == source.meshData.blendShapes[shapeIndex].shapeName)
{
nameAlreadyExists = true;
break;
}
}
if (nameAlreadyExists)//Lets add the vertices data to the existing blendShape
{
if (blendShapes[i].frames.Length != source.meshData.blendShapes[shapeIndex].frames.Length)
{
Debug.LogError("SkinnedMeshCombiner: mesh blendShape frame counts don't match!");
break;
}
for (int frameIndex = 0; frameIndex < source.meshData.blendShapes[shapeIndex].frames.Length; frameIndex++) {
Array.Copy(source.meshData.blendShapes[shapeIndex].frames[frameIndex].deltaVertices, 0, blendShapes[i].frames[frameIndex].deltaVertices, vertexIndex, sourceVertexCount);
Array.Copy(source.meshData.blendShapes[shapeIndex].frames[frameIndex].deltaNormals, 0, blendShapes[i].frames[frameIndex].deltaNormals, vertexIndex, sourceVertexCount);
Array.Copy(source.meshData.blendShapes[shapeIndex].frames[frameIndex].deltaTangents, 0, blendShapes[i].frames[frameIndex].deltaTangents, vertexIndex, sourceVertexCount);
}
}
else
{
blendShapes[blendShapeIndex] = new UMABlendShape();
blendShapes[blendShapeIndex].shapeName = source.meshData.blendShapes[shapeIndex].shapeName;
blendShapes[blendShapeIndex].frames = new UMABlendFrame[source.meshData.blendShapes[shapeIndex].frames.Length];
for (int frameIndex = 0; frameIndex < source.meshData.blendShapes[shapeIndex].frames.Length; frameIndex++) {
blendShapes[blendShapeIndex].frames[frameIndex] = new UMABlendFrame(vertexCount);
blendShapes[blendShapeIndex].frames[frameIndex].frameWeight = source.meshData.blendShapes[shapeIndex].frames[frameIndex].frameWeight;
Array.Copy(source.meshData.blendShapes[shapeIndex].frames[frameIndex].deltaVertices, 0, blendShapes[blendShapeIndex].frames[frameIndex].deltaVertices, vertexIndex, sourceVertexCount);
Array.Copy(source.meshData.blendShapes[shapeIndex].frames[frameIndex].deltaNormals, 0, blendShapes[blendShapeIndex].frames[frameIndex].deltaNormals, vertexIndex, sourceVertexCount);
Array.Copy(source.meshData.blendShapes[shapeIndex].frames[frameIndex].deltaTangents, 0, blendShapes[blendShapeIndex].frames[frameIndex].deltaTangents, vertexIndex, sourceVertexCount);
}
blendShapeIndex++;
}
}
}
}
if (has_clothSkinning)
{
localClothVertices.Clear();
if (source.meshData.clothSkinningSerialized != null && source.meshData.clothSkinningSerialized.Length > 0)
{
for (int i = 0; i < source.meshData.vertexCount; i++)
{
var vertice = source.meshData.vertices[i];
if (!localClothVertices.ContainsKey(vertice))
{
int localCount = localClothVertices.Count;
localClothVertices.Add(vertice, localCount);
if (!clothVertices.ContainsKey(vertice))
{
ConvertData(ref source.meshData.clothSkinningSerialized[localCount], ref clothSkinning[clothVertices.Count]);
clothVertices.Add(vertice, clothVertices.Count);
}
else
{
ConvertData(ref source.meshData.clothSkinningSerialized[localCount], ref clothSkinning[clothVertices[vertice]]);
}
}
}
}
else
{
for (int i = 0; i < source.meshData.vertexCount; i++)
{
var vertice = source.meshData.vertices[i];
if (!clothVertices.ContainsKey(vertice))
{
clothSkinning[clothVertices.Count].maxDistance = 0;
clothSkinning[clothVertices.Count].collisionSphereDistance = float.MaxValue;
clothVertices.Add(vertice, clothVertices.Count);
localClothVertices.Add(vertice, clothVertices.Count);
}
}
}
}
for (int i = 0; i < source.meshData.subMeshCount; i++)
{
if (source.targetSubmeshIndices[i] >= 0)
{
int[] subTriangles = source.meshData.submeshes[i].triangles;
int triangleLength = subTriangles.Length;
int destMesh = source.targetSubmeshIndices[i];
if (source.triangleMask == null)
{
CopyIntArrayAdd(subTriangles, 0, submeshTriangles[destMesh], subMeshTriangleLength[destMesh], triangleLength, vertexIndex);
subMeshTriangleLength[destMesh] += triangleLength;
}
else
{
MaskedCopyIntArrayAdd(subTriangles, 0, submeshTriangles[destMesh], subMeshTriangleLength[destMesh], triangleLength, vertexIndex, source.triangleMask[i] );
subMeshTriangleLength[destMesh] += (triangleLength - (UMAUtils.GetCardinality(source.triangleMask[i])*3));
}
}
}
vertexIndex += sourceVertexCount;
}
if (vertexCount != vertexIndex)
{
Debug.LogError("Combined vertices size didn't match precomputed value!");
}
// fill in new values.
target.vertexCount = vertexCount;
target.vertices = vertices;
target.unityBoneWeights = boneWeights;
target.bindPoses = bindPoses.ToArray();
target.normals = normals;
target.tangents = tangents;
target.uv = uv;
target.uv2 = uv2;
target.uv3 = uv3;
target.uv4 = uv4;
target.colors32 = colors32;
if (has_blendShapes)
target.blendShapes = blendShapes;
if (has_clothSkinning)
{
Array.Resize(ref clothSkinning, clothVertices.Count);
}
target.clothSkinning = clothSkinning;
target.subMeshCount = subMeshCount;
target.submeshes = new SubMeshTriangles[subMeshCount];
target.umaBones = umaTransforms;
target.umaBoneCount = boneCount;
for (int i = 0; i < subMeshCount; i++)
{
target.submeshes[i].triangles = submeshTriangles[i];
}
target.boneNameHashes = bonesList.ToArray();
}
19
Source : UMAData.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public void ClearDna()
{
umaDna.Clear();
dnaValues.Clear();
}
19
Source : DropdownWithColor.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public void Show()
{
if (!this.IsActive() || !this.IsInteractable() || this.m_Dropdown != null)
{
return;
}
if (!this.validTemplate)
{
this.SetupTemplate();
if (!this.validTemplate)
{
return;
}
}
List<Canvas> list = MyListPool<Canvas>.Get();
base.gameObject.GetComponentsInParent<Canvas>(false, list);
if (list.Count == 0)
{
return;
}
Canvas canvas = list[0];
MyListPool<Canvas>.Release(list);
this.m_Template.gameObject.SetActive(true);
this.m_Dropdown = this.CreateDropdownList(this.m_Template.gameObject);
this.m_Dropdown.name = "Dropdown List";
this.m_Dropdown.SetActive(true);
RectTransform rectTransform = this.m_Dropdown.transform as RectTransform;
rectTransform.SetParent(this.m_Template.transform.parent, false);
DropdownWithColor.DropdownItem componentInChildren = this.m_Dropdown.GetComponentInChildren<DropdownWithColor.DropdownItem>();
GameObject gameObject = componentInChildren.rectTransform.parent.gameObject;
RectTransform rectTransform2 = gameObject.transform as RectTransform;
componentInChildren.rectTransform.gameObject.SetActive(true);
Rect rect = rectTransform2.rect;
Rect rect2 = componentInChildren.rectTransform.rect;
Vector2 vector = rect2.min - rect.min + (Vector2)componentInChildren.rectTransform.localPosition;
Vector2 vector2 = rect2.max - rect.max + (Vector2)componentInChildren.rectTransform.localPosition;
Vector2 size = rect2.size;
this.m_Items.Clear();
Toggle toggle = null;
for (int i = 0; i < this.options.Count; i++)
{
DropdownWithColor.OptionData data = this.options[i];
DropdownWithColor.DropdownItem item = this.AddItem(data, this.value == i, componentInChildren, this.m_Items);
if (!(item == null))
{
item.toggle.isOn = (this.value == i);
item.toggle.onValueChanged.AddListener(delegate (bool x)
{
this.OnSelecreplacedem(item.toggle);
});
if (item.toggle.isOn)
{
item.toggle.Select();
}
if (toggle != null)
{
Navigation navigation = toggle.navigation;
Navigation navigation2 = item.toggle.navigation;
navigation.mode = Navigation.Mode.Explicit;
navigation2.mode = Navigation.Mode.Explicit;
navigation.selectOnDown = item.toggle;
navigation.selectOnRight = item.toggle;
navigation2.selectOnLeft = toggle;
navigation2.selectOnUp = toggle;
toggle.navigation = navigation;
item.toggle.navigation = navigation2;
}
toggle = item.toggle;
}
}
Vector2 sizeDelta = rectTransform2.sizeDelta;
sizeDelta.y = size.y * (float)this.m_Items.Count + vector.y - vector2.y;
rectTransform2.sizeDelta = sizeDelta;
float num = rectTransform.rect.height - rectTransform2.rect.height;
if (num > 0f)
{
rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, rectTransform.sizeDelta.y - num);
}
Vector3[] array = new Vector3[4];
rectTransform.GetWorldCorners(array);
RectTransform rectTransform3 = canvas.transform as RectTransform;
Rect rect3 = rectTransform3.rect;
for (int j = 0; j < 2; j++)
{
bool flag = false;
for (int k = 0; k < 4; k++)
{
Vector3 vector3 = rectTransform3.InverseTransformPoint(array[k]);
if (vector3[j] < rect3.min[j] || vector3[j] > rect3.max[j])
{
flag = true;
break;
}
}
if (flag)
{
RectTransformUtility.FlipLayoutOnAxis(rectTransform, j, false, false);
}
}
for (int l = 0; l < this.m_Items.Count; l++)
{
RectTransform rectTransform4 = this.m_Items[l].rectTransform;
rectTransform4.anchorMin = new Vector2(rectTransform4.anchorMin.x, 0f);
rectTransform4.anchorMax = new Vector2(rectTransform4.anchorMax.x, 0f);
rectTransform4.ancreplaceddPosition = new Vector2(rectTransform4.ancreplaceddPosition.x, vector.y + size.y * (float)(this.m_Items.Count - 1 - l) + size.y * rectTransform4.pivot.y);
rectTransform4.sizeDelta = new Vector2(rectTransform4.sizeDelta.x, size.y);
}
//this.AlphaFadeList(0.15f, 0f, 1f);
this.m_Template.gameObject.SetActive(false);
componentInChildren.gameObject.SetActive(false);
this.m_Blocker = this.CreateBlocker(canvas);
}
19
Source : UMADefaultMeshCombiner.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public override void UpdateUMAMesh(bool updatedAtlas, UMAData umaData, int atlasResolution)
{
this.umaData = umaData;
this.atlasResolution = atlasResolution;
combinedMeshList = new List<SkinnedMeshCombiner.CombineInstance>(umaData.umaRecipe.slotDataList.Length);
combinedMaterialList = new List<Material>();
EnsureUMADataSetup(umaData);
umaData.skeleton.BeginSkeletonUpdate();
for (currentRendererIndex = 0; currentRendererIndex < umaData.generatedMaterials.rendererCount; currentRendererIndex++)
{
//Move umaMesh creation to with in the renderer loops
//May want to make sure to set all it's buffers to null instead of creating a new UMAMeshData
UMAMeshData umaMesh = new UMAMeshData();
umaMesh.ClaimSharedBuffers();
umaMesh.subMeshCount = 0;
umaMesh.vertexCount = 0;
combinedMeshList.Clear();
combinedMaterialList.Clear();
clothProperties = null;
BuildCombineInstances();
if (combinedMeshList.Count == 1)
{
// fast track
var tempMesh = SkinnedMeshCombiner.ShallowInstanceMesh(combinedMeshList[0].meshData);
tempMesh.ApplyDataToUnityMesh(renderers[currentRendererIndex], umaData.skeleton);
}
else
{
SkinnedMeshCombiner.CombineMeshes(umaMesh, combinedMeshList.ToArray(), umaData.blendShapeSettings );
if (updatedAtlas)
{
RecalculateUV(umaMesh);
}
umaMesh.ApplyDataToUnityMesh(renderers[currentRendererIndex], umaData.skeleton);
}
var cloth = renderers[currentRendererIndex].GetComponent<Cloth>();
if (clothProperties != null)
{
if (cloth != null)
{
clothProperties.ApplyValues(cloth);
}
}
else
{
UMAUtils.DestroySceneObject(cloth);
}
var materials = combinedMaterialList.ToArray();
renderers[currentRendererIndex].sharedMaterials = materials;
umaMesh.ReleaseSharedBuffers();
}
umaData.umaRecipe.ClearDNAConverters();
for (int i = 0; i < umaData.umaRecipe.slotDataList.Length; i++)
{
SlotData slotData = umaData.umaRecipe.slotDataList[i];
if (slotData != null)
{
umaData.umaRecipe.AddDNAUpdater(slotData.replacedet.slotDNA);
}
}
umaData.firstBake = false;
}
19
Source : UMAGeneratorBase.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
private static void SkeletonModifier(UMAData umaData, ref SkeletonBone[] bones, HumanBone[] human)
{
int missingBoneCount = 0;
newBones.Clear();
while (!umaData.skeleton.HasBone(UMAUtils.StringToHash(bones[missingBoneCount].name)))
{
missingBoneCount++;
}
if (missingBoneCount > 0)
{
// force the two root transforms, reuse old bones entries to ensure any humanoid identifiers stay intact
var realRootBone = umaData.transform;
var newBone = bones[missingBoneCount - 2];
newBone.position = realRootBone.localPosition;
newBone.rotation = realRootBone.localRotation;
newBone.scale = realRootBone.localScale;
// Debug.Log(newBone.name + "<-"+realRootBone.name);
newBone.name = realRootBone.name;
newBones.Add(newBone);
var rootBoneTransform = umaData.umaRoot.transform;
newBone = bones[missingBoneCount - 1];
newBone.position = rootBoneTransform.localPosition;
newBone.rotation = rootBoneTransform.localRotation;
newBone.scale = rootBoneTransform.localScale;
// Debug.Log(newBone.name + "<-" + rootBoneTransform.name);
newBone.name = rootBoneTransform.name;
newBones.Add(newBone);
}
for (var i = missingBoneCount; i < bones.Length; i++)
{
var skeletonbone = bones[i];
int boneHash = UMAUtils.StringToHash(skeletonbone.name);
GameObject boneGO = umaData.skeleton.GetBoneGameObject(boneHash);
if (boneGO != null)
{
skeletonbone.position = boneGO.transform.localPosition;
skeletonbone.scale = boneGO.transform.localScale;
skeletonbone.rotation = umaData.skeleton.GetTPoseCorrectedRotation(boneHash, skeletonbone.rotation);
newBones.Add(skeletonbone);
}
}
bones = newBones.ToArray();
}
19
Source : UMAGeneratorCoroutine.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
protected override void Start()
{
if (generatedMaterialLookup == null)
{
generatedMaterialLookup = new Dictionary<List<OverlayData>, UMAData.GeneratedMaterial>(20);
}
else
{
generatedMaterialLookup.Clear();
}
backUpTexture = umaData.backUpTextures();
umaData.CleanTextures();
generatedMaterials = new List<UMAData.GeneratedMaterial>(20);
atlreplacededMaterials.Clear();
rendererCount = 0;
SlotData[] slots = umaData.umaRecipe.slotDataList;
for (int i = 0; i < slots.Length; i++)
{
var slot = slots[i];
if (slot == null)
continue;
if ((slot.replacedet.material != null) && (slot.GetOverlay(0) != null))
{
if (!slot.replacedet.material.RequireSeperateRenderer)
{
// At least one slot that doesn't require a seperate renderer, so we reserve renderer 0 for those.
rendererCount = 1;
break;
}
}
}
for (int i = 0; i < slots.Length; i++)
{
SlotData slot = slots[i];
if (slot == null)
continue;
// Let's only add the default overlay if the slot has overlays and NO meshData
if ((slot.replacedet.meshData != null) && (slot.OverlayCount == 0))
{
if (umaGenerator.defaultOverlaydata != null)
slot.AddOverlay(umaGenerator.defaultOverlaydata);
}
OverlayData overlay0 = slot.GetOverlay(0);
if ((slot.replacedet.material != null) && (overlay0 != null))
{
List<OverlayData> overlayList = slot.GetOverlayList();
UMAData.GeneratedMaterial generatedMaterial;
if (!generatedMaterialLookup.TryGetValue(overlayList, out generatedMaterial))
{
generatedMaterial = FindOrCreateGeneratedMaterial(slot.replacedet.material);
generatedMaterialLookup.Add(overlayList, generatedMaterial);
}
int validOverlayCount = 0;
for (int j = 0; j < slot.OverlayCount; j++)
{
var overlay = slot.GetOverlay(j);
if (overlay != null)
{
validOverlayCount++;
#if UNITY_STANDALONE || UNITY_IOS || UNITY_ANDROID || UNITY_PS4 || UNITY_XBOXONE //supported platforms for procedural materials
if (overlay.isProcedural)
overlay.GenerateProceduralTextures();
#endif
}
}
UMAData.MaterialFragment tempMaterialDefinition = new UMAData.MaterialFragment();
tempMaterialDefinition.baseOverlay = new UMAData.textureData();
tempMaterialDefinition.baseOverlay.textureList = overlay0.textureArray;
tempMaterialDefinition.baseOverlay.alphaTexture = overlay0.alphaMask;
tempMaterialDefinition.baseOverlay.overlayType = overlay0.overlayType;
tempMaterialDefinition.umaMaterial = slot.replacedet.material;
tempMaterialDefinition.baseColor = overlay0.colorData.color;
tempMaterialDefinition.size = overlay0.pixelCount;
tempMaterialDefinition.overlays = new UMAData.textureData[validOverlayCount - 1];
tempMaterialDefinition.overlayColors = new Color32[validOverlayCount - 1];
tempMaterialDefinition.rects = new Rect[validOverlayCount - 1];
tempMaterialDefinition.overlayData = new OverlayData[validOverlayCount];
tempMaterialDefinition.channelMask = new Color[validOverlayCount][];
tempMaterialDefinition.channelAdditiveMask = new Color[validOverlayCount][];
tempMaterialDefinition.overlayData[0] = slot.GetOverlay(0);
tempMaterialDefinition.channelMask[0] = slot.GetOverlay(0).colorData.channelMask;
tempMaterialDefinition.channelAdditiveMask[0] = slot.GetOverlay(0).colorData.channelAdditiveMask;
tempMaterialDefinition.slotData = slot;
int overlayID = 0;
for (int j = 1; j < slot.OverlayCount; j++)
{
OverlayData overlay = slot.GetOverlay(j);
if (overlay == null)
continue;
tempMaterialDefinition.rects[overlayID] = overlay.rect;
tempMaterialDefinition.overlays[overlayID] = new UMAData.textureData();
tempMaterialDefinition.overlays[overlayID].textureList = overlay.textureArray;
tempMaterialDefinition.overlays[overlayID].alphaTexture = overlay.alphaMask;
tempMaterialDefinition.overlays[overlayID].overlayType = overlay.overlayType;
tempMaterialDefinition.overlayColors[overlayID] = overlay.colorData.color;
overlayID++;
tempMaterialDefinition.overlayData[overlayID] = overlay;
tempMaterialDefinition.channelMask[overlayID] = overlay.colorData.channelMask;
tempMaterialDefinition.channelAdditiveMask[overlayID] = overlay.colorData.channelAdditiveMask;
}
tempMaterialDefinition.overlayList = overlayList;
tempMaterialDefinition.isRectShared = false;
for (int j = 0; j < generatedMaterial.materialFragments.Count; j++)
{
if (tempMaterialDefinition.overlayList == generatedMaterial.materialFragments[j].overlayList)
{
tempMaterialDefinition.isRectShared = true;
tempMaterialDefinition.rectFragment = generatedMaterial.materialFragments[j];
break;
}
}
generatedMaterial.materialFragments.Add(tempMaterialDefinition);
}
}
packTexture = new MaxRectsBinPack(umaGenerator.atlasResolution, umaGenerator.atlasResolution, false);
}
19
Source : WardrobeCollectionLibrary.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public void AddCollections(UMAWardrobeCollection[] uwcs, string filename = "")
{
foreach (UMAWardrobeCollection uwc in uwcs)
{
if (uwc == null)
continue;
if (filename == "" || (filename != "" && filename.Trim() == uwc.name))
{
if (!collectionIndex.ContainsKey(uwc.name))
{
collectionIndex.Add(uwc.name, uwc);
}
else
{
collectionIndex[uwc.name] = uwc;
}
}
}
//sync up the list
collectionList.Clear();
foreach (KeyValuePair<string, UMAWardrobeCollection> kp in collectionIndex)
{
collectionList.Add(kp.Value);
}
//TODO if the collection is 'unlocked/downloaded' add its contents to DCS
//for this though we would need to maintain a list in player prefs so I'm not going to do that in this demo
}
19
Source : DNAPanel.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public void Initialize (DynamicCharacterAvatar Avatar)
{
foreach(GameObject go in CreatedObjects) UMAUtils.DestroySceneObject(go);
CreatedObjects.Clear();
UMADnaBase[] DNA = Avatar.GetAllDNA();
List<DNAHolder> ValidDNA = new List<DNAHolder>();
foreach (UMADnaBase d in DNA)
{
string[] names = d.Names;
float[] values = d.Values;
for (int i=0;i<names.Length;i++)
{
string name = names[i];
if (IsThisCategory(name.ToLower()))
{
ValidDNA.Add(new DNAHolder(name,values[i],i,d));
}
}
}
ValidDNA.Sort( );
foreach(DNAHolder dna in ValidDNA)
{
GameObject go = GameObject.Instantiate(DnaEditor);
go.transform.SetParent(ContentArea.transform);
go.transform.localScale = new Vector3(1f, 1f, 1f);//Set the scale back to 1
DNAEditor de = go.GetComponentInChildren<DNAEditor>();
de.Initialize(dna.name.BreakupCamelCase(),dna.index,dna.dnaBase,Avatar,dna.value);
go.SetActive(true);
CreatedObjects.Add(go);
}
}
19
Source : DropdownWithColor.cs
with Apache License 2.0
from A7ocin
with Apache License 2.0
from A7ocin
public void ClearOptions()
{
this.options.Clear();
this.RefreshShownValue();
}
19
Source : AnimationNodeEditor.cs
with MIT License
from aarthificial
with MIT License
from aarthificial
protected virtual void UpdateSpritesCache()
{
Sprites.Clear();
for (var i = 0; i < Cels.arraySize; i++)
{
var frameProp = Cels.GetArrayElementAtIndex(i);
var sprite = frameProp.FindPropertyRelative("sprite").objectReferenceValue as Sprite;
if (sprite != null)
Sprites.Add(sprite);
}
}
19
Source : MirroredAnimationNodeEditor.cs
with MIT License
from aarthificial
with MIT License
from aarthificial
protected override void UpdateSpritesCache()
{
Sprites.Clear();
SpritesLeft.Clear();
for (var i = 0; i < Cels.arraySize; i++)
{
var frameProp = Cels.GetArrayElementAtIndex(i);
var sprite = frameProp.FindPropertyRelative("sprite").objectReferenceValue as Sprite;
if (sprite != null)
Sprites.Add(sprite);
var spriteLeft = frameProp.FindPropertyRelative("spriteLeft").objectReferenceValue as Sprite;
if (spriteLeft != null)
SpritesLeft.Add(spriteLeft);
}
}
19
Source : KeyValuePointerBuffer.cs
with MIT License
from Abc-Arbitrage
with MIT License
from Abc-Arbitrage
public void Clear()
=> _keyPointers.Clear();
19
Source : RandomWeaponGeneratorWindow.cs
with MIT License
from Abdelfattah-Radwan
with MIT License
from Abdelfattah-Radwan
private void LoadreplacedetReferences()
{
templates?.Clear();
weaponBases?.Clear();
stocks?.Clear();
grips?.Clear();
magazines?.Clear();
scopes?.Clear();
barrels?.Clear();
string filePath = Path.Combine("Temp", replacedET_REFERENCES_INSTANCE_IDS_FILE_NAME);
if (File.Exists(filePath))
{
List<int>[] lists = new List<int>[0];
using (FileStream fileStream = new FileStream(filePath, FileMode.Open))
{
lists = new BinaryFormatter().Deserialize(fileStream) as List<int>[];
}
lists[0].ForEach(id => templates?.Add(replacedetDatabase.LoadreplacedetAtPath<WeaponPropertiesTemplate>(replacedetDatabase.GetreplacedetPath(id))));
lists[1].ForEach(id => weaponBases?.Add(replacedetDatabase.LoadreplacedetAtPath<WeaponBase>(replacedetDatabase.GetreplacedetPath(id))));
lists[2].ForEach(id => stocks?.Add(replacedetDatabase.LoadreplacedetAtPath<GameObject>(replacedetDatabase.GetreplacedetPath(id))));
lists[3].ForEach(id => grips?.Add(replacedetDatabase.LoadreplacedetAtPath<GameObject>(replacedetDatabase.GetreplacedetPath(id))));
lists[4].ForEach(id => magazines?.Add(replacedetDatabase.LoadreplacedetAtPath<GameObject>(replacedetDatabase.GetreplacedetPath(id))));
lists[5].ForEach(id => scopes?.Add(replacedetDatabase.LoadreplacedetAtPath<GameObject>(replacedetDatabase.GetreplacedetPath(id))));
lists[6].ForEach(id => barrels?.Add(replacedetDatabase.LoadreplacedetAtPath<GameObject>(replacedetDatabase.GetreplacedetPath(id))));
}
}
19
Source : FoldingMargin.cs
with MIT License
from Abdesol
with MIT License
from Abdesol
void TextViewVisualLinesChanged(object sender, EventArgs e)
{
foreach (FoldingMarginMarker m in markers) {
RemoveVisualChild(m);
}
markers.Clear();
InvalidateVisual();
if (TextView != null && FoldingManager != null && TextView.VisualLinesValid) {
foreach (VisualLine line in TextView.VisualLines) {
FoldingSection fs = FoldingManager.GetNextFolding(line.FirstDoreplacedentLine.Offset);
if (fs == null)
continue;
if (fs.StartOffset <= line.LastDoreplacedentLine.Offset + line.LastDoreplacedentLine.Length) {
FoldingMarginMarker m = new FoldingMarginMarker {
IsExpanded = !fs.IsFolded,
VisualLine = line,
FoldingSection = fs
};
markers.Add(m);
AddVisualChild(m);
m.IsMouseDirectlyOverChanged += delegate { InvalidateVisual(); };
InvalidateMeasure();
continue;
}
}
}
}
19
Source : HeightTree.cs
with MIT License
from Abdesol
with MIT License
from Abdesol
void EndRemoval()
{
Debug.replacedert(inRemoval);
inRemoval = false;
foreach (HeightTreeNode node in nodesToCheckForMerging) {
MergeCollapsedSectionsIfPossible(node);
}
nodesToCheckForMerging.Clear();
}
19
Source : TextLayer.cs
with MIT License
from Abdesol
with MIT License
from Abdesol
internal void SetVisualLines(ICollection<VisualLine> visualLines)
{
foreach (VisualLineDrawingVisual v in visuals) {
if (v.VisualLine.IsDisposed)
RemoveVisualChild(v);
}
visuals.Clear();
foreach (VisualLine newLine in visualLines) {
VisualLineDrawingVisual v = newLine.Render();
if (!v.IsAdded) {
AddVisualChild(v);
v.IsAdded = true;
}
visuals.Add(v);
}
InvalidateArrange();
}
19
Source : ShapePolyLineM.cs
with Microsoft Public License
from abfo
with Microsoft Public License
from abfo
private void ParsePolyLineM(byte[] shapeData, out RectangleD boundingBox, out List<PointD[]> parts)
{
boundingBox = new RectangleD();
parts = null;
// metadata is validated by the base clreplaced
if (shapeData == null)
{
throw new ArgumentNullException("shapeData");
}
// Note, shapeData includes an 8 byte header so positions below are +8
// Position Field Value Type Number Order
// Byte 0 Shape Type 23 Integer 1 Little
// Byte 4 Box Box Double 4 Little
// Byte 36 NumParts NumParts Integer 1 Little
// Byte 40 NumPoints NumPoints Integer 1 Little
// Byte 44 Parts Parts Integer NumParts Little
// Byte X Points Points Point NumPoints Little
// Byte Y* Mmin Mmin Double 1 Little
// Byte Y + 8* Mmax Mmax Double 1 Little
// Byte Y + 16* Marray Marray Double NumPoints Little
//
// *optional
// validation step 1 - must have at least 8 + 4 + (4*8) + 4 + 4 bytes = 52
if (shapeData.Length < 44)
{
throw new InvalidOperationException("Invalid shape data");
}
// extract bounding box, number of parts and number of points
boundingBox = ParseBoundingBox(shapeData, 12, ProvidedOrder.Little);
int numParts = EndianBitConverter.ToInt32(shapeData, 44, ProvidedOrder.Little);
int numPoints = EndianBitConverter.ToInt32(shapeData, 48, ProvidedOrder.Little);
// validation step 2 - we're expecting 4 * numParts + (16 + 8 * numPoints for m extremes and values) + 16 * numPoints + 52 bytes total
if (shapeData.Length != 52 + (4 * numParts) + 16 + 8 * numPoints + (16 * numPoints))
{
throw new InvalidOperationException("Invalid shape data");
}
// now extract the parts
int partsOffset = 52 + (4 * numParts);
parts = new List<PointD[]>(numParts);
for (int part = 0; part < numParts; part++)
{
// this is the index of the start of the part in the points array
int startPart = (EndianBitConverter.ToInt32(shapeData, 52 + (4 * part), ProvidedOrder.Little) * 16) + partsOffset;
int numBytes;
if (part == numParts - 1)
{
// it's the last part so we go to the end of the point array
numBytes = shapeData.Length - startPart;
// remove bytes for M extreme block
numBytes -= numPoints * 8 + 16;
}
else
{
// we need to get the next part
int nextPart = (EndianBitConverter.ToInt32(shapeData, 52 + (4 * (part + 1)), ProvidedOrder.Little) * 16) + partsOffset;
numBytes = nextPart - startPart;
}
// the number of 16-byte points to read for this segment
int numPointsInPart = (numBytes) / 16;
PointD[] points = new PointD[numPointsInPart];
for (int point = 0; point < numPointsInPart; point++)
{
points[point] = new PointD(EndianBitConverter.ToDouble(shapeData, startPart + (16 * point), ProvidedOrder.Little),
EndianBitConverter.ToDouble(shapeData, startPart + 8 + (16 * point), ProvidedOrder.Little));
}
parts.Add(points);
}
// parse M information
Mmin = EndianBitConverter.ToDouble(shapeData, 52 + (4 * numParts) + (16 * numPoints), ProvidedOrder.Little);
Mmax = EndianBitConverter.ToDouble(shapeData, 52 + 8 + (4 * numParts) + (16 * numPoints), ProvidedOrder.Little);
M.Clear();
for (int i = 0; i < numPoints; i++)
{
double _m = EndianBitConverter.ToDouble(shapeData, 52 + 16 + (4 * numParts) + (16 * numPoints) + i * 8, ProvidedOrder.Little);
M.Add(_m);
}
}
19
Source : MixedRealityControllerMappingProfileInspector.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
private void RenderControllerList(SerializedProperty controllerList)
{
if (thisProfile.MixedRealityControllerMappings.Length != controllerList.arraySize) { return; }
if (InspectorUIUtility.RenderIndentedButton(ControllerAddButtonContent, EditorStyles.miniButton))
{
AddController(controllerList, typeof(GenericJoystickController));
return;
}
controllerRenderList.Clear();
showControllerDefinitions = EditorGUILayout.Foldout(showControllerDefinitions, "Controller Definitions", true);
if (showControllerDefinitions)
{
using (var outerVerticalScope = new GUILayout.VerticalScope())
{
GUILayout.HorizontalScope horizontalScope = null;
for (int i = 0; i < thisProfile.MixedRealityControllerMappings.Length; i++)
{
MixedRealityControllerMapping controllerMapping = thisProfile.MixedRealityControllerMappings[i];
Type controllerType = controllerMapping.ControllerType;
if (controllerType == null) { continue; }
Handedness handedness = controllerMapping.Handedness;
bool useCustomInteractionMappings = controllerMapping.HasCustomInteractionMappings;
SupportedControllerType supportedControllerType = controllerMapping.SupportedControllerType;
var controllerMappingProperty = controllerList.GetArrayElementAtIndex(i);
var handednessProperty = controllerMappingProperty.FindPropertyRelative("handedness");
#region Profile Migration
// Between MRTK v2 RC2 and GA, the HoloLens clicker and HoloLens voice select input were migrated from
// SupportedControllerType.WindowsMixedReality && Handedness.None to SupportedControllerType.GGVHand && Handedness.None
if (supportedControllerType == SupportedControllerType.WindowsMixedReality && handedness == Handedness.None)
{
for (int j = 0; j < thisProfile.MixedRealityControllerMappings.Length; j++)
{
if (thisProfile.MixedRealityControllerMappings[j].SupportedControllerType == SupportedControllerType.GGVHand &&
thisProfile.MixedRealityControllerMappings[j].Handedness == Handedness.None)
{
if (horizontalScope != null) { horizontalScope.Dispose(); horizontalScope = null; }
serializedObject.ApplyModifiedProperties();
for (int k = 0; k < controllerMapping.Interactions.Length; k++)
{
MixedRealityInteractionMapping currentMapping = controllerMapping.Interactions[k];
if (currentMapping.InputType == DeviceInputType.Select)
{
thisProfile.MixedRealityControllerMappings[j].Interactions[0].MixedRealityInputAction = currentMapping.MixedRealityInputAction;
}
else if (currentMapping.InputType == DeviceInputType.SpatialGrip)
{
thisProfile.MixedRealityControllerMappings[j].Interactions[1].MixedRealityInputAction = currentMapping.MixedRealityInputAction;
}
}
serializedObject.Update();
controllerList.DeleteArrayElementAtIndex(i);
EditorUtility.DisplayDialog("Mappings updated", "The \"HoloLens Voice and Clicker\" mappings have been migrated to a new serialization. Please save this replacedet.", "Okay, thanks!");
return;
}
}
}
#endregion Profile Migration
if (!useCustomInteractionMappings)
{
bool skip = false;
// Merge controllers with the same supported controller type.
for (int j = 0; j < controllerRenderList.Count; j++)
{
if (controllerRenderList[j].SupportedControllerType == supportedControllerType &&
controllerRenderList[j].Handedness == handedness)
{
try
{
thisProfile.MixedRealityControllerMappings[i].SynchronizeInputActions(controllerRenderList[j].Interactions);
}
catch (ArgumentException e)
{
Debug.LogError($"Controller mappings between {thisProfile.MixedRealityControllerMappings[i].Description} and {controllerMapping.Description} do not match. Error message: {e.Message}");
}
serializedObject.ApplyModifiedProperties();
skip = true;
}
}
if (skip) { continue; }
}
controllerRenderList.Add(new ControllerRenderProfile(supportedControllerType, handedness, thisProfile.MixedRealityControllerMappings[i].Interactions));
string controllerreplacedle = thisProfile.MixedRealityControllerMappings[i].Description;
var interactionsProperty = controllerMappingProperty.FindPropertyRelative("interactions");
if (useCustomInteractionMappings)
{
if (horizontalScope != null) { horizontalScope.Dispose(); horizontalScope = null; }
GUILayout.Space(24f);
using (var verticalScope = new GUILayout.VerticalScope())
{
using (horizontalScope = new GUILayout.HorizontalScope())
{
EditorGUILayout.LabelField(controllerreplacedle, EditorStyles.boldLabel);
if (GUILayout.Button(ControllerMinusButtonContent, EditorStyles.miniButtonRight, GUILayout.Width(24f)))
{
controllerList.DeleteArrayElementAtIndex(i);
return;
}
}
EditorGUI.BeginChangeCheck();
// Generic Type dropdown
Type[] genericTypes = MixedRealityControllerMappingProfile.CustomControllerMappingTypes;
var genericTypeListContent = new GUIContent[genericTypes.Length];
var genericTypeListIds = new int[genericTypes.Length];
int currentGenericType = -1;
for (int genericTypeIdx = 0; genericTypeIdx < genericTypes.Length; genericTypeIdx++)
{
var attribute = MixedRealityControllerAttribute.Find(genericTypes[genericTypeIdx]);
if (attribute != null)
{
genericTypeListContent[genericTypeIdx] = new GUIContent(attribute.SupportedControllerType.ToString().Replace("Generic", "").ToProperCase() + " Controller");
}
else
{
genericTypeListContent[genericTypeIdx] = new GUIContent("Unknown Controller");
}
genericTypeListIds[genericTypeIdx] = genericTypeIdx;
if (controllerType == genericTypes[genericTypeIdx])
{
currentGenericType = genericTypeIdx;
}
}
Debug.replacedert(currentGenericType != -1);
currentGenericType = EditorGUILayout.IntPopup(GenericTypeContent, currentGenericType, genericTypeListContent, genericTypeListIds);
controllerType = genericTypes[currentGenericType];
{
// Handedness dropdown
var attribute = MixedRealityControllerAttribute.Find(controllerType);
if (attribute != null && attribute.SupportedHandedness.Length >= 1)
{
// Make sure handedness is valid for the selected controller type.
if (Array.IndexOf(attribute.SupportedHandedness, (Handedness)handednessProperty.intValue) < 0)
{
handednessProperty.intValue = (int)attribute.SupportedHandedness[0];
}
if (attribute.SupportedHandedness.Length >= 2)
{
var handednessListContent = new GUIContent[attribute.SupportedHandedness.Length];
var handednessListIds = new int[attribute.SupportedHandedness.Length];
for (int handednessIdx = 0; handednessIdx < attribute.SupportedHandedness.Length; handednessIdx++)
{
handednessListContent[handednessIdx] = new GUIContent(attribute.SupportedHandedness[handednessIdx].ToString());
handednessListIds[handednessIdx] = (int)attribute.SupportedHandedness[handednessIdx];
}
handednessProperty.intValue = EditorGUILayout.IntPopup(HandednessTypeContent, handednessProperty.intValue, handednessListContent, handednessListIds);
}
}
else
{
handednessProperty.intValue = (int)Handedness.None;
}
}
if (EditorGUI.EndChangeCheck())
{
interactionsProperty.ClearArray();
serializedObject.ApplyModifiedProperties();
thisProfile.MixedRealityControllerMappings[i].ControllerType.Type = genericTypes[currentGenericType];
thisProfile.MixedRealityControllerMappings[i].SetDefaultInteractionMapping(true);
serializedObject.ApplyModifiedProperties();
return;
}
if (InspectorUIUtility.RenderIndentedButton("Edit Input Action Map"))
{
ControllerPopupWindow.Show(controllerMapping, interactionsProperty, handedness);
}
if (InspectorUIUtility.RenderIndentedButton("Reset Input Actions"))
{
interactionsProperty.ClearArray();
serializedObject.ApplyModifiedProperties();
thisProfile.MixedRealityControllerMappings[i].SetDefaultInteractionMapping(true);
serializedObject.ApplyModifiedProperties();
}
}
}
else
{
if (handedness != Handedness.Right)
{
if (horizontalScope != null) { horizontalScope.Dispose(); horizontalScope = null; }
horizontalScope = new GUILayout.HorizontalScope();
}
var buttonContent = new GUIContent(controllerreplacedle, ControllerMappingLibrary.GetControllerTextureScaled(controllerType, handedness));
if (GUILayout.Button(buttonContent, MixedRealityStylesUtility.ControllerButtonStyle, GUILayout.Height(128f), GUILayout.MinWidth(32f), GUILayout.ExpandWidth(true)))
{
ControllerPopupWindow.Show(controllerMapping, interactionsProperty, handedness);
}
}
}
if (horizontalScope != null) { horizontalScope.Dispose(); horizontalScope = null; }
}
}
}
19
Source : SceneInfoUtils.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
private static void RefreshCachedTypes()
{
if (EditorApplication.isCompiling || BuildPipeline.isBuildingPlayer)
{ // Don't refresh cached types if we're in the middle of something important
return;
}
cachedComponentTypes.Clear();
foreach (replacedembly replacedembly in AppDomain.CurrentDomain.Getreplacedemblies())
{
foreach (Type t in replacedembly.GetTypes().Where(t => t.IsSubclreplacedOf(typeof(Component))))
{
foreach (FieldInfo f in t.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
{
if (fieldTypesToSearch.Contains(f.FieldType))
{
cachedComponentTypes.Add(new Tuple<Type, FieldInfo>(t, f));
}
}
}
}
}
19
Source : UnityTouchDeviceManager.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
public override void Update()
{
using (UpdatePerfMarker.Auto())
{
base.Update();
// Ensure that touch up and source lost events are at least one frame apart.
for (int i = 0; i < touchesToRemove.Count; i++)
{
IMixedRealityController controller = touchesToRemove[i];
Service?.RaiseSourceLost(controller.InputSource, controller);
}
touchesToRemove.Clear();
int touchCount = UInput.touchCount;
for (int i = 0; i < touchCount; i++)
{
Touch touch = UInput.touches[i];
// Construct a ray from the current touch coordinates
Ray ray = CameraCache.Main.ScreenPointToRay(touch.position);
switch (touch.phase)
{
case TouchPhase.Began:
AddTouchController(touch, ray);
break;
case TouchPhase.Moved:
case TouchPhase.Stationary:
UpdateTouchData(touch, ray);
break;
case TouchPhase.Ended:
case TouchPhase.Canceled:
RemoveTouchController(touch);
break;
}
}
}
}
19
Source : InputMappingAxisUtility.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
private static void RefreshLocalAxesList()
{
EnsureInputManagerReference();
AxisNames.Clear();
SerializedProperty axesProperty = inputManagerreplacedet.FindProperty("m_Axes");
for (int i = 0; i < axesProperty.arraySize; i++)
{
AxisNames.Add(axesProperty.GetArrayElementAtIndex(i).displayName);
}
}
19
Source : StripMeshLineRenderer.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
protected override void UpdateLine()
{
if (stripMeshRenderer == null)
{
Debug.LogError("Strip mesh renderer has been destroyed - disabling");
enabled = false;
}
if (!LineDataSource.enabled)
{
stripMeshRenderer.enabled = false;
return;
}
stripMeshRenderer.enabled = true;
positions.Clear();
forwards.Clear();
colors.Clear();
widths.Clear();
for (int i = 0; i <= LineStepCount; i++)
{
float normalizedDistance = GetNormalizedPointAlongLine(i);
positions.Add(LineDataSource.GetPoint(normalizedDistance));
colors.Add(GetColor(normalizedDistance));
widths.Add(GetWidth(normalizedDistance));
forwards.Add(LineDataSource.GetVelocity(normalizedDistance));
}
GenerateStripMesh(positions, colors, widths, uvOffset, forwards, stripMesh, LineDataSource.LineTransform.up);
}
19
Source : MixedRealityServiceRegistry.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
public static void ClearAllServices()
{
if (registry != null)
{
registry.Clear();
allServices.Clear();
allServicesByRegistrar.Clear();
}
}
19
Source : ServiceFacadeInspector.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
private bool DrawDataProviders(Type serviceType)
{
// If this is a data provider being used by other services, mention that now
dataProviderList.Clear();
foreach (MixedRealityDataProviderAttribute dataProviderAttribute in serviceType.GetCustomAttributes(typeof(MixedRealityDataProviderAttribute), true))
{
dataProviderList.Add(" • " + dataProviderAttribute.ServiceInterfaceType.Name);
}
if (dataProviderList.Count > 0)
{
EditorGUILayout.HelpBox("This data provider is used by the following services:\n " + String.Join("\n", dataProviderList.ToArray()), MessageType.Info);
EditorGUILayout.Space();
return true;
}
return false;
}
19
Source : MixedRealitySearchInspectorUtility.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
public static bool DrawSearchInterface(UnityEngine.Object target)
{
if (target == null)
{
return false;
}
bool drewSearchGUI = false;
if (target != activeTarget)
{
activeTarget = target;
config = new SearchConfig();
prevConfig = new SearchConfig();
searchResults.Clear();
}
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.LabelField("Search For: ", GUILayout.MaxWidth(70));
string searchString = SessionState.GetString(searchDisplaySearchFieldKey, string.Empty);
config.SearchFieldString = EditorGUILayout.TextField(SessionState.GetString(searchDisplaySearchFieldKey, string.Empty), GUILayout.ExpandWidth(true));
if (GUILayout.Button("Clear", EditorStyles.miniButton, GUILayout.MaxWidth(50)))
{
config.SearchFieldString = string.Empty;
}
}
config.RequireAllKeywords = SessionState.GetBool(searchDisplayRequireAllKeywordsKey, true);
config.SearchTooltips = SessionState.GetBool(searchDisplaySearchTooltipsKey, true);
config.SearchFieldContent = SessionState.GetBool(searchDisplaySearchFieldContentKey, false);
if (!string.IsNullOrEmpty(config.SearchFieldString))
{
// If we're searching for something, draw the search GUI
DrawSearchResultInterface(target);
drewSearchGUI = true;
}
// Store search settings
SessionState.SetString(searchDisplaySearchFieldKey, config.SearchFieldString);
SessionState.SetBool(searchDisplayRequireAllKeywordsKey, config.RequireAllKeywords);
SessionState.SetBool(searchDisplaySearchTooltipsKey, config.SearchTooltips);
SessionState.SetBool(searchDisplaySearchFieldContentKey, config.SearchFieldContent);
return drewSearchGUI;
}
19
Source : BaseEventSystem.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
public virtual void HandleEvent<T>(BaseEventData eventData, ExecuteEvents.EventFunction<T> eventHandler) where T : IEventSystemHandler
{
Debug.replacedert(!eventData.used);
eventExecutionDepth++;
// This sends the event to every component that implements the corresponding event handling interface,
// regardless of whether it was the one registering the object as global listener or not.
// This behavior is kept for backwards compatibility. Will be removed together with the IMixedRealityEventSystem.Register(GameObject listener) interface.
for (int i = EventListeners.Count - 1; i >= 0; i--)
{
// Ensure client code does not put the event dispatch system into a bad state.
// Note that ExecuteEvents.Execute internally safeguards against exceptions, but
// this is another layer to ensure that nothing below this layer can affect the state
// of our eventExecutionDepth tracker.
try
{
ExecuteEvents.Execute(EventListeners[i], eventData, eventHandler);
}
catch (Exception ex)
{
Debug.LogException(ex);
}
}
// Send events to all handlers registered via RegisterHandler API.
List<EventHandlerEntry> handlers;
if (EventHandlersByType.TryGetValue(typeof(T), out handlers))
{
for (int i = handlers.Count - 1; i >= 0; i--)
{
var handlerEntry = handlers[i];
// If handler's parent is in object collection (traversed above), it has already received an event.
if (handlerEntry.parentObjectIsInObjectCollection)
{
continue;
}
// Ensure client code does not put the event dispatch system into a bad state.
try
{
eventHandler.Invoke((T)handlerEntry.handler, eventData);
}
catch (Exception ex)
{
Debug.LogException(ex);
}
}
}
eventExecutionDepth--;
if (eventExecutionDepth == 0 && (postponedActions.Count > 0 || postponedObjectActions.Count > 0))
{
foreach (var handler in postponedActions)
{
if (handler.Item1 == Action.Add)
{
AddHandlerToMap(handler.Item2, handler.Item3);
}
else if (handler.Item1 == Action.Remove)
{
RemoveHandlerFromMap(handler.Item2, handler.Item3);
}
}
foreach (var obj in postponedObjectActions)
{
if (obj.Item1 == Action.Add)
{
// Can call it here, because guaranteed that eventExecutionDepth is 0
Register(obj.Item2);
}
else if (obj.Item1 == Action.Remove)
{
Unregister(obj.Item2);
}
}
postponedActions.Clear();
postponedObjectActions.Clear();
}
}
19
Source : MeshLineRenderer.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
protected override void UpdateLine()
{
if (!Application.isPlaying)
{ // This check is only necessary in edit mode.
if (!IsInitialized)
{
enabled = false;
return;
}
}
if (LineDataSource.enabled)
{
meshTransforms.Clear();
colorValues.Clear();
linePropertyBlock.Clear();
int skipCount = 0;
for (int i = 0; i < LineStepCount; i++)
{
if (lineStepSkip > 0)
{
skipCount++;
if (skipCount < lineStepSkip)
continue;
skipCount = 0;
}
float normalizedDistance = GetNormalizedPointAlongLine(i);
colorValues.Add(GetColor(normalizedDistance));
meshTransforms.Add(Matrix4x4.TRS(LineDataSource.GetPoint(normalizedDistance), LineDataSource.GetRotation(normalizedDistance), Vector3.one * GetWidth(normalizedDistance)));
}
if (useVertexColors)
{
colorId = Shader.PropertyToID(colorProperty);
linePropertyBlock.SetVectorArray(colorId, colorValues);
}
Graphics.DrawMeshInstanced(lineMesh, 0, lineMaterial, meshTransforms, linePropertyBlock);
}
}
19
Source : MixedRealitySearchInspectorUtility.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
private static void OnSearchComplete(bool cancelled, UnityEngine.Object target, IReadOnlyCollection<ProfileSearchResult> results)
{
searchResults.Clear();
if (cancelled || target != MixedRealitySearchInspectorUtility.activeTarget)
{ // We've started searching something else, ignore
return;
}
searchResults.AddRange(results);
// Force editors to repaint so the results are displayed
foreach (UnityEditor.Editor e in Resources.FindObjectsOfTypeAll<UnityEditor.Editor>())
{
e.Repaint();
}
}
19
Source : WindowsMixedRealityEyeGazeDataProvider.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
private Ray SmoothGaze(Ray? newGaze)
{
using (SmoothGazePerfMarker.Auto())
{
if (!oldGaze.HasValue)
{
oldGaze = newGaze;
return newGaze.Value;
}
Ray smoothedGaze = new Ray();
bool isSaccading = false;
// Handle saccades vs. outliers: Instead of simply checking that two successive gaze points are sufficiently
// apart, we check for clusters of gaze points instead.
// 1. If the user's gaze points are far enough apart, this may be a saccade, but also could be an outlier.
// So, let's mark it as a potential saccade.
if ((IsSaccading(oldGaze.Value, newGaze.Value) && (confidenceOfSaccade == 0)))
{
confidenceOfSaccade++;
saccade_initialGazePoint = oldGaze.Value;
saccade_newGazeCluster.Clear();
saccade_newGazeCluster.Add(newGaze.Value);
}
// 2. If we have a potential saccade marked, let's check if the new points are within the proximity of
// the initial saccade point.
else if ((confidenceOfSaccade > 0) && (confidenceOfSaccade < confidenceOfSaccadeThreshold))
{
confidenceOfSaccade++;
// First, let's check that we don't just have a bunch of random outliers
// The replacedumption is that after a person saccades, they fixate for a certain
// amount of time resulting in a cluster of gaze points.
for (int i = 0; i < saccade_newGazeCluster.Count; i++)
{
if (IsSaccading(saccade_newGazeCluster[i], newGaze.Value))
{
confidenceOfSaccade = 0;
}
// Meanwhile we want to make sure that we are still looking sufficiently far away from our
// original gaze point before saccading.
if (!IsSaccading(saccade_initialGazePoint, newGaze.Value))
{
confidenceOfSaccade = 0;
}
}
saccade_newGazeCluster.Add(newGaze.Value);
}
else if (confidenceOfSaccade == confidenceOfSaccadeThreshold)
{
isSaccading = true;
}
Vector3 v1 = oldGaze.Value.origin + oldGaze.Value.direction;
Vector3 v2 = newGaze.Value.origin + newGaze.Value.direction;
// Saccade-dependent local smoothing
if (isSaccading)
{
smoothedGaze.direction = newGaze.Value.direction;
smoothedGaze.origin = newGaze.Value.origin;
confidenceOfSaccade = 0;
}
else
{
smoothedGaze.direction = oldGaze.Value.direction * smoothFactorNormalized + newGaze.Value.direction * (1 - smoothFactorNormalized);
smoothedGaze.origin = oldGaze.Value.origin * smoothFactorNormalized + newGaze.Value.origin * (1 - smoothFactorNormalized);
}
oldGaze = smoothedGaze;
return smoothedGaze;
}
}
19
Source : XRSDKDeviceManager.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
public override void Update()
{
using (UpdatePerfMarker.Auto())
{
base.Update();
if (XRSDKSubsystemHelpers.InputSubsystem == null || !XRSDKSubsystemHelpers.InputSubsystem.running)
{
return;
}
InputDevices.GetDevicesWithCharacteristics(InputDeviceCharacteristics.Controller, inputDevices);
foreach (InputDevice device in inputDevices)
{
if (device.isValid)
{
GenericXRSDKController controller = GetOrAddController(device);
if (controller == null)
{
continue;
}
if (!lastInputDevices.Contains(device))
{
CoreServices.InputSystem?.RaiseSourceDetected(controller.InputSource, controller);
}
else
{
// Remove devices from our previously tracked list as we update them.
// This will allow us to remove all stale devices that were tracked
// last frame but not this one.
lastInputDevices.Remove(device);
controller.UpdateController(device);
}
}
}
foreach (InputDevice device in lastInputDevices)
{
GenericXRSDKController controller = GetOrAddController(device);
if (controller != null)
{
CoreServices.InputSystem?.RaiseSourceLost(controller.InputSource, controller);
RemoveController(device);
}
}
lastInputDevices.Clear();
lastInputDevices.AddRange(inputDevices);
}
}
19
Source : UICollection.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
public void RemoveAllItems()
{
Items.Clear();
UpdateLayout();
}
19
Source : UICollection.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
private void Collecreplacedems()
{
Items.Clear();
foreach (Transform childTransform in transform)
{
RectTransform childRect = childTransform.GetComponent<RectTransform>();
if (childRect != null)
{
AddItem(childRect);
}
}
}
19
Source : MixedRealitySearchInspectorUtility.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
private static void DrawSearchResultInterface(UnityEngine.Object target)
{
bool optionsFoldout = SessionState.GetBool(searchDisplayOptionsFoldoutKey, false);
optionsFoldout = EditorGUILayout.Foldout(optionsFoldout, "Search Preferences", true);
SessionState.SetBool(searchDisplayOptionsFoldoutKey, optionsFoldout);
if (optionsFoldout)
{
config.RequireAllKeywords = EditorGUILayout.Toggle("Require All Keywords", config.RequireAllKeywords);
config.SearchTooltips = EditorGUILayout.Toggle("Search Tooltips", config.SearchTooltips);
config.SearchFieldContent = EditorGUILayout.Toggle("Search Field Content", config.SearchFieldContent);
}
if (!config.Equals(prevConfig) && !MixedRealitySearchUtility.Searching)
{
MixedRealitySearchUtility.StartProfileSearch(target, config, OnSearchComplete);
searchResults.Clear();
prevConfig = config;
}
#region display results
using (new EditorGUILayout.VerticalScope())
{
if (searchResults.Count == 0)
{
if (MixedRealitySearchUtility.Searching)
{
EditorGUILayout.HelpBox("Searching...", MessageType.Info);
}
else
{
EditorGUILayout.HelpBox("No search results. Try selecting a subject or entering a keyword.", MessageType.Warning);
}
}
int numDisplayedSearchResults = 0;
if (searchResults.Count > 0)
{
EditorGUILayout.Space();
EditorGUILayout.LabelField("Results:");
foreach (ProfileSearchResult search in searchResults)
{
if (search.Fields.Count == 0)
{ // Don't display results with no fields
continue;
}
using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
{
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.LabelField("Fields found in: ", EditorStyles.boldLabel, GUILayout.MaxWidth(105));
EditorGUILayout.ObjectField(search.Profile, typeof(UnityEngine.Object), false, GUILayout.ExpandWidth(true));
if (GUILayout.Button("View replacedet", GUILayout.MaxWidth(75)))
{
Selection.activeObject = search.Profile;
EditorGUIUtility.PingObject(search.Profile);
}
}
if (MixedRealityProjectPreferences.LockProfiles && !search.IsCustomProfile)
{
EditorGUILayout.HelpBox("Clone this profile to edit default properties.", MessageType.Warning);
}
using (new EditorGUI.DisabledGroupScope(MixedRealityProjectPreferences.LockProfiles && !search.IsCustomProfile))
{
using (new EditorGUI.IndentLevelScope(1))
{
EditorGUILayout.Space();
foreach (FieldSearchResult r in search.Fields)
{
numDisplayedSearchResults++;
GUI.color = Color.white;
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(r.Property, true);
if (EditorGUI.EndChangeCheck())
{
r.Property.serializedObject.ApplyModifiedProperties();
}
EditorGUILayout.Space();
}
}
}
}
EditorGUILayout.Space();
}
}
}
#endregion
}
19
Source : MixedRealityToolkitFacadeHandler.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
private static void DestroyAllChildren(MixedRealityToolkit instance)
{
Transform instanceTransform = instance.transform;
childrenToDelete.Clear();
foreach (Transform child in instanceTransform.transform)
{
childrenToDelete.Add(child);
}
foreach (ServiceFacade facade in ServiceFacade.ActiveFacadeObjects)
{
if (!childrenToDelete.Contains(facade.transform))
{
childrenToDelete.Add(facade.transform);
}
}
foreach (Transform child in childrenToDelete)
{
GameObjectExtensions.DestroyGameObject(child.gameObject);
}
childrenToDelete.Clear();
}
19
Source : BaseCursor.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
private void ResetInputSourceState()
{
SourceDownIds.Clear();
visibleSourcesCount = 0;
if (IsPointerValid)
{
uint cursorPointerId = Pointer.PointerId;
foreach (IMixedRealityInputSource inputSource in CoreServices.InputSystem.DetectedInputSources)
{
if (inputSource.SourceType != InputSourceType.Head && inputSource.SourceType != InputSourceType.Eyes)
{
foreach (IMixedRealityPointer inputSourcePointer in inputSource.Pointers)
{
if (inputSourcePointer.PointerId == cursorPointerId)
{
++visibleSourcesCount;
break;
}
}
}
}
}
if (SetVisibilityOnSourceDetected)
{
SetVisibility(IsSourceDetected);
}
}
19
Source : PressableButton.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
void OnDisable()
{
// clear touch points in case we get disabled and can't receive the touch end event anymore
touchPoints.Clear();
currentInputSources.Clear();
if (hreplacedtarted)
{
// make sure button doesn't stay in a pressed state in case we disable the button while pressing it
currentPushDistance = startPushDistance;
UpdateMovingVisualsPosition();
}
}
19
Source : SerializableDictionary.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
public void OnBeforeSerialize()
{
keys.Clear();
values.Clear();
foreach (KeyValuePair<TKey, TValue> pair in this)
{
keys.Add(pair.Key);
values.Add(pair.Value);
}
}
19
Source : USBDeviceListener.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
private static void NotifyUsbDevicesChanged(UsbDevice[] devices)
{
UsbDevicesChanged?.Invoke(devices);
USBDevicesList.Clear();
foreach (UsbDevice device in devices)
{
USBDevicesList.Add(new USBDeviceInfo(device.vendorId, device.udid, device.productId, device.name, device.revision));
}
USBDevices = USBDevicesList.ToArray();
}
19
Source : AppBar.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
private void InitializeButtons()
{
buttons.Clear();
foreach (Transform child in ButtonParent)
{
AppBarButton appBarButton = child.GetComponent<AppBarButton>();
if (appBarButton == null)
throw new Exception("Found a transform without an AppBarButton component under buttonTransforms!");
appBarButton.InitializeButtonContent(this);
// Set to invisible initially if not custom
switch (appBarButton.ButtonType)
{
case ButtonTypeEnum.Custom:
break;
default:
appBarButton.SetVisible(false);
break;
}
buttons.Add(appBarButton);
}
}
19
Source : AppBar.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
private void FollowTargetObject(bool smooth)
{
var boundsProvider = Target as IBoundsTargetProvider;
if (boundsProvider == null)
return;
// Calculate the best follow position
Vector3 finalPosition = Vector3.zero;
Vector3 headPosition = CameraCache.Main.transform.position;
boundsPoints.Clear();
helper.UpdateNonAABoundsCornerPositions(boundsProvider.TargetBounds, boundsPoints);
int followingFaceIndex = helper.GetIndexOfForwardFace(headPosition);
Vector3 faceNormal = helper.GetFaceNormal(followingFaceIndex);
// Finalize the new position
finalPosition = helper.GetFaceBottomCentroid(followingFaceIndex) + (faceNormal * HoverOffsetZ);
// Follow our bounding box
transform.position = smooth ? Vector3.Lerp(transform.position, finalPosition, Time.deltaTime * backgroundBarMoveSpeed) : finalPosition;
// Rotate on the y axis
Vector3 direction = (boundsProvider.TargetBounds.bounds.center - finalPosition).normalized;
if (direction != Vector3.zero)
{
Vector3 eulerAngles = Quaternion.LookRotation(direction, Vector3.up).eulerAngles;
eulerAngles.x = 0f;
eulerAngles.z = 0f;
transform.eulerAngles = eulerAngles;
}
else
{
transform.eulerAngles = Vector3.zero;
}
}
19
Source : BoundingBoxHelper.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
public void UpdateNonAABoundsCornerPositions(BoxCollider colliderBounds, List<Vector3> boundsPoints)
{
if (colliderBounds != targetBounds || rawBoundingCornersObtained == false)
{
GetRawBoundsCorners(colliderBounds);
}
if (colliderBounds == targetBounds && rawBoundingCornersObtained)
{
boundsPoints.Clear();
for (int i = 0; i < rawBoundingCorners.Count; ++i)
{
boundsPoints.Add(colliderBounds.transform.localToWorldMatrix.MultiplyPoint(rawBoundingCorners[i]));
}
worldBoundingCorners.Clear();
worldBoundingCorners.AddRange(boundsPoints);
}
}
19
Source : BoundingBoxHelper.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
internal void GetRawBoundsCorners(BoxCollider colliderBounds)
{
targetBounds = colliderBounds;
rawBoundingCorners.Clear();
rawBoundingCornersObtained = false;
GetUntransformedCornersFromObject(colliderBounds, rawBoundingCorners);
if (rawBoundingCorners != null && rawBoundingCorners.Count >= 4)
{
rawBoundingCornersObtained = true;
}
}
19
Source : BaseObjectCollection.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
protected void PruneEmptyNodes()
{
// Check for empty nodes and remove them
var emptyNodes = new List<ObjectCollectionNode>();
for (int i = 0; i < NodeList.Count; i++)
{
if (NodeList[i].Transform == null || (IgnoreInactiveTransforms && !NodeList[i].Transform.gameObject.activeSelf) || NodeList[i].Transform.parent == null || !(NodeList[i].Transform.parent.gameObject == gameObject))
{
emptyNodes.Add(NodeList[i]);
}
}
// Now delete the empty nodes
for (int i = 0; i < emptyNodes.Count; i++)
{
NodeList.Remove(emptyNodes[i]);
}
emptyNodes.Clear();
}
19
Source : CameraFOVChecker.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
public static bool IsInFOVCached(this Camera cam, Collider myCollider)
{
// if the collider's size is zero, it is not visible. Return false.
if (myCollider.bounds.size == Vector3.zero || myCollider.transform.localScale == Vector3.zero)
{
return false;
}
Tuple<Collider, Camera> cameraColliderPair = new Tuple<Collider, Camera>(myCollider, cam);
bool result = false;
if (inFOVLastCalculatedFrame != Time.frameCount)
{
inFOVColliderCache.Clear();
inFOVLastCalculatedFrame = Time.frameCount;
}
else if (inFOVColliderCache.TryGetValue(cameraColliderPair, out result))
{
return result;
}
inFOVBoundsCornerPoints.Clear();
BoundsExtensions.GetColliderBoundsPoints(myCollider, inFOVBoundsCornerPoints, 0);
float xMin = float.MaxValue, yMin = float.MaxValue, zMin = float.MaxValue;
float xMax = float.MinValue, yMax = float.MinValue, zMax = float.MinValue;
for (int i = 0; i < inFOVBoundsCornerPoints.Count; i++)
{
var corner = inFOVBoundsCornerPoints[i];
Vector3 screenPoint = cam.WorldToViewportPoint(corner);
bool isInFOV = screenPoint.z >= 0 && screenPoint.z <= cam.farClipPlane
&& screenPoint.x >= 0 && screenPoint.x <= 1
&& screenPoint.y >= 0 && screenPoint.y <= 1;
if (isInFOV)
{
inFOVColliderCache.Add(cameraColliderPair, true);
return true;
}
// if the point is behind the camera, the x and y viewport positions are negated
var zViewport = screenPoint.z;
var xViewport = zViewport >= 0 ? screenPoint.x : -screenPoint.x;
var yViewport = zViewport >= 0 ? screenPoint.y : -screenPoint.y;
xMin = Mathf.Min(xMin, xViewport);
yMin = Mathf.Min(yMin, yViewport);
zMin = Mathf.Min(zMin, zViewport);
xMax = Mathf.Max(xMax, xViewport);
yMax = Mathf.Max(yMax, yViewport);
zMax = Mathf.Max(zMax, zViewport);
}
// Check that collider is visible even if all corners are not visible
// such as when having a large collider
result =
zMax > 0 // Front of collider is in front of the camera.
&& zMin < cam.farClipPlane // Back of collider is not too far away.
&& xMin < 1 // Left edge is not too far to the right.
&& xMax > 0 // Right edge is not too far to the left.
&& yMin < 1 // Bottom edge is not too high.
&& yMax > 0; // Top edge is not too low.
inFOVColliderCache.Add(cameraColliderPair, result);
return result;
}
19
Source : ProximityEffect.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
public void UpdateScaling(Vector3 boundsCenter, Vector3 boundsExtents)
{
// early out if effect is disabled
if (config.ProximityEffectActive == false || !IsAnyRegisteredObjectVisible())
{
return;
}
proximityPointers.Clear();
proximityPoints.Clear();
// Find all valid pointers
foreach (var inputSource in CoreServices.InputSystem.DetectedInputSources)
{
foreach (var pointer in inputSource.Pointers)
{
// don't use IsInteractionEnabled for near pointers as the pointers might have a different radius when deciding
// if they can interact with a near-by object - we might still want to show proximity scaling even if
// eg. grab pointer decides it's too far away to actually perform the interaction
if (pointer.IsActive && !proximityPointers.Contains(pointer))
{
proximityPointers.Add(pointer);
}
}
}
// Get the max radius possible of our current bounds and extent the range to include proximity scaled objects. This is done by adjusting the original bounds to include the ObjectMediumProximity range in x, y and z axis
float squareMaxLength = boundsExtents.sqrMagnitude + (3 * config.ObjectMediumProximity * config.ObjectMediumProximity);
// Grab points within sphere of influence from valid pointers
foreach (var pointer in proximityPointers)
{
if (IsPointWithinBounds(boundsCenter, pointer.Position, squareMaxLength))
{
proximityPoints.Add(pointer.Position);
}
if (pointer.Result?.CurrentPointerTarget != null)
{
Vector3? point = pointer.Result?.Details.Point;
if (point.HasValue && IsPointWithinBounds(boundsCenter, pointer.Result.Details.Point, squareMaxLength))
{
proximityPoints.Add(pointer.Result.Details.Point);
}
}
}
// Loop through all objects and find closest one
Transform closestObject = null;
float closestDistanceSqr = float.MaxValue;
foreach (var point in proximityPoints)
{
foreach (var keyValuePair in registeredObjects)
{
foreach (var item in keyValuePair.Value)
{
// If object can't be visible, skip calculations
if (!keyValuePair.Key.IsActive)
{
continue;
}
// Perform comparison on sqr distance since sqrt() operation is expensive in Vector3.Distance()
float sqrDistance = (item.ScaledObject.transform.position - point).sqrMagnitude;
if (sqrDistance < closestDistanceSqr)
{
closestObject = item.ScaledObject;
closestDistanceSqr = sqrDistance;
}
}
}
}
// Loop through all objects and update visual state based on closest point
foreach (var keyValuePair in registeredObjects)
{
foreach (var item in keyValuePair.Value)
{
ProximityState newState = (closestObject == item.ScaledObject) ? GetProximityState(closestDistanceSqr) : ProximityState.FullsizeNoProximity;
IProximityEffectObjectProvider provider = keyValuePair.Key;
// Only apply updates if object is in a new state or closest object needs to lerp scaling
if (item.ProximityState != newState)
{
// Update and save new state
item.ProximityState = newState;
if (item.ObjectVisualRenderer)
{
item.ObjectVisualRenderer.material = newState == ProximityState.CloseProximity ? provider.GetHighlightedMaterial() : provider.GetBaseMaterial();
}
}
ScaleObject(newState, item.ScaledObject, provider.GetObjectSize(), true);
}
}
}
19
Source : HandlesBase.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
internal void DestroyHandles()
{
if (handles != null)
{
foreach (Transform transform in handles)
{
GameObject.Destroy(transform.gameObject);
}
handles.Clear();
}
}
See More Examples