update CCK to 3.10, fixing unity 2021 crash :)
This commit is contained in:
parent
48a978fa2a
commit
d11e0fb3a9
492 changed files with 2165204 additions and 437687 deletions
|
@ -8,8 +8,7 @@ using UnityEngine;
|
|||
|
||||
namespace ABI.CCK.Scripts.Editor
|
||||
{
|
||||
[CustomEditor(typeof(ABI.CCK.Components.CVRInteractable))]
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(CVRInteractable))]
|
||||
public class CCK_CVRInteractableEditor : UnityEditor.Editor
|
||||
{
|
||||
private CVRInteractable _interactable;
|
||||
|
@ -23,10 +22,26 @@ namespace ABI.CCK.Scripts.Editor
|
|||
private static string[] spawnableUpdateTypes = new string[] {"Override", "Add", "Subtract", "Toggle"};
|
||||
private static string[] apfSetTypes = new string[] {"Static", "Variable Buffer"};
|
||||
private static string[] apfSetTypesString = new string[] {"Static", "Property"};
|
||||
|
||||
private bool _interactalbeIsPartOfWorld;
|
||||
private bool _interactableIsPartOfProp;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (target == null) return;
|
||||
_interactable = (CVRInteractable)target;
|
||||
|
||||
// If Spawnable is not a World Spawnable, limit the entries displayed
|
||||
if (CCK_Tools.FindFirstInstanceInScene<CVRWorld>() == null)
|
||||
_interactableIsPartOfProp = _interactable.GetComponentInParent<CVRSpawnable>() != null;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (_interactable == null) _interactable = (CVRInteractable)target;
|
||||
if (_interactable == null)
|
||||
return;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
_interactable.tooltip = EditorGUILayout.TextField("Tooltip:", _interactable.tooltip);
|
||||
|
||||
|
@ -37,16 +52,41 @@ namespace ABI.CCK.Scripts.Editor
|
|||
foreach (CVRInteractableAction trigger in _interactable.actions)
|
||||
{
|
||||
GUILayout.BeginVertical("HelpBox");
|
||||
GUILayout.BeginHorizontal ();
|
||||
|
||||
trigger.actionType = (CVRInteractableAction.ActionRegister) EditorGUILayout.EnumPopup("Trigger:", trigger.actionType);
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
trigger.actionType = _interactableIsPartOfProp
|
||||
? EnumFilter
|
||||
.FilteredEnumPopup<CVRInteractableAction.ActionRegister,
|
||||
CVRInteractableAction.AllowSpawnable>(trigger.actionType, "Trigger:")
|
||||
: EnumFilter
|
||||
.FilteredEnumPopup<CVRInteractableAction.ActionRegister,
|
||||
CVRInteractableAction.AllowWorld>(trigger.actionType, "Trigger:");
|
||||
|
||||
GUILayout.BeginHorizontal ();
|
||||
GUILayout.BeginVertical ("GroupBox");
|
||||
|
||||
trigger.execType = (CVRInteractableAction.ExecutionType) EditorGUILayout.EnumPopup("Broadcast Type:", trigger.execType);
|
||||
trigger.execType = _interactableIsPartOfProp
|
||||
? EnumFilter
|
||||
.FilteredEnumPopup<CVRInteractableAction.ExecutionType,
|
||||
CVRInteractableAction.AllowSpawnable>(trigger.execType, "Broadcast Type:")
|
||||
: EnumFilter
|
||||
.FilteredEnumPopup<CVRInteractableAction.ExecutionType,
|
||||
CVRInteractableAction.AllowWorld>(trigger.execType, "Broadcast Type:");
|
||||
|
||||
if (trigger.actionType == CVRInteractableAction.ActionRegister.OnAPFTrigger ||
|
||||
trigger.actionType == CVRInteractableAction.ActionRegister.OnAPFBoolChange ||
|
||||
trigger.actionType == CVRInteractableAction.ActionRegister.OnAPFIntChange ||
|
||||
trigger.actionType == CVRInteractableAction.ActionRegister.OnAPFFloatChange ||
|
||||
trigger.actionType == CVRInteractableAction.ActionRegister.OnAPFStringChange)
|
||||
{
|
||||
trigger.execType = CVRInteractableAction.ExecutionType.LocalNotNetworked;
|
||||
|
||||
trigger.stringVal = EditorGUILayout.TextField("Key", trigger.stringVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
trigger.delay = EditorGUILayout.FloatField("Delay (Seconds):", trigger.delay);
|
||||
}
|
||||
|
||||
if (trigger.actionType == CVRInteractableAction.ActionRegister.OnEnterCollider ||
|
||||
trigger.actionType == CVRInteractableAction.ActionRegister.OnExitCollider ||
|
||||
trigger.actionType == CVRInteractableAction.ActionRegister.OnEnterTrigger ||
|
||||
|
@ -55,6 +95,16 @@ namespace ABI.CCK.Scripts.Editor
|
|||
LayerMask tempMask = EditorGUILayout.MaskField("Layer:", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(trigger.layerMask), InternalEditorUtility.layers);
|
||||
trigger.layerMask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(tempMask);
|
||||
}
|
||||
|
||||
if (trigger.actionType is CVRInteractableAction.ActionRegister.OnPlayerTriggerEnter
|
||||
or CVRInteractableAction.ActionRegister.OnPlayerTriggerExit
|
||||
or CVRInteractableAction.ActionRegister.OnPlayerColliderEnter
|
||||
or CVRInteractableAction.ActionRegister.OnPlayerColliderExit)
|
||||
{
|
||||
trigger.boolVal = EditorGUILayout.Toggle("Local Player", trigger.boolVal);
|
||||
trigger.boolVal2 = EditorGUILayout.Toggle("Remote Player", trigger.boolVal2);
|
||||
if (!trigger.boolVal && !trigger.boolVal2) EditorGUILayout.HelpBox("At least one player type must be selected.", MessageType.Error);
|
||||
}
|
||||
|
||||
if (trigger.actionType == CVRInteractableAction.ActionRegister.OnTimer)
|
||||
{
|
||||
|
@ -132,15 +182,15 @@ namespace ABI.CCK.Scripts.Editor
|
|||
|
||||
for (int i = 0; i < trigger.specificParticleSystems.Count; i++)
|
||||
{
|
||||
trigger.specificParticleSystems[i] = (ParticleSystem) EditorGUILayout.ObjectField("Element " + i,
|
||||
trigger.specificParticleSystems[i], typeof(ParticleSystem));
|
||||
trigger.specificParticleSystems[i] = (ParticleSystem)EditorGUILayout.ObjectField("Element " + i,
|
||||
trigger.specificParticleSystems[i], typeof(ParticleSystem), true);
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
if (trigger.actionType == CVRInteractableAction.ActionRegister.OnPointerEnter)
|
||||
if (trigger.actionType == CVRInteractableAction.ActionRegister.OnPointerEnter || trigger.actionType == CVRInteractableAction.ActionRegister.OnPointerExit)
|
||||
{
|
||||
GUIStyle foldoutStyle = new GUIStyle (EditorStyles.foldout);
|
||||
foldoutStyle.margin.left = 12;
|
||||
|
@ -161,8 +211,8 @@ namespace ABI.CCK.Scripts.Editor
|
|||
|
||||
for (int i = 0; i < trigger.allowedPointer.Count; i++)
|
||||
{
|
||||
trigger.allowedPointer[i] = (CVRPointer) EditorGUILayout.ObjectField("Element " + i,
|
||||
trigger.allowedPointer[i], typeof(CVRPointer));
|
||||
trigger.allowedPointer[i] = (CVRPointer)EditorGUILayout.ObjectField("Element " + i,
|
||||
trigger.allowedPointer[i], typeof(CVRPointer), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,32 +249,38 @@ namespace ABI.CCK.Scripts.Editor
|
|||
|
||||
trigger.interactionInputModifier = (CVRInteractableAction.InteractionInputModifier) EditorGUILayout.EnumFlagsField("Interaction Input Modifier", trigger.interactionInputModifier);
|
||||
}
|
||||
|
||||
if (trigger.actionType == CVRInteractableAction.ActionRegister.OnAPFTrigger ||
|
||||
trigger.actionType == CVRInteractableAction.ActionRegister.OnAPFBoolChange ||
|
||||
trigger.actionType == CVRInteractableAction.ActionRegister.OnAPFIntChange ||
|
||||
trigger.actionType == CVRInteractableAction.ActionRegister.OnAPFFloatChange ||
|
||||
trigger.actionType == CVRInteractableAction.ActionRegister.OnAPFStringChange)
|
||||
|
||||
if (trigger.actionType is CVRInteractableAction.ActionRegister.OnBecameVisible
|
||||
or CVRInteractableAction.ActionRegister.OnBecameInvisible)
|
||||
{
|
||||
trigger.execType = CVRInteractableAction.ExecutionType.LocalNotNetworked;
|
||||
|
||||
trigger.stringVal = EditorGUILayout.TextField("Key", trigger.stringVal);
|
||||
if (!_interactable.TryGetComponent(out Renderer _))
|
||||
EditorGUILayout.HelpBox("No Renderer found on this GameObject. A renderer is required for this trigger.", MessageType.Error);
|
||||
}
|
||||
else
|
||||
|
||||
if (trigger.actionType == CVRInteractableAction.ActionRegister.OnStateMachineEnter ||
|
||||
trigger.actionType == CVRInteractableAction.ActionRegister.OnStateMachineExit)
|
||||
{
|
||||
trigger.delay = EditorGUILayout.FloatField("Delay (Seconds):", trigger.delay);
|
||||
EditorGUILayout.HelpBox("This trigger requires a StateMachineCallbackSender to invoke it via an Animation State. Specify a State Tag if using this trigger type more than once on this interactable. Leave empty to not filter.", MessageType.Info);
|
||||
|
||||
trigger.stringVal = EditorGUILayout.TextField("State Tag Filter", trigger.stringVal);
|
||||
}
|
||||
|
||||
if(trigger.varBufferVal != null) trigger.varBufferVal.AddInteracteable(_interactable);
|
||||
if(trigger.varBufferVal2 != null) trigger.varBufferVal2.AddInteracteable(_interactable);
|
||||
|
||||
EditorGUILayout.LabelField("Actions:", EditorStyles.boldLabel);
|
||||
EditorGUILayout.LabelField("Actions:", EditorStyles.boldLabel); // why are the operations called actions ?
|
||||
|
||||
for (int j = 0; j < trigger.operations.Count; j++)
|
||||
{
|
||||
GUILayout.BeginVertical ("GroupBox");
|
||||
|
||||
trigger.operations[j].type = (CVRInteractableActionOperation.ActionType) EditorGUILayout.EnumPopup("Action Type:", trigger.operations[j].type);
|
||||
|
||||
trigger.operations[j].type = _interactableIsPartOfProp
|
||||
? EnumFilter
|
||||
.FilteredEnumPopup<CVRInteractableActionOperation.ActionType,
|
||||
CVRInteractableActionOperation.AllowSpawnable>(trigger.operations[j].type, "Action Type:")
|
||||
: EnumFilter
|
||||
.FilteredEnumPopup<CVRInteractableActionOperation.ActionType,
|
||||
CVRInteractableActionOperation.AllowWorld>(trigger.operations[j].type, "Action Type:");
|
||||
|
||||
switch (trigger.operations[j].type)
|
||||
{
|
||||
|
@ -245,9 +301,68 @@ namespace ABI.CCK.Scripts.Editor
|
|||
trigger.operations[j].floatVal = EditorGUILayout.Popup("State:", (int)trigger.operations[j].floatVal, gameObjectStates);
|
||||
|
||||
break;
|
||||
|
||||
case CVRInteractableActionOperation.ActionType.SetComponentActive:
|
||||
|
||||
if (trigger.operations[j].targets.Count == 0)
|
||||
{
|
||||
trigger.operations[j].targets.Add(null);
|
||||
}
|
||||
|
||||
if (trigger.operations[j].floatVal > 2)
|
||||
{
|
||||
trigger.operations[j].floatVal = 0;
|
||||
}
|
||||
|
||||
RenderTargets(trigger.operations[j].targets);
|
||||
|
||||
if (trigger.operations[j].targets[0] != null)
|
||||
{
|
||||
Component[] components = trigger.operations[j].targets[0].GetComponents<Component>();
|
||||
List<string> componentNametList = new List<string>();
|
||||
List<Type> componentList = new List<Type>();
|
||||
componentNametList.Add("- none -");
|
||||
componentList.Add(null);
|
||||
int index = 0;
|
||||
int k = 1;
|
||||
foreach (Component component in components)
|
||||
{
|
||||
if (!componentNametList.Contains(component.GetType().Name))
|
||||
componentNametList.Add(component.GetType().Name);
|
||||
if (!componentList.Contains(component.GetType()))
|
||||
componentList.Add(component.GetType());
|
||||
if (trigger.operations[j].stringVal != null && trigger.operations[j].stringVal == component.GetType().AssemblyQualifiedName) index = k;
|
||||
k++;
|
||||
}
|
||||
|
||||
index = EditorGUILayout.Popup("Component:", index, componentNametList.ToArray());
|
||||
if (index <= 0)
|
||||
{
|
||||
trigger.operations[j].stringVal = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
trigger.operations[j].stringVal = componentList[index].AssemblyQualifiedName;
|
||||
}
|
||||
}
|
||||
|
||||
trigger.operations[j].floatVal = EditorGUILayout.Popup("State:", (int)trigger.operations[j].floatVal, gameObjectStates);
|
||||
|
||||
break;
|
||||
|
||||
case CVRInteractableActionOperation.ActionType.TeleportPlayer:
|
||||
|
||||
|
||||
// align player to whatnot
|
||||
trigger.operations[j].floatVal = EditorGUILayout.Popup("Alignment:",
|
||||
(int)trigger.operations[j].floatVal,
|
||||
new[] { "World Up", "Target Up", "Gravity", "None" });
|
||||
|
||||
// relative teleport, imagine teleporting between identical rooms
|
||||
trigger.operations[j].boolVal = EditorGUILayout.Toggle("Relative Teleport:", trigger.operations[j].boolVal);
|
||||
|
||||
// preserve velocity
|
||||
trigger.operations[j].boolVal2 = EditorGUILayout.Toggle("Preserve Velocity:", trigger.operations[j].boolVal2);
|
||||
|
||||
trigger.operations[j].gameObjectVal = (GameObject)EditorGUILayout.ObjectField(
|
||||
"Target Location:",
|
||||
trigger.operations[j].gameObjectVal,
|
||||
|
@ -879,7 +994,9 @@ namespace ABI.CCK.Scripts.Editor
|
|||
break;
|
||||
case CVRInteractableActionOperation.ActionType.SetPropertyByValue:
|
||||
|
||||
trigger.operations[j].varBufferVal = (CVRVariableBuffer) EditorGUILayout.ObjectField("Variable Buffer", trigger.operations[j].varBufferVal, typeof(CVRVariableBuffer));
|
||||
trigger.operations[j].varBufferVal =
|
||||
(CVRVariableBuffer)EditorGUILayout.ObjectField(new GUIContent("Variable Buffer"),
|
||||
trigger.operations[j].varBufferVal, typeof(CVRVariableBuffer), true);
|
||||
|
||||
trigger.operations[j].gameObjectVal = (GameObject) EditorGUILayout.ObjectField(
|
||||
"Target:",
|
||||
|
@ -939,7 +1056,7 @@ namespace ABI.CCK.Scripts.Editor
|
|||
|
||||
foreach (var finfo in finfos3)
|
||||
{
|
||||
if (finfo.IsPublic)
|
||||
if (finfo.IsPublic && finfo.GetCustomAttribute(typeof(CVRInteractableActionOperation.HideFromSetPropertyByValue)) == null)
|
||||
{
|
||||
if (finfo.FieldType == typeof(float))
|
||||
{
|
||||
|
@ -951,7 +1068,7 @@ namespace ABI.CCK.Scripts.Editor
|
|||
|
||||
foreach (var pinfo in pinfos3)
|
||||
{
|
||||
if (pinfo.CanWrite)
|
||||
if (pinfo.CanWrite && pinfo.GetCustomAttribute(typeof(CVRInteractableActionOperation.HideFromSetPropertyByValue)) == null)
|
||||
{
|
||||
if (pinfo.PropertyType == typeof(float))
|
||||
{
|
||||
|
@ -976,8 +1093,15 @@ namespace ABI.CCK.Scripts.Editor
|
|||
|
||||
break;
|
||||
case CVRInteractableActionOperation.ActionType.DeleteGameObject:
|
||||
trigger.operations[j].gameObjectVal = (GameObject) EditorGUILayout.ObjectField("Target",
|
||||
trigger.operations[j].gameObjectVal, typeof(GameObject));
|
||||
trigger.operations[j].gameObjectVal = (GameObject)EditorGUILayout.ObjectField("Target",
|
||||
trigger.operations[j].gameObjectVal, typeof(GameObject), true);
|
||||
break;
|
||||
|
||||
case CVRInteractableActionOperation.ActionType.LuaFunctionCall:
|
||||
trigger.operations[j].gameObjectVal = (GameObject)EditorGUILayout.ObjectField("Lua Script",
|
||||
trigger.operations[j].gameObjectVal, typeof(GameObject), true);
|
||||
|
||||
trigger.operations[j].stringVal = EditorGUILayout.TextField("Function Name", trigger.operations[j].stringVal);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -990,7 +1114,8 @@ namespace ABI.CCK.Scripts.Editor
|
|||
|
||||
if (GUILayout.Button("Remove Action"))
|
||||
{
|
||||
trigger.operations.RemoveAt(trigger.operations.Count - 1);
|
||||
if (trigger.operations.Count > 0)
|
||||
trigger.operations.RemoveAt(trigger.operations.Count - 1);
|
||||
}
|
||||
if (GUILayout.Button("Add Action"))
|
||||
{
|
||||
|
@ -1006,7 +1131,8 @@ namespace ABI.CCK.Scripts.Editor
|
|||
|
||||
if (GUILayout.Button("Remove Trigger"))
|
||||
{
|
||||
_interactable.actions.RemoveAt(_interactable.actions.Count - 1);
|
||||
if (_interactable.actions.Count > 0)
|
||||
_interactable.actions.RemoveAt(_interactable.actions.Count - 1);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Add Trigger"))
|
||||
|
@ -1014,7 +1140,7 @@ namespace ABI.CCK.Scripts.Editor
|
|||
_interactable.actions.Add(new CVRInteractableAction());
|
||||
}
|
||||
|
||||
if (GUI.changed)
|
||||
if (EditorGUI.EndChangeCheck() || GUI.changed)
|
||||
{
|
||||
EditorUtility.SetDirty (target);
|
||||
}
|
||||
|
@ -1042,12 +1168,13 @@ namespace ABI.CCK.Scripts.Editor
|
|||
|
||||
if (GUILayout.Button("Remove " + caption))
|
||||
{
|
||||
targets.RemoveAt(targets.Count - 1);
|
||||
if (targets is { Count: > 0 })
|
||||
targets.RemoveAt(targets.Count - 1);
|
||||
}
|
||||
if (GUILayout.Button("Add " + caption))
|
||||
{
|
||||
targets.Add(null);
|
||||
targets?.Add(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue