Compare commits
3 commits
1111f0d7a0
...
6031db6620
| Author | SHA1 | Date | |
|---|---|---|---|
| 6031db6620 | |||
| 40fff9bba3 | |||
| 59999ebb2d |
10 changed files with 270 additions and 0 deletions
8
AviLabels.meta
Normal file
8
AviLabels.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: eae4e10ae346ec24984d58b3b87d55e3
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
94
AviLabels/AviLabelParent.cs
Normal file
94
AviLabels/AviLabelParent.cs
Normal file
|
|
@ -0,0 +1,94 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using VRC.SDK3.Avatars.Components;
|
||||||
|
using VRC.SDK3.Dynamics.Constraint.Components;
|
||||||
|
using TMPro;
|
||||||
|
using VRC.Dynamics;
|
||||||
|
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
using UnityEditor;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace gay.lilyy.AviLabels
|
||||||
|
{
|
||||||
|
|
||||||
|
[AddComponentMenu("LillithRosePup/Avatar Label/Driver")]
|
||||||
|
public class AviLabelParent : MonoBehaviour, VRC.SDKBase.IEditorOnly
|
||||||
|
{
|
||||||
|
public Color defaultColor = Color.white;
|
||||||
|
public TMP_FontAsset defaultFont = null;
|
||||||
|
public void UpdateLabels()
|
||||||
|
{
|
||||||
|
List<Transform> childrenToDestroy = new List<Transform>();
|
||||||
|
foreach (Transform child in transform)
|
||||||
|
{
|
||||||
|
childrenToDestroy.Add(child);
|
||||||
|
}
|
||||||
|
foreach (Transform child in childrenToDestroy)
|
||||||
|
{
|
||||||
|
DestroyImmediate(child.gameObject);
|
||||||
|
}
|
||||||
|
var avatarDescriptors = GameObject.FindObjectsOfType<VRCAvatarDescriptor>();
|
||||||
|
foreach (var avatarDescriptor in avatarDescriptors)
|
||||||
|
{
|
||||||
|
LabelConfig labelConfig = LabelConfig.GetDefault();
|
||||||
|
if (avatarDescriptor.GetComponent<LabelConfig>() != null)
|
||||||
|
{
|
||||||
|
labelConfig = avatarDescriptor.GetComponent<LabelConfig>();
|
||||||
|
}
|
||||||
|
if (labelConfig.font == null)
|
||||||
|
{
|
||||||
|
labelConfig.font = defaultFont;
|
||||||
|
}
|
||||||
|
if (labelConfig.color == Color.white)
|
||||||
|
{
|
||||||
|
labelConfig.color = defaultColor;
|
||||||
|
}
|
||||||
|
var child = new GameObject(avatarDescriptor.name);
|
||||||
|
child.transform.SetParent(transform);
|
||||||
|
child.transform.localPosition = Vector3.zero;
|
||||||
|
child.transform.localRotation = Quaternion.identity;
|
||||||
|
child.transform.localScale = Vector3.one;
|
||||||
|
|
||||||
|
|
||||||
|
var parentConstraint = child.AddComponent<VRCParentConstraint>();
|
||||||
|
parentConstraint.AffectsPositionY = false;
|
||||||
|
parentConstraint.AffectsRotationY = false;
|
||||||
|
parentConstraint.Sources.Add(new VRCConstraintSource {
|
||||||
|
SourceTransform = avatarDescriptor.transform,
|
||||||
|
Weight = 1
|
||||||
|
});
|
||||||
|
parentConstraint.ActivateConstraint();
|
||||||
|
parentConstraint.ZeroConstraint();
|
||||||
|
|
||||||
|
|
||||||
|
var textMeshPro = child.AddComponent<TextMeshPro>();
|
||||||
|
if (labelConfig.font != null)
|
||||||
|
{
|
||||||
|
textMeshPro.font = labelConfig.font;
|
||||||
|
}
|
||||||
|
textMeshPro.color = labelConfig.color;
|
||||||
|
textMeshPro.text = !string.IsNullOrEmpty(labelConfig.overrideName) ? labelConfig.overrideName : avatarDescriptor.name;
|
||||||
|
textMeshPro.alignment = TextAlignmentOptions.Center;
|
||||||
|
textMeshPro.fontSize = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
[CustomEditor(typeof(AviLabelParent))]
|
||||||
|
public class AviLabelParentInspector : Editor
|
||||||
|
{
|
||||||
|
public override void OnInspectorGUI()
|
||||||
|
{
|
||||||
|
base.OnInspectorGUI();
|
||||||
|
if (GUILayout.Button("Update Labels"))
|
||||||
|
{
|
||||||
|
((AviLabelParent)target).UpdateLabels();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
11
AviLabels/AviLabelParent.cs.meta
Normal file
11
AviLabels/AviLabelParent.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7bb30b2bdab228a479fae7db4ab367c2
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
18
AviLabels/AviLabels.asmdef
Normal file
18
AviLabels/AviLabels.asmdef
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"name": "AviLabels",
|
||||||
|
"rootNamespace": "",
|
||||||
|
"references": [
|
||||||
|
"GUID:3456780c4fb2d324ab9c633d6f1b0ddb",
|
||||||
|
"GUID:5718fb738711cd34ea54e9553040911d",
|
||||||
|
"GUID:6055be8ebefd69e48b49212b09b47b2f"
|
||||||
|
],
|
||||||
|
"includePlatforms": [],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
||||||
7
AviLabels/AviLabels.asmdef.meta
Normal file
7
AviLabels/AviLabels.asmdef.meta
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0758760262efba643b9c9c20179b4985
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
22
AviLabels/LabelConfig.cs
Normal file
22
AviLabels/LabelConfig.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace gay.lilyy.AviLabels
|
||||||
|
{
|
||||||
|
[AddComponentMenu("LillithRosePup/Avatar Label/Config")]
|
||||||
|
public class LabelConfig : MonoBehaviour, VRC.SDKBase.IEditorOnly
|
||||||
|
{
|
||||||
|
public string overrideName;
|
||||||
|
public Color color;
|
||||||
|
public TMP_FontAsset font;
|
||||||
|
|
||||||
|
internal static LabelConfig GetDefault()
|
||||||
|
{
|
||||||
|
return new LabelConfig {
|
||||||
|
overrideName = "",
|
||||||
|
color = Color.white,
|
||||||
|
font = null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
AviLabels/LabelConfig.cs.meta
Normal file
11
AviLabels/LabelConfig.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9bb9a03d585aaee48b5a80cf79cbb00f
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Commonly Used/Materials.meta
Normal file
8
Commonly Used/Materials.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 22d11a82c6949ff408a60e83fe25a961
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
83
Commonly Used/Materials/Transparent.mat
Normal file
83
Commonly Used/Materials/Transparent.mat
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!21 &2100000
|
||||||
|
Material:
|
||||||
|
serializedVersion: 8
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: Transparent
|
||||||
|
m_Shader: {fileID: 4800000, guid: d5b89f0c74ccf5049ba803c14a090378, type: 3}
|
||||||
|
m_Parent: {fileID: 0}
|
||||||
|
m_ModifiedSerializedProperties: 0
|
||||||
|
m_ValidKeywords: []
|
||||||
|
m_InvalidKeywords: []
|
||||||
|
m_LightmapFlags: 4
|
||||||
|
m_EnableInstancingVariants: 0
|
||||||
|
m_DoubleSidedGI: 0
|
||||||
|
m_CustomRenderQueue: -1
|
||||||
|
stringTagMap: {}
|
||||||
|
disabledShaderPasses: []
|
||||||
|
m_LockedProperties:
|
||||||
|
m_SavedProperties:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TexEnvs:
|
||||||
|
- _BumpMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailAlbedoMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailMask:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailNormalMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _EmissionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MainTex:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MetallicGlossMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _OcclusionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _ParallaxMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
m_Ints: []
|
||||||
|
m_Floats:
|
||||||
|
- _BumpScale: 1
|
||||||
|
- _Cutoff: 0.5
|
||||||
|
- _DetailNormalMapScale: 1
|
||||||
|
- _DstBlend: 0
|
||||||
|
- _GlossMapScale: 1
|
||||||
|
- _Glossiness: 0.5
|
||||||
|
- _GlossyReflections: 1
|
||||||
|
- _Metallic: 0
|
||||||
|
- _Mode: 0
|
||||||
|
- _OcclusionStrength: 1
|
||||||
|
- _Parallax: 0.02
|
||||||
|
- _SmoothnessTextureChannel: 0
|
||||||
|
- _SpecularHighlights: 1
|
||||||
|
- _SrcBlend: 1
|
||||||
|
- _UVSec: 0
|
||||||
|
- _ZWrite: 1
|
||||||
|
m_Colors:
|
||||||
|
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
|
m_BuildTextureStacks: []
|
||||||
8
Commonly Used/Materials/Transparent.mat.meta
Normal file
8
Commonly Used/Materials/Transparent.mat.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 00979658ca9fbca41b948288856c3d32
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 2100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
Add table
Add a link
Reference in a new issue