diff --git a/Assets/Plugins/Moon Motion Toolkit/Build/Editor/DefineMoonMotionToolkit.cs b/Assets/Plugins/Moon Motion Toolkit/Build/Editor/DefineMoonMotionToolkit.cs index 0a10cb6..2af80d6 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Build/Editor/DefineMoonMotionToolkit.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Build/Editor/DefineMoonMotionToolkit.cs @@ -3,11 +3,10 @@ using UnityEngine; using UnityEditor; -[InitializeOnLoad] +// #defines public static class DefineMoonMotionToolkit { - static DefineMoonMotionToolkit() - { - Build.ensureDefine("MOON_MOTION_TOOLKIT"); - } + [InitializeOnLoadMethod] + private static void ensureDefine() + => Build.ensureDefine("MOON_MOTION_TOOLKIT"); } \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Locomotions/Dashing/Dashing.cs b/Assets/Plugins/Moon Motion Toolkit/Locomotions/Dashing/Dashing.cs index d700ffe..ae9c7f8 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Locomotions/Dashing/Dashing.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Locomotions/Dashing/Dashing.cs @@ -212,19 +212,19 @@ private void beginDashTo(object raycastHit_RaycastHitProvider) #region updating - + // at each physics update: // public override void physicsUpdate() { - if (operations.operated() && DashingOutlining.outlinedObject) + if (operations.isOperated() && DashingTargeting.targetedObject) { - beginDashTo(DashingOutlining.outliningRaycastHit); + beginDashTo(DashingTargeting.targetingRaycastHit); } else if ( currentlyDashing && ( - (isCancelable && !DashingOutlining.outlinedObject && operations.operated()) || + (isCancelable && !DashingTargeting.targetedObject && operations.isOperated()) || endUponTargetCollision.and(MoonMotionPlayer.isCollidedWith(potentialCurrentTargetCollider)) || diff --git a/Assets/Plugins/Moon Motion Toolkit/Locomotions/Dashing/DashingOutlining.cs b/Assets/Plugins/Moon Motion Toolkit/Locomotions/Dashing/DashingOutlining.cs deleted file mode 100644 index 7538b9c..0000000 --- a/Assets/Plugins/Moon Motion Toolkit/Locomotions/Dashing/DashingOutlining.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -#if ODIN_INSPECTOR -using Sirenix.OdinInspector; -#else -using NaughtyAttributes; -#endif - -// Dashing Outlining: -// • the Outlining Controller Raycasting for the Dashing locomotion -public class DashingOutlining : OutliningControllerRaycasting -{ - -} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Locomotions/Dashing/DashingTargeting.cs b/Assets/Plugins/Moon Motion Toolkit/Locomotions/Dashing/DashingTargeting.cs new file mode 100644 index 0000000..1072744 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Locomotions/Dashing/DashingTargeting.cs @@ -0,0 +1,10 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +// Dashing Targeting: +// • the Controller Raycasting Targeting for the Dashing locomotion +public class DashingTargeting : ControllerRaycastingTargeting +{ + +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Locomotions/Dashing/DashingOutlining.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Locomotions/Dashing/DashingTargeting.cs.meta similarity index 100% rename from Assets/Plugins/Moon Motion Toolkit/Locomotions/Dashing/DashingOutlining.cs.meta rename to Assets/Plugins/Moon Motion Toolkit/Locomotions/Dashing/DashingTargeting.cs.meta diff --git a/Assets/Plugins/Moon Motion Toolkit/Locomotions/Dashing/Default Dashing Highlighting.asset b/Assets/Plugins/Moon Motion Toolkit/Locomotions/Dashing/Default Dashing Highlighting.asset new file mode 100644 index 0000000..9d3b671 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Locomotions/Dashing/Default Dashing Highlighting.asset @@ -0,0 +1,71 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8e9253636bf2648bd813257f451f8486, type: 3} + m_Name: Default Dashing Highlighting + m_EditorClassIdentifier: + constantWidth: 0 + effectGroup: 1 + effectGroupLayer: + serializedVersion: 2 + m_Bits: 18 + alphaCutOff: 0 + cullBackFaces: 1 + fadeInDuration: 0.1 + fadeOutDuration: 0.1 + overlay: 0 + overlayColor: {r: 0, g: 1, b: 0, a: 1} + overlayAnimationSpeed: 1.25 + overlayMinIntensity: 0 + overlayBlending: 1 + outline: 0 + outlineColor: {r: 0, g: 0, b: 0, a: 1} + outlineWidth: 0.4 + outlineQuality: 2 + outlineVisibility: 0 + glow: 0.3 + glowWidth: 0.4 + glowQuality: 1 + glowHQColor: {r: 0, g: 0, b: 0, a: 1} + glowDithering: 0 + glowMagicNumber1: 0.75 + glowMagicNumber2: 0.5 + glowAnimationSpeed: 3 + glowVisibility: 0 + glowPasses: + - offset: 4 + alpha: 0.1 + color: {r: 0, g: 1, b: 0, a: 1} + - offset: 3 + alpha: 0.2 + color: {r: 0.07035923, g: 1, b: 0, a: 1} + - offset: 2 + alpha: 0.3 + color: {r: 0.20369065, g: 1, b: 0, a: 1} + - offset: 1 + alpha: 0.4 + color: {r: 0.9468056, g: 1, b: 0, a: 1} + innerGlow: 0 + innerGlowWidth: 1 + innerGlowColor: {r: 0, g: 0, b: 0, a: 1} + innerGlowVisibility: 0 + targetFX: 0 + targetFXTexture: {fileID: 2800000, guid: 1de3c566a6c8c405b9f6f453137273ec, type: 3} + targetFXColor: {r: 1, g: 1, b: 1, a: 1} + targetFXRotationSpeed: 30 + targetFXInitialScale: 4 + targetFXEndScale: 1.5 + targetFXTransitionDuration: 0.5 + targetFXStayDuration: 1.5 + seeThrough: 0 + seeThroughIntensity: 0.8 + seeThroughTintAlpha: 0.3 + seeThroughTintColor: {r: 0, g: 1, b: 0.09638786, a: 1} + seeThroughNoise: 0 diff --git a/Assets/Plugins/Moon Motion Toolkit/Locomotions/Dashing/Default Dashing Highlighting.asset.meta b/Assets/Plugins/Moon Motion Toolkit/Locomotions/Dashing/Default Dashing Highlighting.asset.meta new file mode 100644 index 0000000..eff579f --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Locomotions/Dashing/Default Dashing Highlighting.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d3b1545417e20b94fb56af1178d8daaa +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Locomotions/Sweeping/Sweeping.cs b/Assets/Plugins/Moon Motion Toolkit/Locomotions/Sweeping/Sweeping.cs index cc8d013..b07704d 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Locomotions/Sweeping/Sweeping.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Locomotions/Sweeping/Sweeping.cs @@ -222,15 +222,15 @@ private void beginSweepVia(Controller sweepingController) // at each physics update: // public override void physicsUpdate() { - if (operations.operated() && !currentlySweeping) + if (operations.isOperated() && !currentlySweeping) { - beginSweepVia(operations.firstOperatedControllerOtherwiseFallback()); + beginSweepVia(operations.firstRelevantController()); } else if ( currentlySweeping && ( - (isCancelable && operations.operated()) || + (isCancelable && operations.isOperated()) || (limitSweepDuration && (timeSince(sweepStartingTime) > sweepDurationLimit)) || diff --git a/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Outlining Controller Raycasting.meta b/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controller Raycasting Targeting.meta similarity index 100% rename from Assets/Plugins/Moon Motion Toolkit/Player/Hands/Outlining Controller Raycasting.meta rename to Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controller Raycasting Targeting.meta diff --git a/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controller Raycasting Targeting/ControllerRaycastingTargeting.cs b/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controller Raycasting Targeting/ControllerRaycastingTargeting.cs new file mode 100644 index 0000000..f200114 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controller Raycasting Targeting/ControllerRaycastingTargeting.cs @@ -0,0 +1,352 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +#if ODIN_INSPECTOR +using Sirenix.OdinInspector; +#else +using NaughtyAttributes; +#endif +#if HIGHLIGHT_PLUS +using HighlightPlus; +#endif + +// Controller Raycasting Targeting: +// • while any of the controller operations is operated, raycasts from the first relevant controller, targets the raycasted object (∗) if any, tracking and highlighting it +// · if Highlight Plus is not available, will not highlight the target +public abstract class ControllerRaycastingTargeting : + SingletonBehaviour + where ControllerRaycastingTargetingT : ControllerRaycastingTargeting + +{ + #region variables + + + #region editor visualization + + #if ODIN_INSPECTOR + [TabGroup("Editor Visualization")] + #else + [BoxGroup("Editor Visualization")] + #endif + [Tooltip("whether to visualize the line of the raycast")] + public bool visualizeLine = Default.choiceToVisualizeInEditor; + + #if ODIN_INSPECTOR + [TabGroup("Editor Visualization")] + [Indent] + [ShowIf("visualizeLine")] + [HideLabel] + #else + [BoxGroup("Editor Visualization")] + #endif + [Tooltip("the color to use for editor visualization")] + public Color visualizationColor = Default.visualizationColor; + #endregion editor visualization + + + #region control + + #if ODIN_INSPECTOR + [TabGroup("Control")] + #else + [BoxGroup("Control")] + #endif + [Tooltip("the controller operations by which to raycast")] + #if ODIN_INSPECTOR + #if UNITY_EDITOR + [ListItemSelector("operations_SetSelected")] + #endif + #else + [ReorderableList] + #endif + public ControllerOperation[] operations; + #region selected operation + #if ODIN_INSPECTOR + #if UNITY_EDITOR + [TabGroup("Control")] + [InlineEditor(InlineEditorObjectFieldModes.CompletelyHidden, Expanded = true)] + [HideLabel] + [ShowInInspector] + #pragma warning disable 0414 + private ControllerOperation operations_ListItemSelected; + #pragma warning restore 0414 + public void operations_SetSelected(int index) + => operations_ListItemSelected = operations.itemOtherwiseDefault(index); + #endif + #endif + #endregion selected operation + #endregion control + + + #region raycasting + [InfoBox("Raycasting is nonpositional (does not include colliders overlapping this position) and is from the first relevant controller. It will detect the first raycasted object that is not static and has a lodal mesh filter or, otherwise, skinned mesh renderer. (Objects not meeting those requirements will not obscure raycasting.)")] // ∗ + + #if ODIN_INSPECTOR + [TabGroup("Raycasting")] + #else + [BoxGroup("Raycasting")] + #endif + public Vector3 localDirection = Default.raycastingDirection; + + #if ODIN_INSPECTOR + [TabGroup("Raycasting")] + #else + [BoxGroup("Raycasting")] + #endif + public float distance = Default.targetingRaycastingDistance; + + #if ODIN_INSPECTOR + [TabGroup("Raycasting")] + [EnumToggleButtons] + #else + [BoxGroup("Raycasting")] + #endif + public QueryTriggerInteraction triggerColliderQuery = Default.raycastingTriggerColliderQuery; + + #if ODIN_INSPECTOR + [TabGroup("Raycasting")] + #else + [BoxGroup("Raycasting")] + #endif + public LayerMask layerMask = Default.layerMask; + + // the controller that last did the raycasting // + public static Controller raycastingController {get; private set;} + + // the current raycast hit // + public static RaycastHit? targetingRaycastHit {get; private set;} + + // the currently raycasted/targeted object // + public static GameObject targetedObject {get; private set;} + #endregion raycasting + + + #region highlighting + #if HIGHLIGHT_PLUS + [InfoBox("While any of the controller operations is operated, the first raycasted object will be highlighted.")] + + #if ODIN_INSPECTOR + [TabGroup("Highlighting")] + //[InlineEditor(InlineEditorObjectFieldModes.CompletelyHidden)] + #else + [BoxGroup("Highlighting")] + #endif + public HighlightProfile highlighting = null; + + private bool highlightingTrackings_ShowIf => couldBeAwakeRightNow; + + #if ODIN_INSPECTOR + [TabGroup("Highlighting")] + [ShowIf("highlightingTrackings_ShowIf")] + [LabelText("Highlightable Target Compo.")] + [ReadOnly] + [ShowInInspector] + #endif + public Component highlightableComponentOfTargetObject {get; private set;} = null; + + #if ODIN_INSPECTOR + [TabGroup("Highlighting")] + [ShowIf("highlightingTrackings_ShowIf")] + [ReadOnly] + [ShowInInspector] + #endif + public HighlightEffect targetHighlight {get; private set;} = null; + #endif + #endregion highlighting + + + #region line rendering + + #if ODIN_INSPECTOR + [TabGroup("Line Rendering")] + #else + [BoxGroup("Line Rendering")] + #endif + [Tooltip("whether to render a line representing the raycast")] + public bool renderLine = Default.choiceToRenderRaycastLine; + + #if ODIN_INSPECTOR + [TabGroup("Line Rendering")] + [Indent] + [PreviewField(Alignment = ObjectFieldAlignment.Center, AlignmentHasValue = true, Height = 60)] + [ShowIf("renderLine")] + [HideLabel] + #else + [BoxGroup("Line Rendering")] + #endif + [Tooltip("the material with which to render the line representing the raycast")] + public Material lineMaterial; + + #if ODIN_INSPECTOR + [TabGroup("Line Rendering")] + [Indent] + [SuffixLabel("Width", Overlay = true)] + [ShowIf("renderLine")] + [HideLabel] + #else + [BoxGroup("Line Rendering")] + #endif + [Tooltip("the width at which to render the line representing the raycast")] + public float lineWidth = Default.lineRendererWidth; + + #if ODIN_INSPECTOR + [TabGroup("Line Rendering")] + [Indent] + [LabelText("Render Only To Raycast Hit")] + [ShowIf("renderLine")] + #else + [BoxGroup("Line Rendering")] + #endif + [Tooltip("whether to render the line only to the raycast hit versus for the set distance")] + public bool renderLineOnlyToHit = Default.choiceToRenderRaycastLineOnlyToHit; + #endregion line rendering + + + #region feedback + + #if ODIN_INSPECTOR + private void defaultVibrationIntensity() + => vibrationIntensity = Default.targetingVibrationIntensity; + [TabGroup("Feedback")] + [InlineButton("defaultVibrationIntensity", "Default")] + #else + [BoxGroup("Feedback")] + #endif + [Tooltip("the intensity at which to vibrate the raycasting controller when highlighting and unoutlining an object")] + public ushort vibrationIntensity = Default.targetingVibrationIntensity; + #endregion feedback + #endregion variables + + + + + #region methods + + + // method: return the potential raycast hit (∗), potentially track the highlightable component of the target object, and render a line to represent the raycast while doing so, if set to // + public RaycastHit? potentialHitRaycastingBy(Controller controller) + { + RaycastHit? potentialRaycastHit = controller.firstNonpositionallyRaycastedHitLocallyWhere + ( + raycastHitToEvaluate => + { + #if HIGHLIGHT_PLUS + highlightableComponentOfTargetObject = null; + #endif + + #if HIGHLIGHT_PLUS + bool firstFoundAMeshFilter_IfFoundAnyHighlightableComponent = false; + #endif + + bool raycastHitIsValid + = raycastHitToEvaluate.objectIsNotStatic() && + ( + ( + #if HIGHLIGHT_PLUS + firstFoundAMeshFilter_IfFoundAnyHighlightableComponent = + #endif + raycastHitToEvaluate.hasAnyLodal() + ) || + raycastHitToEvaluate.hasAnyLodal() + ); + + #if HIGHLIGHT_PLUS + highlightableComponentOfTargetObject + = firstFoundAMeshFilter_IfFoundAnyHighlightableComponent ? + raycastHitToEvaluate.firstLodal().castTo() : + raycastHitToEvaluate.firstLodal().castTo(); + #endif + + return raycastHitIsValid; + }, + localDirection, + distance, + triggerColliderQuery, + layerMask + ); + + if (renderLineOnlyToHit && potentialRaycastHit.isYull()) + { + setupLineRendererAsLineOfLightLocallyDirectedFrom + ( + controller, + localDirection, + controller.distanceWith(potentialRaycastHit.GetValueOrDefault()), + lineMaterial + ); + } + else + { + setupLineRendererAsLineOfLightLocallyDirectedFrom + ( + controller, + localDirection, + distance, + lineMaterial + ); + } + + return potentialRaycastHit; + } + #endregion methods + + + + + #region updating + + + // upon editor visualization: // + private void OnDrawGizmos() + { + if (!raycastingController && UnityIs.inEditorEditMode) + { + raycastingController = Controller.left; + } + + if (raycastingController) + { + Visualize.localLineFrom(raycastingController, localDirection, distance, + visualizeLine, + visualizationColor); + } + } + + // at each late update: // + public override void lateUpdate() // Late Update instead of Update so that the line renderer isn't seen in two places for a frame when turning via the turning locomotion, and probably other situations too + { + bool operationsOperated = operations.isOperated(); + targetingRaycastHit = operationsOperated ? + potentialHitRaycastingBy + ( + raycastingController = operations.firstRelevantController() + ) : + null; + lineRenderer.setEnablementTo(operationsOperated); + + GameObject objectRaycasted = targetingRaycastHit.gameObjectIfYull(); + + if (targetedObject != objectRaycasted) + { + #if HIGHLIGHT_PLUS + if (targetHighlight.isYull()) + { + targetHighlight.finishHighlighting(); + targetHighlight = null; + } + #endif + + targetedObject = objectRaycasted; + + #if HIGHLIGHT_PLUS + if (targetedObject) + { + targetHighlight = highlightableComponentOfTargetObject.beginGetHighlight(highlighting); + } + #endif + + raycastingController.vibrate(vibrationIntensity); + } + } + #endregion updating +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Outlining Controller Raycasting/OutliningControllerRaycasting.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controller Raycasting Targeting/ControllerRaycastingTargeting.cs.meta similarity index 100% rename from Assets/Plugins/Moon Motion Toolkit/Player/Hands/Outlining Controller Raycasting/OutliningControllerRaycasting.cs.meta rename to Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controller Raycasting Targeting/ControllerRaycastingTargeting.cs.meta diff --git a/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Outlining Controller Raycasting/Outline Controller Raycasting Operation.asset b/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controller Raycasting Targeting/Default Controller Raycasting Targeting Operation.asset similarity index 60% rename from Assets/Plugins/Moon Motion Toolkit/Player/Hands/Outlining Controller Raycasting/Outline Controller Raycasting Operation.asset rename to Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controller Raycasting Targeting/Default Controller Raycasting Targeting Operation.asset index 2136fd9..749dc17 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Outlining Controller Raycasting/Outline Controller Raycasting Operation.asset +++ b/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controller Raycasting Targeting/Default Controller Raycasting Targeting Operation.asset @@ -9,8 +9,17 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 901e12d04729f5440ab0c78ba8b82cae, type: 3} - m_Name: Outline Controller Raycasting Operation + m_Name: Default Controller Raycasting Targeting Operation m_EditorClassIdentifier: + serializationData: + SerializedFormat: 2 + SerializedBytes: + ReferencedUnityObjects: [] + SerializedBytesString: + Prefab: {fileID: 0} + PrefabModificationsReferencedUnityObjects: [] + PrefabModifications: [] + SerializationNodes: [] handedness: 7 fallbackToLeftVersusRight: 1 inputs: diff --git a/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Outlining Controller Raycasting/Outline Controller Raycasting Operation.asset.meta b/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controller Raycasting Targeting/Default Controller Raycasting Targeting Operation.asset.meta similarity index 100% rename from Assets/Plugins/Moon Motion Toolkit/Player/Hands/Outlining Controller Raycasting/Outline Controller Raycasting Operation.asset.meta rename to Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controller Raycasting Targeting/Default Controller Raycasting Targeting Operation.asset.meta diff --git a/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controller Raycasting Targeting/GenericControllerRaycastingTargeting.cs b/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controller Raycasting Targeting/GenericControllerRaycastingTargeting.cs new file mode 100644 index 0000000..70445b8 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controller Raycasting Targeting/GenericControllerRaycastingTargeting.cs @@ -0,0 +1,10 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +// Generic Controller Raycasting Targeting: +// • the generic Controller Raycasting Targeting that the player uses by default +public class GenericControllerRaycastingTargeting : ControllerRaycastingTargeting +{ + +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Outlining Controller Raycasting/GenericOutliningControllerRaycasting.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controller Raycasting Targeting/GenericControllerRaycastingTargeting.cs.meta similarity index 100% rename from Assets/Plugins/Moon Motion Toolkit/Player/Hands/Outlining Controller Raycasting/GenericOutliningControllerRaycasting.cs.meta rename to Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controller Raycasting Targeting/GenericControllerRaycastingTargeting.cs.meta diff --git a/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controllers/ControllerOperation.cs b/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controllers/ControllerOperation.cs index 8536963..40d3d7b 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controllers/ControllerOperation.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controllers/ControllerOperation.cs @@ -1,6 +1,9 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using Handedness = Controller.Handedness; +using Input = Controller.Input; +using Inputtedness = Controller.Inputtedness; #if ODIN_INSPECTOR using Sirenix.OdinInspector; #else @@ -30,13 +33,11 @@ public class ControllerOperation : ResetFixedScriptableObject #else [BoxGroup("Handedness")] #endif - public Controller.Handedness handedness = Default.controllerHandedness; - - private bool fallbackToLeftVersusRight_ShowIf => handedness.isInfinite(); - [Tooltip("whether to return the left versus the right controller as the first operated controller when operating without any controllers operating (only relevant when handedness is infinite)")] + public Handedness handedness = Default.controllerHandedness; + + [Tooltip("whether to return the left versus the right controller as the first relevant controller when:\n· operating without any controllers operating (when handedness is infinite)\n· none of the operations being evaluated are currently operated")] #if ODIN_INSPECTOR [TabGroup("Handedness")] - [ShowIf("fallbackToLeftVersusRight_ShowIf")] #else [BoxGroup("Handedness")] #endif @@ -49,7 +50,7 @@ public class ControllerOperation : ResetFixedScriptableObject [BoxGroup("Input")] [ReorderableList] #endif - public Controller.Input[] inputs; + public Input[] inputs; [Tooltip("the controller inputtednesses (to check operation by)")] #if ODIN_INSPECTOR @@ -58,7 +59,7 @@ public class ControllerOperation : ResetFixedScriptableObject [BoxGroup("Input")] [ReorderableList] #endif - public Controller.Inputtedness[] inputtednesses; + public Inputtedness[] inputtednesses; [Tooltip("the states of being (to check operation at)")] #if ODIN_INSPECTOR @@ -94,7 +95,9 @@ public class ControllerOperation : ResetFixedScriptableObject #region properties - // the controller to fallback to as the first operated controller when operating without any controllers operating (when handedness is infinite) // + // the controller to fallback to: + // · as the relevant controller when operating without any controllers operating (when handedness is infinite) + // · when the relevant controller for some operations is requested but none of those operations are currently operated public Controller fallbackController => fallbackToLeftVersusRight ? Controller.left : Controller.right; #endregion properties diff --git a/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controllers/ControllerOperationExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controllers/ControllerOperationExtensions.cs index 1240ff4..e7173fb 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controllers/ControllerOperationExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Controllers/ControllerOperationExtensions.cs @@ -7,7 +7,7 @@ public static class ControllerOperationExtensions { // method: return whether these operations are currently operated // - public static bool operated(this ControllerOperation[] controllerOperations) + public static bool isOperated(this ControllerOperation[] controllerOperations) => Controller.operated(controllerOperations); // method: return the set of controllers for which any of the given operations are currently operated // @@ -23,7 +23,16 @@ public static ControllerOperation firstOperatedOperation(this IEnumerable controllerOperations) => controllerOperations.firstOperatedOperation().fallbackController; - // method: return the first controller for which any of the given operations are currently operated, otherwise returning the left controller // - public static Controller firstOperatedControllerOtherwiseFallback(this ControllerOperation[] controllerOperations) - => controllerOperations.operatedControllers().firstOtherwise(controllerOperations.fallbackControllerOfFirstOperatedOperation()); + // method: return the fallback controller of the first operation of these given operations // + public static Controller fallbackControllerOfFirstOperation(this IEnumerable controllerOperations) + => controllerOperations.first().fallbackController; + + // method: return the first controller for which any of the given operations are currently operated, otherwise returning the fallback controller of the first operated operation if any of the given operations are currently operated, otherwise returning the fallback controller of the first operation // + public static Controller firstRelevantController(this ControllerOperation[] controllerOperations) + => controllerOperations.operatedControllers().firstOtherwise + ( + controllerOperations.isOperated() ? + controllerOperations.fallbackControllerOfFirstOperatedOperation() : + controllerOperations.fallbackControllerOfFirstOperation() + ); } \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Outlining Controller Raycasting/GenericOutliningControllerRaycasting.cs b/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Outlining Controller Raycasting/GenericOutliningControllerRaycasting.cs deleted file mode 100644 index af0a8ba..0000000 --- a/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Outlining Controller Raycasting/GenericOutliningControllerRaycasting.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using NaughtyAttributes; - -// Generic Outlining Controller Raycasting: -// • the generic Outlining Controller Raycasting that the player uses by default -public class GenericOutliningControllerRaycasting : OutliningControllerRaycasting -{ - -} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Outlining Controller Raycasting/OutliningControllerRaycasting.cs b/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Outlining Controller Raycasting/OutliningControllerRaycasting.cs deleted file mode 100644 index eea4aa8..0000000 --- a/Assets/Plugins/Moon Motion Toolkit/Player/Hands/Outlining Controller Raycasting/OutliningControllerRaycasting.cs +++ /dev/null @@ -1,368 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -#if ODIN_INSPECTOR -using Sirenix.OdinInspector; -#else -using NaughtyAttributes; -#endif -using Valve.VR.InteractionSystem; -using UnityEditor; - -// Outlining Controller Raycasting: -// • while any of the controller operations is operated, outlines the raycasted object (∗) if any -// · does this by maintaining a child object with the set outline material that matches the raycasted object's shape and transformations -public abstract class OutliningControllerRaycasting : - SingletonBehaviour - where OutliningControllerRaycastingT : OutliningControllerRaycasting - -{ - #region variables - - - #region editor visualization - - #if ODIN_INSPECTOR - [TabGroup("Editor Visualization")] - #else - [BoxGroup("Editor Visualization")] - #endif - [Tooltip("whether to visualize the line of the raycast")] - public bool visualizeLine = Default.choiceToVisualizeInEditor; - - #if ODIN_INSPECTOR - [TabGroup("Editor Visualization")] - [Indent] - [ShowIf("visualizeLine")] - [HideLabel] - #else - [BoxGroup("Editor Visualization")] - #endif - [Tooltip("the color to use for editor visualization")] - public Color visualizationColor = Default.visualizationColor; - #endregion editor visualization - - - #region control - - #if ODIN_INSPECTOR - [TabGroup("Control")] - #else - [BoxGroup("Control")] - #endif - [Tooltip("the controller operations by which to raycast and so outline")] - #if ODIN_INSPECTOR - #if UNITY_EDITOR - [ListItemSelector("operations_SetSelected")] - #endif - #else - [ReorderableList] - #endif - public ControllerOperation[] operations; - #region selected operation - #if ODIN_INSPECTOR - #if UNITY_EDITOR - [TabGroup("Control")] - [InlineEditor(InlineEditorObjectFieldModes.CompletelyHidden, Expanded = true)] - [HideLabel] - [ShowInInspector] - #pragma warning disable 0414 - private ControllerOperation operations_ListItemSelected; - #pragma warning restore 0414 - public void operations_SetSelected(int index) - => operations_ListItemSelected = operations.itemOtherwiseDefault(index); - #endif - #endif - #endregion selected operation - #endregion control - - - #region raycasting - [InfoBox("Raycasting is nonpositional (does not include colliders overlapping this position) and is from the first operating controller (otherwise the fallback controller for the first operated operation). It will detect the first raycasted object that has a local\\descendant mesh filter or otherwise skinned mesh renderer or otherwise capsule collider, and is not static. (Objects not meeting those requirements will not obscure raycasting.)")] // ∗ - - #if ODIN_INSPECTOR - [TabGroup("Raycasting")] - #else - [BoxGroup("Raycasting")] - #endif - public Vector3 localDirection = Default.raycastingDirection; - - #if ODIN_INSPECTOR - [TabGroup("Raycasting")] - #else - [BoxGroup("Raycasting")] - #endif - public float distance = Default.outlineRaycastingDistance; - - #if ODIN_INSPECTOR - [TabGroup("Raycasting")] - [EnumToggleButtons] - #else - [BoxGroup("Raycasting")] - #endif - public QueryTriggerInteraction triggerColliderQuery = Default.raycastingTriggerColliderQuery; - - #if ODIN_INSPECTOR - [TabGroup("Raycasting")] - #else - [BoxGroup("Raycasting")] - #endif - public LayerMask layerMask = Default.layerMask; - - // the controller that last did the raycasting // - public static Controller raycastingController {get; private set;} - - // the current raycast hit // - public static RaycastHit? outliningRaycastHit {get; private set;} - - // the currently raycasted object to outline // - public static GameObject outlinedObject {get; private set;} - - // the kind of shape provider found (first) on the last outlined object upon being raycasted (mesh filter, by default) // - public static ShapeProviderKind shapeProviderKindFound = ShapeProviderKind.meshFilter; - // whether the kind of shape provider found is mesh filter // - public static bool foundMeshFilter => shapeProviderKindFound.isMeshFilter(); - // whether the kind of shape provider found is skinned mesh renderer // - public static bool foundSkinnedMeshRenderer => shapeProviderKindFound.isSkinnedMeshRenderer(); - // whether the kind of shape provider found is primitive collider // - public static bool foundPrimitiveCollider => shapeProviderKindFound.isPrimitiveCollider(); - - // the offset of the outlined object's primitive collider from the outlined object, by which to also offset the outline shading object – outlining via a found primitive collider – otherwise the zeroes floats vector // - public static Vector3 offsetNecessaryForPotentiallyUsedPrimitiveCollider - => foundPrimitiveCollider ? - outlinedObject.providePrimitiveColliderLocalCenterPosition().multiplyBy(outlinedObject.localScale()) : - FloatsVector.zeroes; - #endregion raycasting - - - #region outlining - [InfoBox("While any of the controller operations is operated, the first raycasted object will be outlined.")] - - public static readonly string outlineShadingObjectName = "Outline Controller Raycasting - Outline"; - - #if ODIN_INSPECTOR - [TabGroup("Outlining")] - [PreviewField(Alignment = ObjectFieldAlignment.Left, AlignmentHasValue = true, Height = 100)] - [HideLabel] - #else - [BoxGroup("Outlining")] - #endif - [Tooltip("the outline material to use for the outline shading object; will be set to the default outline material at the start if null")] - public Material outlineMaterial = null; - - // the outline object (reused between raycasted objects) for shading an outline of the outlined object // - public static GameObject outlineShadingObject {get; private set;} - #endregion outlining - - - #region line rendering - - #if ODIN_INSPECTOR - [TabGroup("Line Rendering")] - #else - [BoxGroup("Line Rendering")] - #endif - [Tooltip("whether to render a line representing the raycast")] - public bool renderLine = Default.choiceToRenderRaycastLine; - - #if ODIN_INSPECTOR - [TabGroup("Line Rendering")] - [Indent] - [PreviewField(Alignment = ObjectFieldAlignment.Center, AlignmentHasValue = true, Height = 60)] - [ShowIf("renderLine")] - [HideLabel] - #else - [BoxGroup("Line Rendering")] - #endif - [Tooltip("the material with which to render the line representing the raycast")] - public Material lineMaterial; - - #if ODIN_INSPECTOR - [TabGroup("Line Rendering")] - [Indent] - [SuffixLabel("Width", Overlay = true)] - [ShowIf("renderLine")] - [HideLabel] - #else - [BoxGroup("Line Rendering")] - #endif - [Tooltip("the width at which to render the line representing the raycast")] - public float lineWidth = Default.lineRendererWidth; - - #if ODIN_INSPECTOR - [TabGroup("Line Rendering")] - [Indent] - [LabelText("Render Only To Raycast Hit")] - [ShowIf("renderLine")] - #else - [BoxGroup("Line Rendering")] - #endif - [Tooltip("whether to render the line only to the raycast hit versus for the set distance")] - public bool renderLineOnlyToHit = Default.choiceToRenderRaycastLineOnlyToHit; - #endregion line rendering - - - #region feedback - - #if ODIN_INSPECTOR - [TabGroup("Feedback")] - #else - [BoxGroup("Feedback")] - #endif - [Tooltip("the intensity at which to vibrate the raycasting controller when outlining and unoutlining an object")] - public ushort vibrationIntensity = Default.vibrationIntensity; - #endregion feedback - #endregion variables - - - - - #region methods - - - // method: return the potential raycast hit (∗), track some variables related to the raycast accordingly, and render a line to represent the raycast while doing so, if set to // - public RaycastHit? potentialHitRaycastingBy(Controller controller) - { - RaycastHit? potentialRaycastHit = controller.firstNonpositionallyRaycastedHitLocallyWhere - ( - raycastHitToEvaluate => - { - bool firstFoundAMeshFilter = false; - bool firstFoundASkinnedMeshRenderer = false; - - bool raycastHitIsValid - = ( - (firstFoundAMeshFilter = raycastHitToEvaluate.hasAnyLodal()) || - (firstFoundASkinnedMeshRenderer = raycastHitToEvaluate.hasAnyLodal()) || - raycastHitToEvaluate.hasAnyLodal() - ) && - raycastHitToEvaluate.objectIsNotStatic(); - - shapeProviderKindFound = ShapeProvider.kindFor(firstFoundAMeshFilter, firstFoundASkinnedMeshRenderer); - - return raycastHitIsValid; - }, - localDirection, - distance, - triggerColliderQuery, - layerMask - ); - - if (renderLineOnlyToHit && potentialRaycastHit.isYull()) - { - setupLineRendererAsLineOfLightLocallyDirectedFrom - ( - controller, - localDirection, - controller.distanceWith(potentialRaycastHit.GetValueOrDefault()), - lineMaterial - ); - } - else - { - setupLineRendererAsLineOfLightLocallyDirectedFrom - ( - controller, - localDirection, - distance, - lineMaterial - ); - } - - return potentialRaycastHit; - } - #endregion methods - - - - - #region updating - - - // upon editor visualization: // - private void OnDrawGizmos() - { - if (!raycastingController && UnityIs.inEditorEditMode) - { - raycastingController = Controller.left; - } - - if (raycastingController) - { - Visualize.localLineFrom(raycastingController, localDirection, distance, - visualizeLine, - visualizationColor); - } - } - - // at the start: // - private void Start() - => outlineShadingObject = createChildObject(outlineShadingObjectName) - .deactivate() - .setMaterialTo(outlineMaterial.ifYullOtherwise(()=> - outlineMaterial = Default.outlineMaterial_IfInAwakeOrStart)); - - // at each late update: // - public override void lateUpdate() // Late Update instead of Update so that the line renderer isn't seen in two places for a frame when turning via the turning locomotion, and probably other situations too - { - bool operationsOperated = operations.operated(); - outliningRaycastHit = operationsOperated ? - potentialHitRaycastingBy - ( - raycastingController = operations.firstOperatedControllerOtherwiseFallback() - ) : - null; - lineRenderer.setEnablementTo(operationsOperated); - - GameObject objectRaycasted = outliningRaycastHit.gameObjectIfYull(); - - if (outlinedObject != objectRaycasted) - { - outlinedObject = objectRaycasted; - - if (outlinedObject) - { - if (foundMeshFilter || foundPrimitiveCollider) - { - outlineShadingObject - .destroyFirstIfAny(true) - .setMeshTo(outlinedObject) - .ensuredlyMatchTransformationsTo - ( - outlinedObject, - offsetNecessaryForPotentiallyUsedPrimitiveCollider - ); - - atNextCheckExecute(()=> // this delay is necessary in order for any skinned mesh renderer to finish being destroyed, so that a mesh renderer can actually be created - { - outlineShadingObject.setMaterialTo(outlineMaterial); - }); - } - else // if 'foundSkinnedMeshRenderer' - { - GameObject skinnedMeshRendererObject - = outlinedObject.firstLodalObjectWith(); - outlineShadingObject.destroy(); - outlineShadingObject - = skinnedMeshRendererObject - .createDuplicateMaintainingOnlyComponentsDerivedFrom_ViaReflection(outlineShadingObjectName) - .setParentTo(this) - .setLabelsTo(this) - .setMaterialTo(outlineMaterial) - .ensuredlyMatchTransformationsTo(skinnedMeshRendererObject); - } - outlineShadingObject.activate(); - } - else - { - outlineShadingObject - .deactivate() - .ensuredlyMatchTransformationsToNull() - .removeMeshIfAny(); - } - - raycastingController.vibrate(vibrationIntensity); - } - } - #endregion updating -} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Player/Player.prefab b/Assets/Plugins/Moon Motion Toolkit/Player/Player.prefab index 3a0c8d4..666b143 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Player/Player.prefab +++ b/Assets/Plugins/Moon Motion Toolkit/Player/Player.prefab @@ -14237,11 +14237,11 @@ MonoBehaviour: - {fileID: 11400000, guid: ddba4789ad88ccd4f90fdea5c5fdae1a, type: 2} localDirection: {x: 0, y: 0, z: 1} distance: Infinity - triggerColliderQuery: 2 + triggerColliderQuery: 1 layerMask: serializedVersion: 2 - m_Bits: 4160746697 - outlineMaterial: {fileID: 2100000, guid: 456bbe229301a4841bbdcadb5c22c6e9, type: 2} + m_Bits: 16774145 + highlighting: {fileID: 0} renderLine: 1 lineMaterial: {fileID: 2100000, guid: 2bf1a032eaa181743b88fb551e7481cb, type: 2} lineWidth: 0.01 diff --git a/Assets/Plugins/Moon Motion Toolkit/Plugins/Odin Hierarchy/Odin Hierarchy Settings.asset b/Assets/Plugins/Moon Motion Toolkit/Plugins/Odin Hierarchy/Odin Hierarchy Settings.asset index 2f18d03..cbbf597 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Plugins/Odin Hierarchy/Odin Hierarchy Settings.asset +++ b/Assets/Plugins/Moon Motion Toolkit/Plugins/Odin Hierarchy/Odin Hierarchy Settings.asset @@ -16,6 +16,7 @@ MonoBehaviour: iconPaddingRight: 6 stylizations: - name: Layer Labeling + expandedObjectsOnly: 0 prefabInstancesOnly: 0 useStringContainmentConditions: 0 nameContains: @@ -30,15 +31,46 @@ MonoBehaviour: icon: 0 sizeAdjustment: 0 paddingRightAdjustment: 0 - iconName_: + iconName_: Stop drawText: 1 useLayerName: 1 + treatDefaultLayerNameAsEmpty: 0 + useUniqueColorForDefaultLayerLabels: 1 + defaultLayerLabelColor: {r: 0.48235297, g: 0.48235297, b: 0.48235297, a: 0.5019608} overrideText: blah textAnchor: 5 decoration: 0 decorationType: 3 decorationColor: {r: 0, g: 1, b: 0, a: 0.30980393} - name: Containers + expandedObjectsOnly: 0 + prefabInstancesOnly: 0 + useStringContainmentConditions: 1 + nameContains: + layerContains: + scene: + component: + attribute: Container + component_matching: + drawBackgroundColor: 1 + color: {r: 0.21960786, g: 0.21960786, b: 0.21960786, a: 0.39215687} + style: 4 + icon: 1 + sizeAdjustment: 2.5 + paddingRightAdjustment: 0 + iconName_: FolderBack + drawText: 0 + useLayerName: 0 + treatDefaultLayerNameAsEmpty: 0 + useUniqueColorForDefaultLayerLabels: 1 + defaultLayerLabelColor: {r: 0.827451, g: 0.827451, b: 0.827451, a: 1} + overrideText: Teeeeee + textAnchor: 5 + decoration: 0 + decorationType: 2 + decorationColor: {r: 0.16078432, g: 0.16078432, b: 0.16078432, a: 1} + - name: Containers - Expanded + expandedObjectsOnly: 1 prefabInstancesOnly: 0 useStringContainmentConditions: 1 nameContains: @@ -48,20 +80,51 @@ MonoBehaviour: attribute: Container component_matching: drawBackgroundColor: 0 - color: {r: 1, g: 0.92156863, b: 0.015686275, a: 1} + color: {r: 0.16078432, g: 0.16078432, b: 0.16078432, a: 0.89411765} style: 4 icon: 1 - sizeAdjustment: 4.5 - paddingRightAdjustment: 5 + sizeAdjustment: 2.5 + paddingRightAdjustment: 0 iconName_: Folder + drawText: 1 + useLayerName: 0 + treatDefaultLayerNameAsEmpty: 0 + useUniqueColorForDefaultLayerLabels: 1 + defaultLayerLabelColor: {r: 0.827451, g: 0.827451, b: 0.827451, a: 1} + overrideText: + textAnchor: 5 + decoration: 1 + decorationType: 2 + decorationColor: {r: 0.18823531, g: 0.18823531, b: 0.18823531, a: 1} + - name: Ether + expandedObjectsOnly: 0 + prefabInstancesOnly: 0 + useStringContainmentConditions: 1 + nameContains: + layerContains: + scene: + component: + attribute: + component_matching: Ether + drawBackgroundColor: 1 + color: {r: 1, g: 0, b: 0.93721867, a: 0.4392157} + style: 4 + icon: 1 + sizeAdjustment: 4.5 + paddingRightAdjustment: 0 + iconName_: StarPointer drawText: 0 useLayerName: 0 + treatDefaultLayerNameAsEmpty: 0 + useUniqueColorForDefaultLayerLabels: 1 + defaultLayerLabelColor: {r: 0.827451, g: 0.827451, b: 0.827451, a: 1} overrideText: textAnchor: 5 decoration: 0 - decorationType: 1 - decorationColor: {r: 1, g: 1, b: 1, a: 0.39215687} - - name: Ether + decorationType: 2 + decorationColor: {r: 1, g: 1, b: 1, a: 0.4392157} + - name: Ether - Expanded + expandedObjectsOnly: 1 prefabInstancesOnly: 0 useStringContainmentConditions: 1 nameContains: @@ -75,16 +138,20 @@ MonoBehaviour: style: 4 icon: 1 sizeAdjustment: 4.5 - paddingRightAdjustment: 5 + paddingRightAdjustment: 0 iconName_: StarPointer drawText: 0 useLayerName: 0 + treatDefaultLayerNameAsEmpty: 0 + useUniqueColorForDefaultLayerLabels: 1 + defaultLayerLabelColor: {r: 0.827451, g: 0.827451, b: 0.827451, a: 1} overrideText: textAnchor: 5 - decoration: 0 - decorationType: 1 - decorationColor: {r: 0.827, g: 0.294, b: 0.333, a: 1} + decoration: 1 + decorationType: 2 + decorationColor: {r: 1, g: 0, b: 0.93721867, a: 0.4392157} - name: Player + expandedObjectsOnly: 0 prefabInstancesOnly: 0 useStringContainmentConditions: 1 nameContains: @@ -93,7 +160,7 @@ MonoBehaviour: component: attribute: component_matching: - drawBackgroundColor: 0 + drawBackgroundColor: 1 color: {r: 0, g: 0, b: 1, a: 0.39215687} style: 4 icon: 0 @@ -102,12 +169,16 @@ MonoBehaviour: iconName_: SingleUser drawText: 0 useLayerName: 1 + treatDefaultLayerNameAsEmpty: 0 + useUniqueColorForDefaultLayerLabels: 1 + defaultLayerLabelColor: {r: 0.827451, g: 0.827451, b: 0.827451, a: 1} overrideText: textAnchor: 5 decoration: 1 decorationType: 0 decorationColor: {r: 0, g: 0, b: 1, a: 1} - name: Player - Primogenitor + expandedObjectsOnly: 0 prefabInstancesOnly: 0 useStringContainmentConditions: 1 nameContains: @@ -116,7 +187,7 @@ MonoBehaviour: component: attribute: component_matching: MoonMotionPlayer - drawBackgroundColor: 0 + drawBackgroundColor: 1 color: {r: 0, g: 0, b: 1, a: 0.39215687} style: 4 icon: 1 @@ -125,22 +196,80 @@ MonoBehaviour: iconName_: SingleUser drawText: 0 useLayerName: 1 + treatDefaultLayerNameAsEmpty: 0 + useUniqueColorForDefaultLayerLabels: 1 + defaultLayerLabelColor: {r: 0.827451, g: 0.827451, b: 0.827451, a: 1} overrideText: textAnchor: 5 decoration: 1 decorationType: 0 decorationColor: {r: 0, g: 0, b: 1, a: 1} - - name: Ally + - name: Neutrals + expandedObjectsOnly: 0 prefabInstancesOnly: 0 useStringContainmentConditions: 1 nameContains: - layerContains: Ally + layerContains: + scene: + component: + attribute: + component_matching: Neutrals + drawBackgroundColor: 1 + color: {r: 1, g: 1, b: 1, a: 0.39215687} + style: 4 + icon: 1 + sizeAdjustment: 2.5 + paddingRightAdjustment: 0 + iconName_: FolderBack + drawText: 0 + useLayerName: 0 + treatDefaultLayerNameAsEmpty: 0 + useUniqueColorForDefaultLayerLabels: 1 + defaultLayerLabelColor: {r: 0, g: 0, b: 0, a: 1} + overrideText: + textAnchor: 5 + decoration: 1 + decorationType: 0 + decorationColor: {r: 1, g: 1, b: 1, a: 1} + - name: Neutrals - Expanded + expandedObjectsOnly: 1 + prefabInstancesOnly: 0 + useStringContainmentConditions: 1 + nameContains: + layerContains: + scene: + component: + attribute: + component_matching: Neutrals + drawBackgroundColor: 0 + color: {r: 1, g: 1, b: 1, a: 0.39215687} + style: 4 + icon: 1 + sizeAdjustment: 2.5 + paddingRightAdjustment: 0 + iconName_: Folder + drawText: 0 + useLayerName: 0 + treatDefaultLayerNameAsEmpty: 0 + useUniqueColorForDefaultLayerLabels: 1 + defaultLayerLabelColor: {r: 0, g: 0, b: 0, a: 1} + overrideText: + textAnchor: 5 + decoration: 1 + decorationType: 2 + decorationColor: {r: 1, g: 1, b: 1, a: 1} + - name: Neutral + expandedObjectsOnly: 0 + prefabInstancesOnly: 0 + useStringContainmentConditions: 1 + nameContains: + layerContains: Neutral scene: component: attribute: component_matching: drawBackgroundColor: 0 - color: {r: 0, g: 1, b: 0, a: 0.39215687} + color: {r: 1, g: 1, b: 1, a: 0.39215687} style: 4 icon: 0 sizeAdjustment: 0 @@ -148,45 +277,107 @@ MonoBehaviour: iconName_: PacmanGhost drawText: 0 useLayerName: 1 + treatDefaultLayerNameAsEmpty: 0 + useUniqueColorForDefaultLayerLabels: 1 + defaultLayerLabelColor: {r: 0.827451, g: 0.827451, b: 0.827451, a: 1} overrideText: textAnchor: 5 decoration: 1 decorationType: 0 - decorationColor: {r: 0, g: 1, b: 0, a: 1} - - name: Ally - Unit Primogenitor + decorationColor: {r: 1, g: 1, b: 1, a: 1} + - name: Neutral - Unit Primogenitor + expandedObjectsOnly: 0 prefabInstancesOnly: 0 useStringContainmentConditions: 1 nameContains: - layerContains: Ally + layerContains: Neutral scene: component: attribute: component_matching: Unit drawBackgroundColor: 0 - color: {r: 0, g: 1, b: 0, a: 0.39215687} + color: {r: 1, g: 1, b: 1, a: 0.39215687} style: 4 icon: 1 sizeAdjustment: 0 paddingRightAdjustment: 0 iconName_: PacmanGhost drawText: 0 - useLayerName: 1 + useLayerName: 0 + treatDefaultLayerNameAsEmpty: 0 + useUniqueColorForDefaultLayerLabels: 1 + defaultLayerLabelColor: {r: 0.827451, g: 0.827451, b: 0.827451, a: 1} + overrideText: + textAnchor: 5 + decoration: 1 + decorationType: 0 + decorationColor: {r: 1, g: 1, b: 1, a: 1} + - name: Allies + expandedObjectsOnly: 0 + prefabInstancesOnly: 0 + useStringContainmentConditions: 1 + nameContains: + layerContains: + scene: + component: + attribute: + component_matching: Allies + drawBackgroundColor: 1 + color: {r: 0.21960784, g: 1, b: 0.21960784, a: 0.39215687} + style: 4 + icon: 1 + sizeAdjustment: 2.5 + paddingRightAdjustment: 0 + iconName_: FolderBack + drawText: 0 + useLayerName: 0 + treatDefaultLayerNameAsEmpty: 0 + useUniqueColorForDefaultLayerLabels: 1 + defaultLayerLabelColor: {r: 0, g: 0, b: 0, a: 1} overrideText: textAnchor: 5 decoration: 1 decorationType: 0 decorationColor: {r: 0, g: 1, b: 0, a: 1} - - name: Enemy + - name: Allies - Expanded + expandedObjectsOnly: 1 prefabInstancesOnly: 0 useStringContainmentConditions: 1 nameContains: - layerContains: Enemy + layerContains: + scene: + component: + attribute: + component_matching: Allies + drawBackgroundColor: 0 + color: {r: 0.16078432, g: 0.16078432, b: 0.16078432, a: 1} + style: 4 + icon: 1 + sizeAdjustment: 2.5 + paddingRightAdjustment: 0 + iconName_: Folder + drawText: 0 + useLayerName: 0 + treatDefaultLayerNameAsEmpty: 0 + useUniqueColorForDefaultLayerLabels: 1 + defaultLayerLabelColor: {r: 0, g: 0, b: 0, a: 1} + overrideText: + textAnchor: 5 + decoration: 1 + decorationType: 2 + decorationColor: {r: 0, g: 1, b: 0, a: 1} + - name: Ally + expandedObjectsOnly: 0 + prefabInstancesOnly: 0 + useStringContainmentConditions: 1 + nameContains: + layerContains: Ally scene: component: attribute: component_matching: drawBackgroundColor: 0 - color: {r: 1, g: 0, b: 0, a: 0.39215687} + color: {r: 0, g: 1, b: 0, a: 0.39215687} style: 4 icon: 0 sizeAdjustment: 0 @@ -194,45 +385,107 @@ MonoBehaviour: iconName_: PacmanGhost drawText: 0 useLayerName: 1 + treatDefaultLayerNameAsEmpty: 0 + useUniqueColorForDefaultLayerLabels: 1 + defaultLayerLabelColor: {r: 0.827451, g: 0.827451, b: 0.827451, a: 1} overrideText: textAnchor: 5 decoration: 1 decorationType: 0 - decorationColor: {r: 1, g: 0, b: 0, a: 1} - - name: Enemy - Unit Primogenitor + decorationColor: {r: 0, g: 1, b: 0, a: 1} + - name: Ally - Unit Primogenitor + expandedObjectsOnly: 0 prefabInstancesOnly: 0 useStringContainmentConditions: 1 nameContains: - layerContains: Enemy + layerContains: Ally scene: component: attribute: component_matching: Unit drawBackgroundColor: 0 - color: {r: 1, g: 0, b: 0, a: 0.39215687} + color: {r: 0, g: 1, b: 0, a: 0.39215687} style: 4 icon: 1 sizeAdjustment: 0 paddingRightAdjustment: 0 iconName_: PacmanGhost drawText: 0 + useLayerName: 1 + treatDefaultLayerNameAsEmpty: 0 + useUniqueColorForDefaultLayerLabels: 1 + defaultLayerLabelColor: {r: 0.827451, g: 0.827451, b: 0.827451, a: 1} + overrideText: + textAnchor: 5 + decoration: 1 + decorationType: 0 + decorationColor: {r: 0, g: 1, b: 0, a: 1} + - name: Enemies + expandedObjectsOnly: 0 + prefabInstancesOnly: 0 + useStringContainmentConditions: 1 + nameContains: + layerContains: + scene: + component: + attribute: + component_matching: Enemies + drawBackgroundColor: 1 + color: {r: 1, g: 0.21960784, b: 0.21960784, a: 0.39215687} + style: 4 + icon: 1 + sizeAdjustment: 2.5 + paddingRightAdjustment: 0 + iconName_: FolderBack + drawText: 0 useLayerName: 0 + treatDefaultLayerNameAsEmpty: 0 + useUniqueColorForDefaultLayerLabels: 1 + defaultLayerLabelColor: {r: 0, g: 0, b: 0, a: 1} overrideText: textAnchor: 5 decoration: 1 decorationType: 0 decorationColor: {r: 1, g: 0, b: 0, a: 1} - - name: Neutral + - name: Enemies - Expanded + expandedObjectsOnly: 1 prefabInstancesOnly: 0 useStringContainmentConditions: 1 nameContains: - layerContains: Neutral + layerContains: + scene: + component: + attribute: + component_matching: Enemies + drawBackgroundColor: 0 + color: {r: 0.16078432, g: 0.16078432, b: 0.16078432, a: 1} + style: 4 + icon: 1 + sizeAdjustment: 2.5 + paddingRightAdjustment: 0 + iconName_: Folder + drawText: 0 + useLayerName: 0 + treatDefaultLayerNameAsEmpty: 0 + useUniqueColorForDefaultLayerLabels: 1 + defaultLayerLabelColor: {r: 0, g: 0, b: 0, a: 1} + overrideText: + textAnchor: 5 + decoration: 1 + decorationType: 2 + decorationColor: {r: 1, g: 0, b: 0, a: 1} + - name: Enemy + expandedObjectsOnly: 0 + prefabInstancesOnly: 0 + useStringContainmentConditions: 1 + nameContains: + layerContains: Enemy scene: component: attribute: component_matching: drawBackgroundColor: 0 - color: {r: 1, g: 1, b: 1, a: 0.39215687} + color: {r: 1, g: 0, b: 0, a: 0.39215687} style: 4 icon: 0 sizeAdjustment: 0 @@ -240,22 +493,26 @@ MonoBehaviour: iconName_: PacmanGhost drawText: 0 useLayerName: 1 + treatDefaultLayerNameAsEmpty: 0 + useUniqueColorForDefaultLayerLabels: 1 + defaultLayerLabelColor: {r: 0.827451, g: 0.827451, b: 0.827451, a: 1} overrideText: textAnchor: 5 decoration: 1 decorationType: 0 - decorationColor: {r: 1, g: 1, b: 1, a: 1} - - name: Neutral - Unit Primogenitor + decorationColor: {r: 1, g: 0, b: 0, a: 1} + - name: Enemy - Unit Primogenitor + expandedObjectsOnly: 0 prefabInstancesOnly: 0 useStringContainmentConditions: 1 nameContains: - layerContains: Neutral + layerContains: Enemy scene: component: attribute: component_matching: Unit drawBackgroundColor: 0 - color: {r: 1, g: 1, b: 1, a: 0.39215687} + color: {r: 1, g: 0, b: 0, a: 0.39215687} style: 4 icon: 1 sizeAdjustment: 0 @@ -263,8 +520,11 @@ MonoBehaviour: iconName_: PacmanGhost drawText: 0 useLayerName: 0 + treatDefaultLayerNameAsEmpty: 0 + useUniqueColorForDefaultLayerLabels: 1 + defaultLayerLabelColor: {r: 0.827451, g: 0.827451, b: 0.827451, a: 1} overrideText: textAnchor: 5 decoration: 1 decorationType: 0 - decorationColor: {r: 1, g: 1, b: 1, a: 1} + decorationColor: {r: 1, g: 0, b: 0, a: 1} diff --git a/Assets/Plugins/Moon Motion Toolkit/Plugins/Odin Hierarchy/Odin Hierarchy/OdinHierarchyDrawer.cs b/Assets/Plugins/Moon Motion Toolkit/Plugins/Odin Hierarchy/Odin Hierarchy/OdinHierarchyDrawer.cs index 2c06112..52f95e0 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Plugins/Odin Hierarchy/Odin Hierarchy/OdinHierarchyDrawer.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Plugins/Odin Hierarchy/Odin Hierarchy/OdinHierarchyDrawer.cs @@ -49,17 +49,16 @@ public static void LoadSettings() } } - public static GUIStyle styleForUsingLayerName + public static GUIStyle styleForUsingLayerNameWith(Color color) { - get - { - GUIStyle guiStyle = new GUIStyle(GUI.skin.label); - guiStyle.alignment = TextAnchor.MiddleRight; - guiStyle.fontSize = 9; - guiStyle.normal.textColor = Color.gray; - return guiStyle; - } + GUIStyle guiStyle = new GUIStyle(GUI.skin.label); + guiStyle.alignment = TextAnchor.MiddleRight; + guiStyle.fontSize = 9; + guiStyle.normal.textColor = color; + return guiStyle; } + public static GUIStyle styleForUsingLayerName + => styleForUsingLayerNameWith(Default.layerHierarchyLabelColor); private static void Draw(int id, Rect rect) { @@ -108,7 +107,13 @@ private static void Draw(int id, Rect rect) } string textToDraw = (item.useLayerName ? - gameObject.layerName().withReplaced("Default", "") : + gameObject + .layerName() + .withReplaced + ( + Layer.defaultName, "", + item.treatDefaultLayerNameAsEmpty + ) : item.overrideText ).withPotentialTrailingSpace(); EditorGUI.LabelField @@ -118,7 +123,9 @@ string textToDraw textToDraw : "", (item.drawText && item.useLayerName) ? - styleForUsingLayerName : + !item.treatDefaultLayerNameAsEmpty && item.useUniqueColorForDefaultLayerLabels && textToDraw.matches(Layer.defaultName.withPotentialTrailingSpace()) ? + styleForUsingLayerNameWith(item.defaultLayerLabelColor) : + styleForUsingLayerName : style ); if (item.drawBackgroundColor) diff --git a/Assets/Plugins/Moon Motion Toolkit/Plugins/Odin Hierarchy/Odin Hierarchy/OdinHierarchySettings.cs b/Assets/Plugins/Moon Motion Toolkit/Plugins/Odin Hierarchy/Odin Hierarchy/OdinHierarchySettings.cs index 7ee4ebc..8cb8ac4 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Plugins/Odin Hierarchy/Odin Hierarchy/OdinHierarchySettings.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Plugins/Odin Hierarchy/Odin Hierarchy/OdinHierarchySettings.cs @@ -98,7 +98,7 @@ private void defaultPaddingRight() private static bool secret; public void ToggleSecret() => secret = !secret; - [ListDrawerSettings(ListElementLabelName = "name")] + [ListDrawerSettings(ListElementLabelName = "name", ShowPaging = false)] [LabelText("Styling Rules")] public List stylizations; @@ -110,6 +110,11 @@ public class Stylization [HideLabel] public string name = "New Styling Rule"; + [TabGroup("Context")] + [Title("Expansion Conditions")] + [PropertyOrder(-9)] + public bool expandedObjectsOnly = false; + [TabGroup("Context")] [Title("Prefab Conditions")] [PropertyOrder(-8)] @@ -264,6 +269,21 @@ public void ViewIcons() [Indent] [ShowIf("drawText")] public bool useLayerName = false; + private bool treatDefaultLayerNameAsEmpty_And_useUniqueColorForDefaultLayerLabels_ShowIf => drawText && useLayerName; + [TabGroup("Label")] + [Indent(2)] + [ShowIf("treatDefaultLayerNameAsEmpty_And_useUniqueColorForDefaultLayerLabels_ShowIf")] + public bool treatDefaultLayerNameAsEmpty = false; + [TabGroup("Label")] + [Indent(2)] + [ShowIf("treatDefaultLayerNameAsEmpty_And_useUniqueColorForDefaultLayerLabels_ShowIf")] + public bool useUniqueColorForDefaultLayerLabels = true; + private bool defaultLayerLabelColor_ShowIf => treatDefaultLayerNameAsEmpty_And_useUniqueColorForDefaultLayerLabels_ShowIf && useUniqueColorForDefaultLayerLabels; + [TabGroup("Label")] + [Indent(3)] + [ShowIf("defaultLayerLabelColor_ShowIf")] + [HideLabel] + public Color defaultLayerLabelColor = Colors.defaultLayerHierarchyLabelColor; [TabGroup("Label")] [ShowIf("@drawText && !useLayerName"), Indent] [HideLabel] @@ -284,6 +304,7 @@ public void ViewIcons() [HideLabel] public Decoration decorationType = Decoration.Right; [TabGroup("Decoration")] + [Space] [ColorPalette] [ShowIf("decoration"), Indent(1)] [HideLabel] @@ -295,6 +316,10 @@ public Stylization MatchSettingsWithGameObject(GameObject go) return stylizations.reversed()?.FirstOrDefault(s => { return + ( + !s.expandedObjectsOnly || + go.isExpandedInHierarchy_ViaReflection() + ) && ( !s.prefabInstancesOnly || go.isInstanceOfPrefabAsset() diff --git a/Assets/Plugins/Moon Motion Toolkit/Plugins/Steam Virtuality/Build/Editor/DefineSteamVirtuality.cs b/Assets/Plugins/Moon Motion Toolkit/Plugins/Steam Virtuality/Build/Editor/DefineSteamVirtuality.cs index 11af7fa..86581bb 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Plugins/Steam Virtuality/Build/Editor/DefineSteamVirtuality.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Plugins/Steam Virtuality/Build/Editor/DefineSteamVirtuality.cs @@ -3,11 +3,10 @@ using UnityEngine; using UnityEditor; -[InitializeOnLoad] +// #defines public static class DefineSteamVirtuality { - static DefineSteamVirtuality() - { - Build.ensureDefine("STEAM_VIRTUALITY"); - } + [InitializeOnLoadMethod] + private static void ensureDefine() + => Build.ensureDefine("STEAM_VIRTUALITY"); } \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Attributes/Auto/Validation/Expand If Selected/ExpandIfSelectedGameObjects.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Attributes/Auto/Validation/Expand If Selected/ExpandIfSelectedGameObjects.cs index 82e6874..4dc3681 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Attributes/Auto/Validation/Expand If Selected/ExpandIfSelectedGameObjects.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Attributes/Auto/Validation/Expand If Selected/ExpandIfSelectedGameObjects.cs @@ -20,8 +20,8 @@ static ExpandIfSelectedGameObjects() if (UnityIs.inEditorEditMode) { gameObjects - .only(gameObject => gameObject.isSelectedInHierarchy()) - .expandUniquesInHierarchy(); + .only(gameObject => gameObject.isSelected()) + .expandInHierarchy(); } }; } diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Attributes/Auto/Validation/Expand Self And Children If Selected/ExpandSelfAndChildrenIfSelectedGameObjects.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Attributes/Auto/Validation/Expand Self And Children If Selected/ExpandSelfAndChildrenIfSelectedGameObjects.cs index 113b2c7..fbd6b2b 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Attributes/Auto/Validation/Expand Self And Children If Selected/ExpandSelfAndChildrenIfSelectedGameObjects.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Attributes/Auto/Validation/Expand Self And Children If Selected/ExpandSelfAndChildrenIfSelectedGameObjects.cs @@ -20,7 +20,7 @@ static ExpandSelfAndChildrenIfSelectedGameObjects() if (UnityIs.inEditorEditMode) { gameObjects - .only(gameObject => gameObject.isSelectedInHierarchy()) + .only(gameObject => gameObject.isSelected()) .forEach(gameObject => gameObject.expandSelfAndChildrenInHierarchy()); } diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Baseline Layers/Abstract/AutoBehaviourLayerAutoBehaviour.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Baseline Layers/Abstract/AutoBehaviourLayerAutoBehaviour.cs index 28b8e89..a719cb6 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Baseline Layers/Abstract/AutoBehaviourLayerAutoBehaviour.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Baseline Layers/Abstract/AutoBehaviourLayerAutoBehaviour.cs @@ -93,10 +93,11 @@ public static ObjectT log(ObjectT object_, string prefix, string loggin => object_.logAs(prefix, contextGameObject, loggingSeparator); public static GameObject log(GameObject gameObject, string prefix, string loggingSeparator = Default.loggingSeparator) => gameObject.logAs(prefix, loggingSeparator); - public AutoBehaviourT log(string string_, string loggingSeparator = Default.loggingSeparator) - => selfAfter(()=> gameObject.log(string_, loggingSeparator)); + public AutoBehaviourT log(string string_, bool boolean = true, string loggingSeparator = Default.loggingSeparator) + => selfAfter(()=> + gameObject.log(string_, boolean, loggingSeparator)); public AutoBehaviourT pickLog(Func function, string loggingSeparator = Default.loggingSeparator) - => selfAfter(()=> gameObject.log(function(self), loggingSeparator)); + => selfAfter(()=> gameObject.log(function(self), true, loggingSeparator)); #endregion printing what is given #region printing listings diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Baseline Layers/Abstract/AutoBehaviourLayerBehaviour.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Baseline Layers/Abstract/AutoBehaviourLayerBehaviour.cs index db67259..5aa9731 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Baseline Layers/Abstract/AutoBehaviourLayerBehaviour.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Baseline Layers/Abstract/AutoBehaviourLayerBehaviour.cs @@ -13,7 +13,7 @@ public abstract class AutoBehaviourLayerBehaviour : #region enablement of this behaviour public bool isEnabled => self.isEnabled(); - public bool isNotEnabled => self.isNotEnabled(); + public bool isDisabled => self.isDisabled(); // method: set the enablement of this behaviour to the given boolean, then return this behaviour // public AutoBehaviourT setEnablementTo(bool enablement) diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Baseline Layers/Abstract/AutoBehaviourLayerCachedComponents.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Baseline Layers/Abstract/AutoBehaviourLayerCachedComponents.cs index a48ff66..0da14f1 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Baseline Layers/Abstract/AutoBehaviourLayerCachedComponents.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Baseline Layers/Abstract/AutoBehaviourLayerCachedComponents.cs @@ -14,11 +14,11 @@ public abstract class AutoBehaviourLayerCachedComponents : public ComponentT cache(bool addComponentIfNoneFound = false) where ComponentT : Component => gameObject.cache(addComponentIfNoneFound); - // method: cachingly return the corresponding rigidbody for this game object, optionally adding a rigidbody to this game object if none is found // + // method: cachingly return the corresponding rigidbody for this game object, optionally adding the specified type of component to this game object if none is found // public ComponentT cacheCorresponding(bool addComponentIfNoneFound = false) where ComponentT : Component => gameObject.cacheCorresponding(addComponentIfNoneFound); - // method: cachingly return the lodesponding rigidbody for this game object, optionally adding a rigidbody to this game object if none is found // + // method: cachingly return the lodesponding rigidbody for this game object, optionally adding the specified type of component to this game object if none is found // public ComponentT cacheLodesponding(bool addComponentIfNoneFound = false) where ComponentT : Component => gameObject.cacheLodesponding(addComponentIfNoneFound); diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Baseline Layers/Abstract/AutoBehaviourLayerGameObject.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Baseline Layers/Abstract/AutoBehaviourLayerGameObject.cs index f47d4e5..2e5eafd 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Baseline Layers/Abstract/AutoBehaviourLayerGameObject.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Baseline Layers/Abstract/AutoBehaviourLayerGameObject.cs @@ -93,27 +93,34 @@ public AutoBehaviourT makeUniversalAndTemporary() #endregion making objects universal andor temporary - #region determining hierarchy selection + #region determining selection #if UNITY_EDITOR - public bool isSelectedInHierarchy => gameObject.isSelectedInHierarchy(); - public bool isNotSelectedInHierarchy => gameObject.isNotSelectedInHierarchy(); + public bool isSelected => gameObject.isSelected(); + public bool isNotSelected => gameObject.isNotSelected(); #endif - #endregion determining hierarchy selection + #endregion determining selection - #region setting hierarchy objects selection + #region setting selection - public AutoBehaviourT selectInHierarchy_IfInEditor() - => selfAfter(()=> gameObject.selectInHierarchy_IfInEditor()); - #endregion setting hierarchy objects selection + public AutoBehaviourT select_IfInEditor() + => selfAfter(()=> gameObject.select_IfInEditor()); + #endregion setting selection - #region setting hierarchy objects selection then pinging the selection + #region pinging + + public AutoBehaviourT ping_IfInEditor() + => selfAfter(()=> gameObject.ping_IfInEditor()); + #endregion pinging + + + #region setting selection then pinging the selection - public AutoBehaviourT selectAndPingInHierarchy_IfInEditor() - => selfAfter(()=> gameObject.selectAndPingInHierarchy_IfInEditor()); - #endregion setting hierarchy objects selection then pinging the selection + public AutoBehaviourT selectAndPing_IfInEditor() + => selfAfter(()=> gameObject.selectAndPing_IfInEditor()); + #endregion setting selection then pinging the selection #region setting hierarchy expansion @@ -168,10 +175,14 @@ public bool nameContains(string string_) #region activity // method: return whether this behaviour's game object is active locally // - public bool activeLocally => gameObject.activeLocally(); + public bool isActiveLocally => gameObject.isActiveLocally(); + // method: return whether this behaviour's game object is inactive locally // + public bool isInactiveLocally => gameObject.isInactiveLocally(); // method: return whether this behaviour's game object is active globally // - public bool activeGlobally => gameObject.activeGlobally(); + public bool isActiveGlobally => gameObject.isActiveGlobally(); + // method: return whether this behaviour's game object is inactive globally // + public bool isInactiveGlobally => gameObject.isInactiveGlobally(); // method: set the activity of this behaviour's game object to the given boolean, then return this behaviour // public AutoBehaviourT setActivityTo(bool enablement) diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Baseline Layers/Abstract/AutoBehaviourLayerTransform.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Baseline Layers/Abstract/AutoBehaviourLayerTransform.cs index 861e3d2..cd4315b 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Baseline Layers/Abstract/AutoBehaviourLayerTransform.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Baseline Layers/Abstract/AutoBehaviourLayerTransform.cs @@ -200,22 +200,90 @@ public GameObject farthestOf(IEnumerable gameObjects) #endregion farthest of #region is within distance of - public bool isWithinDistanceOf(object position_PositionProvider, float thresholdDistance) - => position.isWithinDistanceOf(position_PositionProvider, thresholdDistance); - public bool isNotWithinDistanceOf(object position_PositionProvider, float thresholdDistance) - => position.isNotWithinDistanceOf(position_PositionProvider, thresholdDistance); - public bool isWithinDistanceOf(float thresholdDistance) where SingletonBehaviourT : SingletonBehaviour - => position.isWithinDistanceOf(thresholdDistance); - public bool isNotWithinDistanceOf(float thresholdDistance) where SingletonBehaviourT : SingletonBehaviour - => position.isNotWithinDistanceOf(thresholdDistance); - public bool isWithinDistanceOfCamera(float thresholdDistance) - => position.isWithinDistanceOfCamera(thresholdDistance); - public bool isNotWithinDistanceOfCamera(float thresholdDistance) - => position.isNotWithinDistanceOfCamera(thresholdDistance); - public bool isWithinDistanceOfPlayer(float thresholdDistance) - => position.isWithinDistanceOfPlayer(thresholdDistance); - public bool isNotWithinDistanceOfPlayer(float thresholdDistance) - => position.isNotWithinDistanceOfPlayer(thresholdDistance); + public bool isWithinDistanceOf + ( + object position_PositionProvider, + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + => position.isWithinDistanceOf + ( + position_PositionProvider, + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); + public bool isNotWithinDistanceOf + ( + object position_PositionProvider, + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + => position.isNotWithinDistanceOf + ( + position_PositionProvider, + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); + public bool isWithinDistanceOf + ( + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) where SingletonBehaviourT : SingletonBehaviour + => position.isWithinDistanceOf + ( + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); + public bool isNotWithinDistanceOf + ( + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) where SingletonBehaviourT : SingletonBehaviour + => position.isNotWithinDistanceOf + ( + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); + public bool isWithinDistanceOfCamera + ( + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + => position.isWithinDistanceOfCamera + ( + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); + public bool isNotWithinDistanceOfCamera + ( + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + => position.isNotWithinDistanceOfCamera + ( + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); + public bool isWithinDistanceOfPlayer + ( + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + => position.isWithinDistanceOfPlayer + ( + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); + public bool isNotWithinDistanceOfPlayer + ( + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + => position.isNotWithinDistanceOfPlayer + ( + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); #endregion is within distance of #region as position provider is within distance of nearest point on solid collider @@ -226,10 +294,32 @@ public bool positionallyIsNotWithinSolidDistanceOf(object solidCollider_SolidCol #endregion as position provider is within distance of nearest point on solid collider #region as position provider is within distance of nearest point on solid collider otherwise position - public bool positionallyIsWithinIdeallySolidDistanceOf(object colliderOtherwisePosition_ColliderOtherwisePositionProvider, float thresholdDistance) - => position.positionallyIsWithinIdeallySolidDistanceOf(colliderOtherwisePosition_ColliderOtherwisePositionProvider, thresholdDistance); - public bool positionallyIsNotWithinIdeallySolidDistanceOf(object colliderOtherwisePosition_ColliderOtherwisePositionProvider, float thresholdDistance) - => position.positionallyIsNotWithinIdeallySolidDistanceOf(colliderOtherwisePosition_ColliderOtherwisePositionProvider, thresholdDistance); + public bool positionallyIsWithinIdeallySolidDistanceOf + ( + object colliderOtherwisePosition_ColliderOtherwisePositionProvider, + float thresholdDistance, + bool treatOtherProviderNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + => position + .positionallyIsWithinIdeallySolidDistanceOf + ( + colliderOtherwisePosition_ColliderOtherwisePositionProvider, + thresholdDistance, + treatOtherProviderNullAsInfinitelyDistant + ); + public bool positionallyIsNotWithinIdeallySolidDistanceOf + ( + object colliderOtherwisePosition_ColliderOtherwisePositionProvider, + float thresholdDistance, + bool treatOtherProviderNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + => position + .positionallyIsNotWithinIdeallySolidDistanceOf + ( + colliderOtherwisePosition_ColliderOtherwisePositionProvider, + thresholdDistance, + treatOtherProviderNullAsInfinitelyDistant + ); #endregion as position provider is within distance of nearest point on solid collider otherwise position #region is more distant than @@ -270,4 +360,12 @@ public Vector3 positionAlongForwardOf(object transform_TransformProvider, float => position.positionAlongForwardOf(transform_TransformProvider, distance); #endregion determining another position relative to the provided position, along the forward direction of the provided transform #endregion position + + + #region rendering bounds + + public Vector3 renderingBoundsDimensions => transform.renderingBoundsDimensions(); + public float shortestRenderingBound => transform.shortestRenderingBound(); + public float longestRenderingBound => transform.longestRenderingBound(); + #endregion rendering bounds } \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Destruction/PlannedObjectDestruction.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Destruction/PlannedObjectDestruction.cs index aa4b5e7..0bdf7c6 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Destruction/PlannedObjectDestruction.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Destruction/PlannedObjectDestruction.cs @@ -24,8 +24,8 @@ public class PlannedObjectDestruction : AutoBehaviour // method: set the delay to the given delay // public PlannedObjectDestruction setDelayTo(float givenDelay) - => selfAfter(()=> - delay = givenDelay); + => selfAfter(()=> + delay = givenDelay); diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Singleton/Abstract/Baseline Layers/SingletonBehaviourLayerBehaviour.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Singleton/Abstract/Baseline Layers/SingletonBehaviourLayerBehaviour.cs index e3a5e0a..b41b4b3 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Singleton/Abstract/Baseline Layers/SingletonBehaviourLayerBehaviour.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Singleton/Abstract/Baseline Layers/SingletonBehaviourLayerBehaviour.cs @@ -13,7 +13,7 @@ public abstract class SingletonBehaviourLayerBehaviour : #region enablement of this behaviour public static new bool isEnabled => autoBehaviour.isEnabled; - public static new bool isNotEnabled => autoBehaviour.isNotEnabled; + public static new bool isDisabled => autoBehaviour.isDisabled; // method: set the enablement of this behaviour to the given boolean, then return this behaviour // public static new AutoBehaviour setEnablementTo(bool enablement) diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Singleton/Abstract/Baseline Layers/SingletonBehaviourLayerGameObject.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Singleton/Abstract/Baseline Layers/SingletonBehaviourLayerGameObject.cs index 8022ba4..8ac8ece 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Singleton/Abstract/Baseline Layers/SingletonBehaviourLayerGameObject.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Singleton/Abstract/Baseline Layers/SingletonBehaviourLayerGameObject.cs @@ -101,27 +101,34 @@ public abstract class SingletonBehaviourLayerGameObject : #endregion making objects universal andor temporary - #region determining hierarchy selection + #region determining selection #if UNITY_EDITOR - public static new bool isSelectedInHierarchy => autoBehaviour.isSelectedInHierarchy; - public static new bool isNotSelectedInHierarchy => autoBehaviour.isNotSelectedInHierarchy; + public static new bool isSelected => autoBehaviour.isSelected; + public static new bool isNotSelected => autoBehaviour.isNotSelected; #endif - #endregion determining hierarchy selection + #endregion determining selection - #region setting hierarchy objects selection + #region setting selection - public static new AutoBehaviour selectInHierarchy_IfInEditor() - => autoBehaviour.selectInHierarchy_IfInEditor(); - #endregion setting hierarchy objects selection + public static new AutoBehaviour select_IfInEditor() + => autoBehaviour.select_IfInEditor(); + #endregion setting selection - #region setting hierarchy objects selection then pinging the selection + #region pinging + + public static new AutoBehaviour ping_IfInEditor() + => autoBehaviour.ping_IfInEditor(); + #endregion pinging + + + #region setting selection then pinging the selection - public static new AutoBehaviour selectAndPingInHierarchy_IfInEditor() - => autoBehaviour.selectAndPingInHierarchy_IfInEditor(); - #endregion setting hierarchy objects selection then pinging the selection + public static new AutoBehaviour selectAndPing_IfInEditor() + => autoBehaviour.selectAndPing_IfInEditor(); + #endregion setting selection then pinging the selection #region setting hierarchy expansion @@ -174,10 +181,14 @@ public abstract class SingletonBehaviourLayerGameObject : #region activity // method: return whether this behaviour's game object is active locally // - public static new bool activeLocally => autoBehaviour.activeLocally; + public static new bool isActiveLocally => autoBehaviour.isActiveLocally; + // method: return whether this behaviour's game object is inactive locally // + public static new bool isInactiveLocally => autoBehaviour.isInactiveLocally; // method: return whether this behaviour's game object is active globally // - public static new bool activeGlobally => autoBehaviour.activeGlobally; + public static new bool isActiveGlobally => autoBehaviour.isActiveGlobally; + // method: return whether this behaviour's game object is inactive globally // + public static new bool isInactiveGlobally => autoBehaviour.isInactiveGlobally; // method: set the activity of this behaviour's game object to the given boolean, then return this behaviour // public static new AutoBehaviour setActivityTo(bool boolean) diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Singleton/Abstract/Baseline Layers/SingletonBehaviourLayerSingleton.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Singleton/Abstract/Baseline Layers/SingletonBehaviourLayerSingleton.cs index fdae9c6..6a3b661 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Singleton/Abstract/Baseline Layers/SingletonBehaviourLayerSingleton.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Singleton/Abstract/Baseline Layers/SingletonBehaviourLayerSingleton.cs @@ -7,6 +7,7 @@ // #auto #console // • provides this singleton behaviour with static access to its auto behaviour's auto behaviour layer // • provides this singleton behaviour with singleton features +[DisallowMultipleComponent] // prevents multiple of the same kind of singleton from being added to the same object public abstract class SingletonBehaviourLayerSingleton : AutoBehaviour where SingletonBehaviourT : SingletonBehaviour @@ -43,8 +44,8 @@ public abstract class SingletonBehaviourLayerSingleton : #region printing what is given - public static new AutoBehaviour log(string string_, string loggingSeparator = Default.loggingSeparator) - => autoBehaviour.log(string_, loggingSeparator); + public static new AutoBehaviour log(string string_, bool boolean = true, string loggingSeparator = Default.loggingSeparator) + => autoBehaviour.log(string_, boolean, loggingSeparator); public static AutoBehaviour pickLog(Func, string> function, string loggingSeparator = Default.loggingSeparator) => autoBehaviour.pickLog(function, loggingSeparator); #endregion printing what is given diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Singleton/Abstract/Baseline Layers/SingletonBehaviourLayerTransform.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Singleton/Abstract/Baseline Layers/SingletonBehaviourLayerTransform.cs index 815913a..a9a7537 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Singleton/Abstract/Baseline Layers/SingletonBehaviourLayerTransform.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Singleton/Abstract/Baseline Layers/SingletonBehaviourLayerTransform.cs @@ -196,22 +196,90 @@ public abstract class SingletonBehaviourLayerTransform : #endregion farthest of #region is within distance of - public static new bool isWithinDistanceOf(object position_PositionProvider, float thresholdDistance) - => autoBehaviour.isWithinDistanceOf(position_PositionProvider, thresholdDistance); - public static new bool isNotWithinDistanceOf(object position_PositionProvider, float thresholdDistance) - => autoBehaviour.isNotWithinDistanceOf(position_PositionProvider, thresholdDistance); - public static new bool isWithinDistanceOf(float thresholdDistance) where OtherSingletonBehaviourT : SingletonBehaviour - => autoBehaviour.isWithinDistanceOf(thresholdDistance); - public static new bool isNotWithinDistanceOf(float thresholdDistance) where OtherSingletonBehaviourT : SingletonBehaviour - => autoBehaviour.isNotWithinDistanceOf(thresholdDistance); - public static new bool isWithinDistanceOfCamera(float thresholdDistance) - => autoBehaviour.isWithinDistanceOfCamera(thresholdDistance); - public static new bool isNotWithinDistanceOfCamera(float thresholdDistance) - => autoBehaviour.isNotWithinDistanceOfCamera(thresholdDistance); - public static new bool isWithinDistanceOfPlayer(float thresholdDistance) - => autoBehaviour.isWithinDistanceOfPlayer(thresholdDistance); - public static new bool isNotWithinDistanceOfPlayer(float thresholdDistance) - => autoBehaviour.isNotWithinDistanceOfPlayer(thresholdDistance); + public static new bool isWithinDistanceOf + ( + object position_PositionProvider, + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + => autoBehaviour.isWithinDistanceOf + ( + position_PositionProvider, + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); + public static new bool isNotWithinDistanceOf + ( + object position_PositionProvider, + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + => autoBehaviour.isNotWithinDistanceOf + ( + position_PositionProvider, + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); + public static new bool isWithinDistanceOf + ( + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) where OtherSingletonBehaviourT : SingletonBehaviour + => autoBehaviour.isWithinDistanceOf + ( + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); + public static new bool isNotWithinDistanceOf + ( + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) where OtherSingletonBehaviourT : SingletonBehaviour + => autoBehaviour.isNotWithinDistanceOf + ( + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); + public static new bool isWithinDistanceOfCamera + ( + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + => autoBehaviour.isWithinDistanceOfCamera + ( + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); + public static new bool isNotWithinDistanceOfCamera + ( + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + => autoBehaviour.isNotWithinDistanceOfCamera + ( + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); + public static new bool isWithinDistanceOfPlayer + ( + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + => autoBehaviour.isWithinDistanceOfPlayer + ( + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); + public static new bool isNotWithinDistanceOfPlayer + ( + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + => autoBehaviour.isNotWithinDistanceOfPlayer + ( + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); #endregion is within distance of #region as position provider is within distance of nearest point on solid collider @@ -222,10 +290,32 @@ public abstract class SingletonBehaviourLayerTransform : #endregion as position provider is within distance of nearest point on solid collider #region as position provider is within distance of nearest point on solid collider otherwise position - public static new bool positionallyIsWithinIdeallySolidDistanceOf(object colliderOtherwisePosition_ColliderOtherwisePositionProvider, float thresholdDistance) - => autoBehaviour.positionallyIsWithinIdeallySolidDistanceOf(colliderOtherwisePosition_ColliderOtherwisePositionProvider, thresholdDistance); - public static new bool positionallyIsNotWithinIdeallySolidDistanceOf(object colliderOtherwisePosition_ColliderOtherwisePositionProvider, float thresholdDistance) - => autoBehaviour.positionallyIsNotWithinIdeallySolidDistanceOf(colliderOtherwisePosition_ColliderOtherwisePositionProvider, thresholdDistance); + public static new bool positionallyIsWithinIdeallySolidDistanceOf + ( + object colliderOtherwisePosition_ColliderOtherwisePositionProvider, + float thresholdDistance, + bool treatOtherProviderNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + => autoBehaviour + .positionallyIsWithinIdeallySolidDistanceOf + ( + colliderOtherwisePosition_ColliderOtherwisePositionProvider, + thresholdDistance, + treatOtherProviderNullAsInfinitelyDistant + ); + public static new bool positionallyIsNotWithinIdeallySolidDistanceOf + ( + object colliderOtherwisePosition_ColliderOtherwisePositionProvider, + float thresholdDistance, + bool treatOtherProviderNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + => autoBehaviour + .positionallyIsNotWithinIdeallySolidDistanceOf + ( + colliderOtherwisePosition_ColliderOtherwisePositionProvider, + thresholdDistance, + treatOtherProviderNullAsInfinitelyDistant + ); #endregion as position provider is within distance of nearest point on solid collider otherwise position #region is more distant than @@ -266,4 +356,12 @@ public abstract class SingletonBehaviourLayerTransform : => autoBehaviour.positionAlongForwardOf(transform_TransformProvider, distance); #endregion determining another position relative to the provided position, along the forward direction of the provided transform #endregion position + + + #region rendering bounds + + public static new Vector3 renderingBoundsDimensions => autoBehaviour.renderingBoundsDimensions; + public static new float shortestRenderingBound => autoBehaviour.shortestRenderingBound; + public static new float longestRenderingBound => autoBehaviour.longestRenderingBound; + #endregion rendering bounds } \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Singleton/Ether.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Singleton/Ether.cs index 7b6b443..7de9886 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Singleton/Ether.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Singleton/Ether.cs @@ -14,6 +14,7 @@ // · static execution such as for coroutines // #auto #updating #execution #coroutines [UseClassNameForObjectUponValidation] +[Container] public class Ether : SingletonBehaviour { // updating // diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Sole.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Sole.meta new file mode 100644 index 0000000..8f846ce --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Sole.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f125e84bfc404744ca5644e3c758398a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Sole/Abstract.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Sole/Abstract.meta new file mode 100644 index 0000000..ba88188 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Sole/Abstract.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ebec97a883d5eb34d896f506451dc81f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Sole/Abstract/SoleBehaviour.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Sole/Abstract/SoleBehaviour.cs new file mode 100644 index 0000000..53b21ed --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Sole/Abstract/SoleBehaviour.cs @@ -0,0 +1,20 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +#if ODIN_INSPECTOR +using Sirenix.OdinInspector; +#else +using NaughtyAttributes; +#endif + +// Sole Behaviour: +// #auto +// • inherits auto behaviour functionality +// • prevents multiple of the same kind of sole behaviour from being added to the same object +[DisallowMultipleComponent] +public abstract class SoleBehaviour : + AutoBehaviour + where SoleBehaviourT : SoleBehaviour +{ + +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Compilation/WhenPlayingTemporarilyDisableCompiling.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Sole/Abstract/SoleBehaviour.cs.meta similarity index 83% rename from Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Compilation/WhenPlayingTemporarilyDisableCompiling.cs.meta rename to Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Sole/Abstract/SoleBehaviour.cs.meta index 4a6d384..ea9c1e7 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Compilation/WhenPlayingTemporarilyDisableCompiling.cs.meta +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Sole/Abstract/SoleBehaviour.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 1a45177af81121444838d75845f02ac0 +guid: 40513212386919e4192cb13b4d4335d4 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Sole/StartsAsUniversal.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Sole/StartsAsUniversal.cs new file mode 100644 index 0000000..a330fba --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Sole/StartsAsUniversal.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +#if ODIN_INSPECTOR +using Sirenix.OdinInspector; +#else +using NaughtyAttributes; +#endif + +// Starts As Universal: +// • makes this object universal at the start +public class StartsAsUniversal : SoleBehaviour +{ + private void Start() + => makeUniversal(); +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/ClearConsole.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Sole/StartsAsUniversal.cs.meta similarity index 83% rename from Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/ClearConsole.cs.meta rename to Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Sole/StartsAsUniversal.cs.meta index 8e27198..2843488 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/ClearConsole.cs.meta +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Sole/StartsAsUniversal.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 9c6ff01a49068464aa35b55dd4fcf20e +guid: 8680ffd91ed2aba43a45a270a434b7d9 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Spawning/Spawner.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Spawning/Spawner.cs index e5109e6..b2480c1 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Spawning/Spawner.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Auto Behaviours/Spawning/Spawner.cs @@ -30,9 +30,7 @@ public class Spawner : EnabledsBehaviour private GameObject automatedParticularPositionParent => hasAnyLodal() ? - lodespondingSpawnPoint.isYull() ? - lodespondingSpawnPoint.gameObject : - logErrorAndReturnDefault("encountered unexpected null lodespondingSpawnPoint") : + lodespondingSpawnPoint.gameObject : gameObject; private GameObject automateParticularPositionParent() => particularPositionParent_ = automatedParticularPositionParent; diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Address.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Address.cs index aaeb57f..4374a6c 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Address.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Address.cs @@ -2,13 +2,13 @@ using System.Collections.Generic; using UnityEngine; -// Address: provides methods for handling addresses // +// Address: +// • provides methods for handling (file) addresses +// #assets public static class Address { - public const string divider = "\\"; - public static string forProjectAddress(string projectAddress) - => Project.path+projectAddress; - public static string forAssetPath(string assetAddress) - => Assets.path+assetAddress; + => Project.filepath.withPotentialRessingSuffix(projectAddress); + public static string forAssetAddress(string assetAddress) + => Assets.filepath.withPotentialRessingSuffix(assetAddress); } \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Any.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Any.cs index 594e7b3..fc01058 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Any.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Any.cs @@ -2,9 +2,22 @@ using System.Collections.Generic; using UnityEngine; -// Any: provides methods for determining content // +// Any: +// • provides methods for determining content of enumerables +// #enumerables #selection public static class Any { + #region in given enumerable + public static bool itemsIn(IEnumerable enumerable) => enumerable.hasAny(); + #endregion in given enumerable + + + #region in selection + #if UNITY_EDITOR + + public static bool selectedGameObjects => Selected.gameObject.isYull(); + #endif + #endregion in selection } \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Assets.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Assets.cs deleted file mode 100644 index 326f198..0000000 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Assets.cs +++ /dev/null @@ -1,45 +0,0 @@ -#if UNITY_EDITOR -using System.Collections; -using System.Collections.Generic; -using System.IO; -using UnityEditor; -using UnityEngine; - -// Assets: -// • provides properties methods for handling Assets -// #assets -public static class Assets -{ - public const string folderName = "Assets"; - public static string folderNameRessed = folderName.ress(); - public static string address = Project.path; - public static string path = address.ress(); - - public static void ensureFolderFor(string assetAddress) - { - if (!AssetDatabase.IsValidFolder(Assets.folderNameRessed+assetAddress)) - { - AssetDatabase.CreateFolder(Assets.folderName, assetAddress); - } - } - - // method: return the set of assets of the specified type corresponding to each of the given project paths // - public static HashSet atProjectPathsOfType(IEnumerable projectPaths) where AssetT : class - => projectPaths.pickUnique(projectPath => - Asset.atProjectPathOfType(projectPath)); - - // method: (via reflection:) return the set of assets of the specified type // - public static HashSet ofType_ViaReflection() where AssetT : class - => atProjectPathsOfType(Project.pathsForAssetsOfType_ViaReflection()); - // method: (via reflection:) return the list of assets of the specified type // - public static List manifestedOfType_ViaReflection() where AssetT : class - => ofType_ViaReflection().manifested(); - - // method: (via reflection:) return the set of assets not from the Moon Motion Toolkit that are of the specified type // - public static HashSet notFromMoonMotionToolkitOfType_ViaReflection() where AssetT : class - => atProjectPathsOfType(Project.pathsForNonMoonMotionToolkitAssetsOfType_ViaReflection()); - // method: (via reflection:) return the list of assets not from the Moon Motion Toolkit that are of the specified type // - public static List notFromMoonMotionToolkitManifestedOfType_ViaReflection() where AssetT : class - => notFromMoonMotionToolkitOfType_ViaReflection().manifested(); -} -#endif \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/AutoBehaviours.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/AutoBehaviours.cs index b50894d..08234e1 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/AutoBehaviours.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/AutoBehaviours.cs @@ -7,4 +7,12 @@ public static class AutoBehaviours { public static HashSet enabled_IfPlaying = New.setOf(); public static HashSet enabled_IfPlaying_Copy => enabled_IfPlaying.copy(); + + public static HashSet inHierarchy => Hierarchy.allYullAndUniqueI(); + public static HashSet inHierarchy_Copy => inHierarchy.copy(); + + #if UNITY_EDITOR + public static void validateAllInHierarchy() + => inHierarchy_Copy.validateI_IfInEditor_ViaReflection(); + #endif } \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Build.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Build.cs index 22be0cb..170d8b2 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Build.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Build.cs @@ -1,10 +1,14 @@ #if UNITY_EDITOR +using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEditor; using UnityEngine; -// Build: provides properties related to the build // +// Build: +// • provides properties related to the build +// #build #defines public static class Build { #region target @@ -32,11 +36,36 @@ public static HashSet setDefinesTo(IEnumerable defines) => defines.uniques().after(()=> PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, defines.joinBySemicolons())); + /* disabled in favor Odin Inspector's implementation (which has been added instead below) // method: ensure that the build defines include the given define string, then return whether it was included before // public static bool ensureDefine(string define) => defines.contains(define) ? true : - false.returnAnd(()=> setDefinesTo(defines.add(define))); + false.returnAnd(()=> setDefinesTo(defines.add(define)));*/ + public static void ensureDefine(string define) + { + var currentTarget = EditorUserBuildSettings.selectedBuildTargetGroup; + + if (currentTarget == BuildTargetGroup.Unknown) + { + return; + } + + var definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup(currentTarget).Trim(); + var defines = definesString.Split(';'); + + if (defines.Contains(define) == false) + { + if (definesString.EndsWith(";", StringComparison.InvariantCulture) == false) + { + definesString += ";"; + } + + definesString += define; + + PlayerSettings.SetScriptingDefineSymbolsForGroup(currentTarget, definesString); + } + } // method: ensure that the build defines don't include the given define string, then return whether it was included before // public static bool ensureNoDefine(string define) diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Colors.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Colors.cs index e508697..f45496e 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Colors.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Colors.cs @@ -4,7 +4,7 @@ // Colors: // • provides color constants and methods -// #constants +// #constants #hierarchy #unitology public static class Colors { #region constants @@ -50,7 +50,11 @@ public static class Colors public static Color mediumRed => new Color32(255, 51, 51, 255); #endregion provided here #endregion basic - + + #region hierarchy + public static Color defaultLayerHierarchyLabelColor => new Color32(123, 123, 123, 128); // the color to use for labels in the hierarchy for the layer 'Default' + #endregion hierarchy + #region Unitology #if UNITOLOGY public static readonly Color healthbarLow = red; diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Default.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Default.cs index 641258b..24aa174 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Default.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Default.cs @@ -20,12 +20,18 @@ public static class Default public const bool errorSilencing = false; public const bool editorExecutionIfPlaymodeHasChanged = true; public const bool beginningNowVersusAtNextCycle = true; + public const bool treatingOfNullAsARelevantValue = false; + #region colors + public static readonly Color settingsColor = Colors.gray; + public static readonly Color previousnessColor = Colors.orange; + #endregion colors #endregion miscellaneous #region hierarchy #if UNITY_EDITOR public const float hierarchyIconSize = 14f; public const float hierarchyIconPaddingRight = 6f; + public static Color layerHierarchyLabelColor => Colors.gray; #endif #endregion hierarchy @@ -105,7 +111,7 @@ public static class Default public static readonly Vector3 raycastingDirection = Direction.forward; public const BasicDirection raycastingBasicDirection = BasicDirection.forward; public const float raycastingDistance = 15f; - public const float outlineRaycastingDistance = Infinity.asAFloat; + public const float targetingRaycastingDistance = Infinity.asAFloat; public const RaycastQuery raycastQuery = RaycastQuery.unlimitedHitsAndAllPositionalColliders; public const QueryTriggerInteraction raycastingTriggerColliderQuery = QueryTriggerInteraction.Collide; public const Distinctivity raycastingDistinctivity = Distinctivity.relative; @@ -141,8 +147,9 @@ public static class Default #region Controller public const Controller.Handedness controllerHandedness = Controller.Handedness.infinite; public const ushort vibrationIntensity = 500; + public const ushort targetingVibrationIntensity = 400; #endregion Controller -#endif + #endif #endregion Moon Motion Toolkit #region fense diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/EditorAssembly.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/EditorAssembly.cs new file mode 100644 index 0000000..76149e9 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/EditorAssembly.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using UnityEditor; +using UnityEngine; + +// #reflection +public static class EditorAssembly +{ + private static readonly Assembly assembly + = typeof(Editor).assembly(); + + public static Type classNamed(string className) + => assembly.classNamed(className); +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/ClearConsoleAndDeselect.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/EditorAssembly.cs.meta similarity index 83% rename from Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/ClearConsoleAndDeselect.cs.meta rename to Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/EditorAssembly.cs.meta index cec727d..07d4912 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/ClearConsoleAndDeselect.cs.meta +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/EditorAssembly.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 66fce5d8bbccd634684b998c41828449 +guid: 2b3419b1057bca54f82ccba0dceaa379 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Execute.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Execute.cs index 2be1455..45f8e85 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Execute.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Execute.cs @@ -33,11 +33,11 @@ public static Coroutine atNextCheck(Action action, params object[] parameters) #region planning to execute functions\actions at next check in editor - // method: plan to execute the given action at the next editor check // + // method: (if in the editor:) plan to execute the given action at the next editor check // public static void atNextCheck_IfInEditor(Action action, bool executeIfPlaymodeHasChanged = Default.editorExecutionIfPlaymodeHasChanged, bool silencePotentialNullException = Default.errorSilencing) { #if UNITY_EDITOR - if (UnityIs.inEditor && !BuildPipeline.isBuildingPlayer) + if (!BuildPipeline.isBuildingPlayer) { bool inEditorEditModeUponPlanning = UnityIs.inEditorEditMode; @@ -64,6 +64,18 @@ public static void atNextCheck_IfInEditor(Action action, bool executeIfPlaymodeH #endregion planning to execute functions\actions at next check in editor + #region planning to execute functions\actions at next playmode change if in editor + + // method: (if in the editor:) plan to execute the given action at the next playmode change // + public static void atNextPlaymodeChange_IfInEditor(Action action) + { + #if UNITY_EDITOR + EditorApplication.playModeStateChanged += action; + #endif + } + #endregion planning to execute functions\actions at next check in editor + + #region planning to execute functions\actions now and at every check // methods: (have the ether) plan to execute the given function with the given parameters at every coroutine check, then return the new coroutine that will do so // diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Path.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Filepath.cs similarity index 64% rename from Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Path.cs rename to Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Filepath.cs index 7a8f24e..a3a8c4a 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Path.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Filepath.cs @@ -2,13 +2,15 @@ using System.Collections.Generic; using UnityEngine; -// Filepath: provides methods for handling filepaths // +// Filepath: +// • provides methods for handling filepaths +// #assets public static class Filepath { public static string forProjectPath(string projectPath) - => Project.path+projectPath; + => Project.filepath.withPotentialRessingSuffix(projectPath); public static string forAssetPath(string assetPath) - => Assets.path+assetPath; + => Assets.filepath.withPotentialRessingSuffix(assetPath); public static string forAsset(string assetTitle, string assetAddress) => forAssetPath(Asset.pathFor(assetTitle, assetAddress)); } \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Path.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Filepath.cs.meta similarity index 100% rename from Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Path.cs.meta rename to Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Filepath.cs.meta diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Hierarchy.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Hierarchy.cs index 9adf98d..14aaf70 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Hierarchy.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Hierarchy.cs @@ -12,6 +12,16 @@ public static class Hierarchy { #region state + + public static Type windowType_ViaReflection => EditorAssembly.classNamed("UnityEditor.SceneHierarchyWindow"); + + public static UnityEngine.Object window_ViaReflection + => Resources.FindObjectsOfTypeAll(windowType_ViaReflection).first(); + + public static object treeViewControllerFor_ViaReflection(UnityEngine.Object hierarchyWindow) + => hierarchyWindow.valueOf(windowType_ViaReflection.nonpublicInstanceFieldNamed("m_TreeView")); + public static object windowTreeViewController_ViaReflection + => treeViewControllerFor_ViaReflection(window_ViaReflection); public static IEnumerable accessScenes => Access.forCount(SceneManager.sceneCount, sceneIndex => @@ -25,16 +35,6 @@ public static IEnumerable accessScenes public static int primogenitorCount => accessPrimogenitorObjects.count(); public static int lastPrimogenitorIndex => primogenitorCount - 1; - - #if UNITY_EDITOR - // whether the hierarchy has any selected game objects // - public static bool hasAnySelectedGameObjects => selectedGameObject.isYull(); - public static bool hasNoSelectedGameObjects => !hasAnySelectedGameObjects; - // the (first) currently selected game object // - public static GameObject selectedGameObject => Selection.activeGameObject; - // the set of currently selected game objects // - public static HashSet selectedGameObjects => Selection.gameObjects.uniques(); - #endif #endregion state @@ -45,6 +45,41 @@ public static IEnumerable accessScenes #region accessing components in the hierarchy + // method: return the set of all yull and unique behaviours of the specified type that are currently in the hierarchy // + public static HashSet allYullAndUnique() where BehaviourT : Behaviour + => Resources.FindObjectsOfTypeAll() + .onlyYull() + .only(behaviour => behaviour.gameObject.isNotPartOfPrefabAsset()) + .uniques(); + + // method: return the first yull and unique behaviour of the specified type that is currently in the hierarchy // + public static BehaviourT firstYullAndUnique() where BehaviourT : Behaviour + => allYullAndUnique().firstOtherwiseDefault(); + + /* (via reflection) */ + // method: return the set of all of the specified interface implemented on mono behaviours that are yull and unique instances currently in the hierarchy // + public static HashSet allYullAndUniqueI() where MonoBehaviourI : class + { + if (Interfaces.doesNotInclude()) + { + return default(HashSet).returnWithError(typeof(MonoBehaviourI).simpleClassName_ViaReflection()+" is not an interface"); + } + + return allYullAndUnique().only().uniques(); + } + + /* (via reflection) */ + // method: return the first of the specified interface implemented on mono behaviours that are yull and unique instances currently in the hierarchy // + public static MonoBehaviourI firstYullAndUniqueI() where MonoBehaviourI : class + { + if (Interfaces.doesNotInclude()) + { + return default(MonoBehaviourI).returnWithError(typeof(MonoBehaviourI).simpleClassName_ViaReflection()+" is not an interface"); + } + + return allYullAndUniqueI().firstOtherwiseDefault(); + } + // method: return the set of all yull, enabled, and unique behaviours of the specified type that are currently in the hierarchy // public static HashSet allYullAndEnabledAndUnique() where BehaviourT : Behaviour => Resources.FindObjectsOfTypeAll() @@ -57,10 +92,11 @@ public static HashSet allYullAndEnabledAndUnique() where public static BehaviourT firstYullAndEnabledAndUnique() where BehaviourT : Behaviour => allYullAndEnabledAndUnique().firstOtherwiseDefault(); - // method: (via reflection if error:) return the set of all of the specified interface implemented on mono behaviours that are yull, enabled, and unique instances currently in the hierarchy // + /* (via reflection) */ + // method: return the set of all of the specified interface implemented on mono behaviours that are yull, enabled, and unique instances currently in the hierarchy // public static HashSet allYullAndEnabledAndUniqueI() where MonoBehaviourI : class { - if (!typeof(MonoBehaviourI).IsInterface) + if (Interfaces.doesNotInclude()) { return default(HashSet).returnWithError(typeof(MonoBehaviourI).simpleClassName_ViaReflection()+" is not an interface"); } @@ -68,10 +104,11 @@ public static HashSet allYullAndEnabledAndUniqueI().only().uniques(); } - // method: (via reflection if error:) return the first of the specified interface implemented on mono behaviours that are yull, enabled, and unique instances currently in the hierarchy // + /* (via reflection) */ + // method: return the first of the specified interface implemented on mono behaviours that are yull, enabled, and unique instances currently in the hierarchy // public static MonoBehaviourI firstYullAndEnabledAndUniqueI() where MonoBehaviourI : class { - if (!typeof(MonoBehaviourI).IsInterface) + if (Interfaces.doesNotInclude()) { return default(MonoBehaviourI).returnWithError(typeof(MonoBehaviourI).simpleClassName_ViaReflection()+" is not an interface"); } @@ -109,51 +146,10 @@ public static TResult createTemporaryObjectAndDestroyAfterPicking(Func< #endregion creating universal andor temporary objects - #region setting hierarchy objects selection - #if UNITY_EDITOR - - // method: deselect in the hierarchy all current hierarchy selection objects // - public static void deselect() - => Selection.objects = New.arrayOf(); -#endif - #endregion setting hierarchy objects selection - - - #region pinging a given object - - // method: (if in the editor:) ping this given game object in the hierarchy (if it's yull), then return this given game object // - public static GameObject ping_IfInEditor(GameObject gameObject) - => gameObject.after(gameObject_ => - { - #if UNITY_EDITOR - EditorGUIUtility.PingObject(gameObject_); - #endif - }, gameObject.isYull() && UnityIs.inEditor); - // method: (if in the editor:) ping this given component's game object in the hierarchy (if this given component and its game object are both yull), then return this given component // - public static ComponentT ping_IfInEditor(this ComponentT component) where ComponentT : Component - => component.after(()=> - ping_IfInEditor(component.gameObject), - component.isYull() && component.gameObject.isYull()); - #endregion pinging a given object - - - #region pinging hierarchy selection objects - - #if UNITY_EDITOR - // method: ping the game object currently selected in the hierarchy, then return it // - public static GameObject pingSelectedGameObject() - => ping_IfInEditor(selectedGameObject); - // method: ping the set of game objects currently selected in the hierarchy, then return the set // - public static HashSet pingSelectedGameObjects() - => selectedGameObjects.pingUniquesInHierarchy_IfInEditor(); - - // method: ping the game object currently selected in the hierarchy, then return it after having it log the given string // - public static GameObject pingSelectedGameObjectLogging(string string_) - => pingSelectedGameObject().log(string_); - // method: ping the set of game objects currently selected in the hierarchy, then return the set after logging the given string as each game object // - public static HashSet pingSelectedGameObjectsEachLogging(string string_) - => pingSelectedGameObjects().uniquesAfterAsEachObjectLogging(string_); - #endif - #endregion pinging hierarchy selection objects + #region setting hierarchy expansion + + public static void collapseAllObjects() + => accessPrimogenitorObjects.collapseLodalsInHierarchy(); + #endregion setting hierarchy expansion #endregion methods } \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Instance.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Instance.cs new file mode 100644 index 0000000..f1265e2 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Instance.cs @@ -0,0 +1,15 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +// Instance: +// • provides methods for accessing instance idees +// #instancing #unityobject #assets +public static class Instance +{ + #if UNITY_EDITOR + // method: return the instance idee of the asset with the given asset path // + public static int ideeForAssetPath(string assetPath) + => Asset.atAssetPathOfType(assetPath).instanceIdee(); + #endif +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/CreateNewObject.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Instance.cs.meta similarity index 83% rename from Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/CreateNewObject.cs.meta rename to Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Instance.cs.meta index d8dcb2e..d45de19 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/CreateNewObject.cs.meta +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Instance.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 7a6ecdcee0cee1943aae17cd5fe7130b +guid: 6fb212163bf610d4f96197d5aefb3831 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Interfaces.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Interfaces.cs new file mode 100644 index 0000000..72eaff5 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Interfaces.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +// Interfaces: +// • provides methods for handling interfaces +// #types #reflection +public static class Interfaces +{ + #region interface determination + + // method: return whether the specified type is an interface // + public static bool includes() where I : class + => typeof(I).isAnInterface(); + public static bool doesNotInclude() where I : class + => !includes(); + #endregion interface determination +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Interfaces.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Interfaces.cs.meta new file mode 100644 index 0000000..96efd90 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Interfaces.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 02e7d3707ba41a74696b5024be68635c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/New.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/New.cs index 63e2f9a..65cb378 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/New.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/New.cs @@ -2,11 +2,15 @@ using System.Collections; using System.Collections.Generic; using System.Linq; +using System.Reflection; +#if UNITY_EDITOR +using UnityEditor; +#endif using UnityEngine; // New: // • provides members for that allow for fluent creation of certain objects -// #new #enumerables +// #new #enumerables #reflection public static class New { #region miscellaneous @@ -26,6 +30,22 @@ public static Vector3 floatZeroesVectorWithY(float y) => FloatsVector.zeroes.withY(y); public static Vector3 floatZeroesVectorWithZ(float z) => FloatsVector.zeroes.withZ(z); + + public static GameObject gameObject => "New Object".createAsObject(); + + #if UNITY_EDITOR + // reference: https://forum.unity.com/threads/tutorial-how-to-to-show-specific-folder-content-in-the-project-window-via-editor-scripting.508247/ // + public static EditorWindow assetsWindow_ViaReflection + { + get + { + Type assetsWindowType = Assets.windowType_ViaReflection; + return EditorWindow.GetWindow(assetsWindowType) + .show() + .invoke(assetsWindowType.publicInstanceMethodNamed("Init")); + } + } + #endif #endregion miscellaneous diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/No.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/No.cs new file mode 100644 index 0000000..2eaee05 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/No.cs @@ -0,0 +1,23 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +// No: +// • provides methods for determining content of enumerables +// #enumerables #selection +public static class No +{ + #region in given enumerable + + public static bool itemsIn(IEnumerable enumerable) + => !Any.itemsIn(enumerable); + #endregion in given enumerable + + + #region in selection + #if UNITY_EDITOR + + public static bool selectedGameObjects => !Any.selectedGameObjects; + #endif + #endregion in selection +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/No.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/No.cs.meta new file mode 100644 index 0000000..a0159d5 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/No.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 11d0bf8f6c58b2840945ab50e901de7a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Project.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Project.cs index c05a34c..92799be 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Project.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Project.cs @@ -11,10 +11,11 @@ public static class Project { #region constants - + #if UNITY_EDITOR - public static string path => Directory.GetCurrentDirectory(); + public static string filepath => Directory.GetCurrentDirectory(); + public static string filepathRess => filepath.ress(); #endif #region name @@ -69,7 +70,7 @@ public static HashSet pathsForPrefabAssetsFilteredBy(string filterString // method: return the project path for the asset with the given title at the given asset address // public static string pathFor(string assetPath) - => Assets.folderNameRessed+assetPath; + => Assets.folderName.withPotentialRessingSuffix(assetPath); // method: return the project path for the asset with the given title at the given asset address // public static string pathFor(string assetTitle, string assetAddress) diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Ress.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Ress.cs new file mode 100644 index 0000000..b531d75 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Ress.cs @@ -0,0 +1,11 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +// Ress: +// • provides the ress string constant +// #ressing +public static class Ress +{ + public const string string_ = "\\"; +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Ress.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Ress.cs.meta new file mode 100644 index 0000000..4a98a30 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Ress.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3c7cadb7cad30b14c86d56c90d2060ea +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Scenes.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Scenes.cs new file mode 100644 index 0000000..c0b8167 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Scenes.cs @@ -0,0 +1,10 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +// Scenes: +// • provides methods for handling scenes +public static class Scenes +{ + +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Scenes.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Scenes.cs.meta new file mode 100644 index 0000000..cc20cf1 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Scenes.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 04e2d7e2b1a43c34ab5325fae0e8d742 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/TreeViews.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/TreeViews.cs new file mode 100644 index 0000000..4c8a8d8 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/TreeViews.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using UnityEditor.IMGUI.Controls; +using UnityEngine; + +// #reflection +public static class TreeViews +{ + public static readonly Type controllerType_ViaReflection + = EditorAssembly.classNamed("UnityEditor.IMGUI.Controls.TreeViewController"); + public static readonly Type dataSourceType_ViaReflection + = EditorAssembly.classNamed("UnityEditor.IMGUI.Controls.TreeViewDataSource"); + public static readonly Type gameObjectDataSourceType_ViaReflection + = EditorAssembly.classNamed("UnityEditor.GameObjectTreeViewDataSource"); + + public static object itemFor_ViaReflection(int instanceIdee, object treeViewController) + => treeViewController.invokeGetResult + ( + controllerType_ViaReflection.nonpublicInstanceMethodNamed("GetItemAndRowIndex"), + instanceIdee, null + ); + + public static readonly PropertyInfo property_data + = controllerType_ViaReflection.publicInstancePropertyNamed("data"); + public static object dataOf_ViaReflection(object treeViewController) + => treeViewController.valueOf(property_data); + public static bool expansionOf_ViaReflection(int instanceIdee, object treeViewController) + => dataOf_ViaReflection(treeViewController).invokeGetResult + ( + dataSourceType_ViaReflection.methodNamed + ( + "IsExpanded", + typeof(int) + ), + instanceIdee + ).castTo(); +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/TreeViews.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/TreeViews.cs.meta new file mode 100644 index 0000000..131be3b --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/TreeViews.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 989f70f2b75e6d948adbf99d7bd5ee84 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/AddressExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/AddressExtensions.cs deleted file mode 100644 index af0aa74..0000000 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/AddressExtensions.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -// Address Extensions: -// • provides extension methods for handling addresses -public static class AddressExtensions -{ - public static string ress(this string string_) - => string_+Address.divider; -} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/BoundsExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/BoundsExtensions.cs new file mode 100644 index 0000000..bdb1170 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/BoundsExtensions.cs @@ -0,0 +1,168 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +// Bounds Extensions: +// • provides extension methods for handling bounds +// #bounds +public static class BoundsExtensions +{ + #region accessing measurements + + // method: return the dimensions of this given bounds // + public static Vector3 dimensions(this Bounds bounds) + => bounds.size; + + // method: return the reaches of this given bounds // + public static Vector3 reaches(this Bounds bounds) + => bounds.extents; + #endregion accessing measurements + + + #region distinctivity conversion + + /* based on the 'WorldToLocal' method of some particular transforms plugin; the 'mystery' parameter is not yet understood */ + public static Bounds asGlobalBoundsToLocalBoundsRelativeTo(this Bounds globalBounds, object transform_TransformProvider, Vector3 mystery) + { + if (transform_TransformProvider.isNull()) + { + return "BoundsExtensions.asGlobalBoundsToLocalBoundsRelativeTo given null transform provider".printAsErrorAndReturnDefault(); + } + + return new Bounds + ( + transform_TransformProvider.provideTransform() + .worldToLocalMatrix.MultiplyPoint3x4(globalBounds.center), + mystery + ); + } + #endregion distinctivity conversion + + + #region accessing shared mesh bounds dimensions of renderers + + public static Vector3 sharedMeshBoundsDimensions(this MeshRenderer meshRenderer) + { + if (meshRenderer.isNull()) + { + return "BoundsExtensions.sharedMeshBoundsDimensions given null mesh renderer".printAsErrorAndReturnDefault(); + } + + if (meshRenderer.hasNo()) + { + return "BoundsExtensions.sharedMeshBoundsDimensions given mesh renderer with no local mesh filter".printAsErrorAndReturnDefault(); + } + + MeshFilter meshFilter = meshRenderer.first(); + + if (meshFilter.sharedMesh.isNull()) + { + return "BoundsExtensions.sharedMeshBoundsDimensions given mesh renderer with local mesh filter with null shared mesh".printAsErrorAndReturnDefault(); + } + + return meshFilter.sharedMesh.bounds.dimensions(); + } + + public static Vector3 sharedMeshBoundsDimensions(this SkinnedMeshRenderer skinnedMeshRenderer) + { + if (skinnedMeshRenderer == null) + { + return "BoundsExtensions.sharedMeshBoundsDimensions given null skinned mesh renderer".printAsErrorAndReturnDefault(); + } + + if (skinnedMeshRenderer.sharedMesh == null) + { + return "BoundsExtensions.sharedMeshBoundsDimensions given skinned mesh renderer with null shared mesh".printAsErrorAndReturnDefault(); + } + + return skinnedMeshRenderer.sharedMesh.bounds.dimensions(); + } + + public static Vector3 sharedMeshBoundsDimensions(this Renderer renderer) + { + if (renderer.isNull()) + { + return "BoundsExtensions.sharedMeshBoundsDimensions given null renderer".printAsErrorAndReturnDefault(); + } + if (renderer is MeshRenderer) + { + return (renderer as MeshRenderer).sharedMeshBoundsDimensions(); + } + if (renderer is SkinnedMeshRenderer) + { + return (renderer as SkinnedMeshRenderer).sharedMeshBoundsDimensions(); + } + else + { + return default(Vector3).returnWithError("BoundsExtensions.sharedMeshBoundsDimensions given unrecognized renderer of type "+renderer.derivedType_ViaReflection()); + } + } + #endregion accessing shared mesh bounds dimensions of renderers + + + #region rendering bounds + + /* (via reflection if error) */ + public static Vector3 renderingBoundsDimensions(this object transform_TransformProvider) + { + if (transform_TransformProvider.isNull()) + { + return "BoundsExtensions.shortestRenderingBound given null transform provider".printAsErrorAndReturnDefault(); + } + + Transform transform = transform_TransformProvider.provideTransform(); + + Renderer[] lodalRenderers = transform.lodal(); + + if (lodalRenderers.isEmpty()) + { + return FloatsVector.zeroes; + } + + bool boundsEncapsulationIterationYet = false; + + Bounds? bounds = null; // nullable form to avoid an ignorant compiler error + + foreach (Renderer lodalRenderer in lodalRenderers) + { + if + ( + lodalRenderer.isNull() || + lodalRenderer.isDisabled() || + lodalRenderer.isInactiveGlobally() + ) + { + continue; + } + + Vector3 lodalRendererSharedMeshBoundsDimensions = lodalRenderer.sharedMeshBoundsDimensions(); + + if (lodalRendererSharedMeshBoundsDimensions.isZeroes()) + { + continue; + } + + Bounds lodalRendererBounds = lodalRenderer.bounds; + + if (!boundsEncapsulationIterationYet) + { + bounds = new Bounds(lodalRendererBounds.center, lodalRendererBounds.size); + + boundsEncapsulationIterationYet = true; + } + else + { + bounds.GetValueOrDefault().Encapsulate(lodalRendererBounds); + } + } + + return bounds.GetValueOrDefault().dimensions(); + } + + public static float shortestRenderingBound(this object transform_TransformProvider) + => transform_TransformProvider.renderingBoundsDimensions().min(); + + public static float longestRenderingBound(this object transform_TransformProvider) + => transform_TransformProvider.renderingBoundsDimensions().max(); + #endregion rendering bounds +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/BoundsExtensions.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/BoundsExtensions.cs.meta new file mode 100644 index 0000000..9c17d7b --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/BoundsExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 471d87aa29d0bce4a9d733c95f9b5bb3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/ComponentCachingExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/ComponentCachingExtensions.cs index cf259d5..8a76d31 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/ComponentCachingExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/ComponentCachingExtensions.cs @@ -8,10 +8,8 @@ // #component #correspondence #lodespondence public static class ComponentCachingExtensions { - // variables // - + #region variables - // tracking // // a dictionary of cached component dictionaries (dictionaries of those components on a particular game object which are cached here, keyed by their type) for game object keys // public static Dictionary> cachedComponentDictionaries @@ -24,11 +22,12 @@ public static Dictionary> cachedComponen // a dictionary of cached lodesponding component dictionaries (dictionaries of those components lodesponding to a particular game object which are cached here, keyed by their type) for game object keys // public static Dictionary> cachedLodespondingComponentDictionaries = New.dictionaryOf>(); + #endregion variables - // methods // + #region methods // method: cachingly return the component of the specified type in the cached components for this given game object, optionally adding the specified type of component to this given game object if none is found // @@ -38,7 +37,7 @@ public static ComponentT cache(this GameObject gameObject, bool addC gameObject, ()=> new Dictionary() ) - .cache + .cacheYull ( typeof(ComponentT), ()=> gameObject.first().ifYullOtherwise(()=> @@ -53,7 +52,7 @@ public static ComponentT cacheCorresponding(this GameObject gameObje gameObject, ()=> new Dictionary() ) - .cache + .cacheYull ( typeof(ComponentT), ()=> gameObject.corresponding().ifYullOtherwise(()=> @@ -68,7 +67,7 @@ public static ComponentT cacheLodesponding(this GameObject gameObjec gameObject, ()=> new Dictionary() ) - .cache + .cacheYull ( typeof(ComponentT), ()=> gameObject.lodesponding().ifYullOtherwise(()=> @@ -89,4 +88,5 @@ public static void clean() cachedCorrespondingComponentDictionaries.clean(); cachedLodespondingComponentDictionaries.clean(); } + #endregion methods } \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/ComponentExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/ComponentExtensions.cs index 903a24f..559f2ae 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/ComponentExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/ComponentExtensions.cs @@ -62,17 +62,54 @@ public static GameObject destroyAllComponentsNotDerivedFrom_ViaReflection component.gameObject.activeLocally(); + public static bool isActiveLocally(this Component component) + => component.gameObject.isActiveLocally(); + // method: return whether this given component's game object is inactive locally // + public static bool isInactiveLocally(this Component component) + => component.gameObject.isInactiveLocally(); // method: return whether this given component's game object is active globally // - public static bool activeGlobally(this Component component) - => component.gameObject.activeGlobally(); + public static bool isActiveGlobally(this Component component) + => component.gameObject.isActiveGlobally(); + // method: return whether this given component's game object is inactive globally // + public static bool isInactiveGlobally(this Component component) + => component.gameObject.isInactiveGlobally(); // method: set the activity of this given component's game object to the given boolean, then return this given component // public static ComponentT setActivityTo(this ComponentT component, bool activity) where ComponentT : Component => component.after(()=> component.gameObject.setActivityTo(activity)); + + // method: activate this given component, then return it // + public static ComponentT activate(this ComponentT component) where ComponentT : Component + => component.after(()=> + component.gameObject.activate()); + + // method: deactivate this given component, then return it // + public static ComponentT deactivate(this ComponentT component) where ComponentT : Component + => component.after(()=> + component.gameObject.activate()); + + // method: toggle the activity of this given component using the given toggling, then return this given component // + public static ComponentT toggleActivityBy(this ComponentT component, Toggling toggling) where ComponentT : Component + => component.after(()=> + component.gameObject.toggleActivityBy(toggling)); + + // method: toggle the activity of these given components using the given toggling, then return them // + public static ComponentT[] toggleActivityBy(this ComponentT[] components, Toggling toggling) where ComponentT : Component + => components.forEach(component => component.toggleActivityBy(toggling)); + + // method: set the activity of these given components to the given boolean, then return them // + public static ComponentT[] setActivityTo(this ComponentT[] components, bool activity) where ComponentT : Component + => components.forEach(component => component.setActivityTo(activity)); + + // method: activate these given components, then return them // + public static ComponentT[] activate(this ComponentT[] components) where ComponentT : Component + => components.setActivityTo(true); + + // method: deactivate these given components, then return them // + public static ComponentT[] deactivate(this ComponentT[] components) where ComponentT : Component + => components.setActivityTo(false); #endregion activity @@ -83,10 +120,38 @@ public static ComponentT executeAllLocal(this ComponentT component, => component.after(()=> component.gameObject.executeAllLocal(methodName, sendMessageOptions, boolean)); - // method: (if in the editor:) have all mono behaviours on this component's game object validate (if they have OnValidate defined), then return this given component // - public static ComponentT validate_IfInEditor(this ComponentT component) where ComponentT : Component - => component.after(()=> - component.gameObject.validate_IfInEditor()); + // method: (if in the editor:) have this given component's game object validate, then return this given component // + public static ComponentT validateObject_IfInEditor(this ComponentT component) where ComponentT : Component + => component.after(()=> + component.gameObject.validate_IfInEditor()); + + /* (via reflection) */ + public static ComponentI validateObjectViaThisI_IfInEditor(this ComponentI component) where ComponentI : class + { + if (Interfaces.doesNotInclude()) + { + return default(ComponentI).returnWithError(typeof(ComponentI).simpleClassName_ViaReflection()+" is not an interface"); + } + + return component.after(()=> + component.castTo().validateObject_IfInEditor()); + } + + // method: (if in the editor:) have this given set of components' game objects validate, then return this given set of components // + public static HashSet validateObjects_IfInEditor(this HashSet components) where ComponentT : Component + => components.forEach(component => component.validateObject_IfInEditor()); + + /* (via reflection) */ + public static HashSet validateObjectsViaTheseI_IfInEditor(this HashSet components) where ComponentI : class + { + if (Interfaces.doesNotInclude()) + { + return default(HashSet).returnWithError(typeof(ComponentI).simpleClassName_ViaReflection()+" is not an interface"); + } + + return components.after(()=> + components.forEach(component => component.validateObjectViaThisI_IfInEditor())); + } #endregion calling local methods diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/DictionaryExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/DictionaryExtensions.cs index 1ebae97..f04dd36 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/DictionaryExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/DictionaryExtensions.cs @@ -77,9 +77,11 @@ public static TValue recordingFor(this Dictionary di { return dictionary[key]; } - catch (KeyNotFoundException keyNotFoundException) + catch (KeyNotFoundException) { - return keyNotFoundException.logAsErrorAndReturnDefault(dictionary.asListing()+".recordingFor("+key+"):\nkey "+key+" not found in\ndictionary "+dictionary.asListing()); + string dictionaryListing = dictionary.asListing(); + + return (dictionaryListing+".recordingFor("+key+"):\nkey "+key+" not found in\ndictionary "+dictionaryListing).printAsErrorAndReturnDefault(); } } #endregion accessing @@ -141,13 +143,27 @@ public static Dictionary recordInGet(this TValue val #region caching - // method: return the value of this given dictionary at the given key, or if that key isn't set, add the result of the given backup value function to this given dictionary then return that given backup value // + // method: return the value of this given dictionary at the given key, or if that key isn't set, record the result of the given backup value function in this given dictionary for the given key and then return that given backup value // public static TValue cache(this Dictionary dictionary, TKey key, Func backupValueFunction) => ( dictionary.ContainsKey(key) ? dictionary[key] : backupValueFunction().recordIn(dictionary, key) ); + + // method: return the value of this given dictionary at the given key, or if that key isn't set or is null, record the result of the given backup value function in this given dictionary for the given key and then return that given backup value // + public static TValue cacheYull(this Dictionary dictionary, TKey key, Func backupValueFunction) + { + if (dictionary.ContainsKey(key)) + { + TValue valueFound = dictionary[key]; + if (valueFound.isYull()) + { + return valueFound; + } + } + return backupValueFunction().recordIn(dictionary, key); + } #endregion caching diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/DistanceExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/DistanceExtensions.cs index 3bdbf8e..582f3d9 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/DistanceExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/DistanceExtensions.cs @@ -50,10 +50,11 @@ public static GameObject nearestOf(this GameObject gameObject, IEnumerable(this GameObject gameObject, IEnumerable components) where ComponentT : Component => components.minProviderOtherwiseDefault(component => gameObject.distanceWith(component)); - // method: (via reflection if error:) return the nearest (by position) of the given interfaces (implemented by mono behaviours) to this given game object // + /* (via reflection) */ + // method: return the nearest (by position) of the given interfaces (implemented by mono behaviours) to this given game object // public static MonoBehaviourI nearestOfI(this GameObject gameObject, IEnumerable interfaces) where MonoBehaviourI : class { - if (!typeof(MonoBehaviourI).IsInterface) + if (Interfaces.doesNotInclude()) { return default(MonoBehaviourI).returnWithError(typeof(MonoBehaviourI).simpleClassName_ViaReflection()+" is not an interface"); } @@ -107,24 +108,116 @@ public static GameObject farthestOf(this Transform transform, IEnumerable Yull.areBoth(position_PositionProvider, otherPosition_PositionProvider) && - position_PositionProvider.providePosition() - .distanceWith(otherPosition_PositionProvider.providePosition()) <= thresholdDistance; - public static bool isNotWithinDistanceOf(this object position_PositionProvider, object otherPosition_PositionProvider, float thresholdDistance) - => !position_PositionProvider.isWithinDistanceOf(otherPosition_PositionProvider, thresholdDistance); - public static bool isWithinDistanceOf(this object position_PositionProvider, float thresholdDistance) where SingletonBehaviourT : SingletonBehaviour - => position_PositionProvider.isWithinDistanceOf(SingletonBehaviour.position, thresholdDistance); - public static bool isNotWithinDistanceOf(this object position_PositionProvider, float thresholdDistance) where SingletonBehaviourT : SingletonBehaviour - => !position_PositionProvider.isWithinDistanceOf(thresholdDistance); - public static bool isWithinDistanceOfCamera(this object position_PositionProvider, float thresholdDistance) - => position_PositionProvider.isWithinDistanceOf(Camera.main, thresholdDistance); - public static bool isNotWithinDistanceOfCamera(this object position_PositionProvider, float thresholdDistance) - => !position_PositionProvider.isNotWithinDistanceOfCamera(thresholdDistance); - public static bool isWithinDistanceOfPlayer(this object position_PositionProvider, float thresholdDistance) - => position_PositionProvider.isWithinDistanceOf(thresholdDistance); - public static bool isNotWithinDistanceOfPlayer(this object position_PositionProvider, float thresholdDistance) - => !position_PositionProvider.isWithinDistanceOfPlayer(thresholdDistance); + public static bool isWithinDistanceOf + ( + this object position_PositionProvider, + object otherPosition_PositionProvider, + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + { + if (position_PositionProvider.isNull()) + { + return false.returnWithError("given null position provider"); + } + if (thresholdDistance.isNegative()) + { + return false.returnWithError("given negative threshold distance"); + } + if (otherPosition_PositionProvider.isNull() && !treatOtherPositionNullAsInfinitelyDistant) + { + return false.returnWithError("given null other position provider but 'treatOtherPositionNullAsInfinitelyDistant' is false"); + } + + if (otherPosition_PositionProvider.isNull() && treatOtherPositionNullAsInfinitelyDistant) + { + return thresholdDistance.isInfinity(); + } + + return position_PositionProvider.providePosition() + .distanceWith(otherPosition_PositionProvider.providePosition()) <= thresholdDistance; + } + public static bool isNotWithinDistanceOf + ( + this object position_PositionProvider, + object otherPosition_PositionProvider, + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + => !position_PositionProvider.isWithinDistanceOf + ( + otherPosition_PositionProvider, + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); + public static bool isWithinDistanceOf + ( + this object position_PositionProvider, + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) where SingletonBehaviourT : SingletonBehaviour + => position_PositionProvider.isWithinDistanceOf + ( + SingletonBehaviour.position, + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); + public static bool isNotWithinDistanceOf + ( + this object position_PositionProvider, + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) where SingletonBehaviourT : SingletonBehaviour + => !position_PositionProvider.isWithinDistanceOf + ( + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); + public static bool isWithinDistanceOfCamera + ( + this object position_PositionProvider, + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + => position_PositionProvider.isWithinDistanceOf + ( + Camera.main, + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); + public static bool isNotWithinDistanceOfCamera + ( + this object position_PositionProvider, + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + => !position_PositionProvider.isNotWithinDistanceOfCamera + ( + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); + public static bool isWithinDistanceOfPlayer + ( + this object position_PositionProvider, + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + => position_PositionProvider.isWithinDistanceOf + ( + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); + public static bool isNotWithinDistanceOfPlayer + ( + this object position_PositionProvider, + float thresholdDistance, + bool treatOtherPositionNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) + => !position_PositionProvider.isWithinDistanceOfPlayer + ( + thresholdDistance, + treatOtherPositionNullAsInfinitelyDistant + ); #endregion is within distance of @@ -148,8 +241,32 @@ public static bool positionallyIsNotWithinSolidDistanceOf(this object position_P #region as position provider is within distance of nearest point on solid collider otherwise position - public static bool positionallyIsWithinIdeallySolidDistanceOf(this object position_PositionProvider, object colliderOtherwisePosition_ColliderOtherwisePositionProvider, float thresholdDistance) + public static bool positionallyIsWithinIdeallySolidDistanceOf + ( + this object position_PositionProvider, + object colliderOtherwisePosition_ColliderOtherwisePositionProvider, + float thresholdDistance, + bool treatOtherProviderNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) { + if (position_PositionProvider.isNull()) + { + return false.returnWithError("given null position provider"); + } + if (thresholdDistance.isNegative()) + { + return false.returnWithError("given negative threshold distance"); + } + if (colliderOtherwisePosition_ColliderOtherwisePositionProvider.isNull() && !treatOtherProviderNullAsInfinitelyDistant) + { + return false.returnWithError("given null other provider but 'treatOtherProviderNullAsInfinitelyDistant' is false"); + } + + if (colliderOtherwisePosition_ColliderOtherwisePositionProvider.isNull() && treatOtherProviderNullAsInfinitelyDistant) + { + return thresholdDistance.isInfinity(); + } + Collider potentialSolidCollider = colliderOtherwisePosition_ColliderOtherwisePositionProvider.provideSolidCollider(); return potentialSolidCollider.isYull() ? position_PositionProvider.positionallyIsWithinSolidDistanceOf @@ -163,11 +280,18 @@ public static bool positionallyIsWithinIdeallySolidDistanceOf(this object positi thresholdDistance ); } - public static bool positionallyIsNotWithinIdeallySolidDistanceOf(this object position_PositionProvider, object colliderOtherwisePosition_ColliderOtherwisePositionProvider, float thresholdDistance) + public static bool positionallyIsNotWithinIdeallySolidDistanceOf + ( + this object position_PositionProvider, + object colliderOtherwisePosition_ColliderOtherwisePositionProvider, + float thresholdDistance, + bool treatOtherProviderNullAsInfinitelyDistant = Default.treatingOfNullAsARelevantValue + ) => !position_PositionProvider.positionallyIsWithinIdeallySolidDistanceOf ( colliderOtherwisePosition_ColliderOtherwisePositionProvider, - thresholdDistance + thresholdDistance, + treatOtherProviderNullAsInfinitelyDistant ); #endregion as position provider is within distance of nearest point on solid collider otherwise position diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/EnableeComponentExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/EnableeComponentExtensions.cs index 7b9c95b..41b0cb8 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/EnableeComponentExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/EnableeComponentExtensions.cs @@ -41,15 +41,15 @@ private static bool enablementOf(Component enableeComponent) } else { - return default(bool).returnWithError("EnableeComponentExtensions.setEnablementOf given unrecognized dynamo of type "+enableeComponent.derivedType_ViaReflection()); + return default(bool).returnWithError("given unrecognized dynamo of type "+enableeComponent.derivedType_ViaReflection()); } } // method: return whether this given enablee component is enabled // public static bool isEnabled(this Component enableeComponent) => enablementOf(enableeComponent); - // method: return whether this given enablee component is not enabled // - public static bool isNotEnabled(this Component enableeComponent) + // method: return whether this given enablee component is disabled // + public static bool isDisabled(this Component enableeComponent) => !isEnabled(enableeComponent); /* (via reflection if error) */ diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/GameObjectExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/GameObjectExtensions.cs index 6e44f93..12f1c7f 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/GameObjectExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/GameObjectExtensions.cs @@ -9,7 +9,7 @@ // Game Object Extensions: // • provides extension methods for handling game objects -// #gameobject #execution +// #gameobject #execution #console public static class GameObjectExtensions { #region accessing @@ -65,28 +65,36 @@ public static Dictionary clean(this Dictionary gameObject.after(()=> string_.logAs(""+gameObject, gameObject, loggingSeparator)); + public static GameObject log(this GameObject gameObject, string string_, bool boolean = true, string loggingSeparator = Default.loggingSeparator) + => gameObject.after(()=> + string_.logAs(""+gameObject, gameObject, loggingSeparator), + boolean); public static List asEachObjectLog(this IEnumerable gameObjects, string string_, string loggingSeparator = Default.loggingSeparator) => gameObjects.forEachManifested(gameObject => - gameObject.log(string_, loggingSeparator)); + gameObject.log(string_, true, loggingSeparator)); public static HashSet uniquesAfterAsEachObjectLogging(this IEnumerable gameObjects, string string_, string loggingSeparator = Default.loggingSeparator) => gameObjects.uniquesAfterForEach(gameObject => - gameObject.log(string_, loggingSeparator)); + gameObject.log(string_, true, loggingSeparator)); #endregion printing #region activity // method: return whether this given game object is active locally // - public static bool activeLocally(this GameObject gameObject) + public static bool isActiveLocally(this GameObject gameObject) => gameObject.activeSelf; + // method: return whether this given game object is inactive locally // + public static bool isInactiveLocally(this GameObject gameObject) + => !gameObject.isActiveLocally(); // method: return whether this given game object is active globally // - public static bool activeGlobally(this GameObject gameObject) + public static bool isActiveGlobally(this GameObject gameObject) => gameObject.activeInHierarchy; + // method: return whether this given game object is inactive globally // + public static bool isInactiveGlobally(this GameObject gameObject) + => !gameObject.isActiveGlobally(); // method: set the activity of this given game object to the given boolean, then return this given game object // public static GameObject setActivityTo(this GameObject gameObject, bool activity) @@ -103,7 +111,7 @@ public static GameObject deactivate(this GameObject gameObject) // method: toggle the activity of this given game object using the given toggling, then return this given game object // public static GameObject toggleActivityBy(this GameObject gameObject, Toggling toggling) - => gameObject.setActivityTo(gameObject.activeLocally().toggledBy(toggling)); + => gameObject.setActivityTo(gameObject.isActiveLocally().toggledBy(toggling)); // method: toggle the activity of these given game objects using the given toggling, then return them // public static GameObject[] toggleActivityBy(this GameObject[] gameObjects, Toggling toggling) @@ -197,26 +205,16 @@ public static GameObject executeAllLocal(this GameObject gameObject, string meth gameObject.SendMessage(methodName, sendMessageOptions), boolean); - // method: (if in the editor:) have all mono behaviours on this game object validate (if they have OnValidate defined), then return this given game object // + // method: (if in the editor:) have this given game object validate (have all mono behaviours on this given game object validate (if they have OnValidate defined)), then return this given game object // public static GameObject validate_IfInEditor(this GameObject gameObject) => gameObject.executeAllLocal ( "OnValidate", SendMessageOptions.DontRequireReceiver, UnityIs.inEditor ); - #endregion calling local methods - - - #region conversion - - // method: return the game object idee for this given game object // - public static int idee(this GameObject gameObject) - => gameObject.GetInstanceID(); - #if UNITY_EDITOR - // method: if there is a game object corresponding to this given integer as a game object idee, return that game object; otherwise, return null // - public static GameObject gameObject(this int gameObjectIdee) - => EditorUtility.InstanceIDToObject(gameObjectIdee) as GameObject; - #endif - #endregion conversion + // method: (if in the editor:) have this given set of game objects validate, then return this given set of game objects // + public static HashSet validate_IfInEditor(this HashSet gameObjects) + => gameObjects.forEach(gameObject => gameObject.validate_IfInEditor()); + #endregion calling local methods } \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/HierarchyExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/HierarchyExtensions.cs index e361133..ad1c808 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/HierarchyExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/HierarchyExtensions.cs @@ -38,94 +38,28 @@ public static ComponentT makeUniversalAndTemporary(this ComponentT c => component.after(()=> component.gameObject.makeUniversalAndTemporary()); #endregion making objects universal andor temporary + - - #region determining hierarchy selection + #region setting hierarchy expansion #if UNITY_EDITOR - // method: return whether this given game object is currently selected in the hierarchy // - public static bool isSelectedInHierarchy(this GameObject gameObject) - => Selection.gameObjects.contains(gameObject); - - // method: return whether this given game object is not currently selected in the hierarchy // - public static bool isNotSelectedInHierarchy(this GameObject gameObject) - => !gameObject.isSelectedInHierarchy(); + // method: (via reflection:) return whether the game object for this given instance idee is currently expanded in the hierarchy // + public static bool asGameObjectInstanceIdeeIsExpandedInHierarchy_ViaReflection(this int gameObjectInstanceIdee) + => TreeViews.expansionOf_ViaReflection + ( + gameObjectInstanceIdee, + Hierarchy.windowTreeViewController_ViaReflection + ); + public static bool asGameObjectInstanceIdeeIsNotExpandedInHierarchy_ViaReflection(this int gameObjectInstanceIdee) + => !gameObjectInstanceIdee.asGameObjectInstanceIdeeIsExpandedInHierarchy_ViaReflection(); + + // method: (via reflection:) return whether this given game object is currently expanded in the hierarchy // + public static bool isExpandedInHierarchy_ViaReflection(this GameObject gameObject) + => gameObject.instanceIdee().asGameObjectInstanceIdeeIsExpandedInHierarchy_ViaReflection(); + public static bool isNotExpandedInHierarchy_ViaReflection(this GameObject gameObject) + => !gameObject.isExpandedInHierarchy_ViaReflection(); #endif - #endregion determining hierarchy selection - - - #region setting hierarchy objects selection - - // method: (if in the editor:) select this given game object in the hierarchy, then return this given game object // - public static GameObject selectInHierarchy_IfInEditor(this GameObject gameObject) - { - #if UNITY_EDITOR - if (UnityIs.inEditor) - { - return Selection.activeGameObject = gameObject; - } - #endif - - return gameObject; - } - // method: (if in the editor:) select this given component's game object in the hierarchy (if this given component and its game object are both yull), then return this given component // - public static ComponentT selectInHierarchy_IfInEditor(this ComponentT component) where ComponentT : Component - => component.after(()=> - component.gameObject.selectInHierarchy_IfInEditor(), - component.isYull() && component.gameObject.isYull()); - // method: (if in the editor:) select the uniques of these given game objects in the hierarchy, then return the set of these given game objects // - public static HashSet selectUniquesInHierarchy_IfInEditor(this IEnumerable gameObjects) - { - HashSet uniqueGameObjects = gameObjects.uniques(); - - #if UNITY_EDITOR - if (UnityIs.inEditor) - { - Selection.objects = uniqueGameObjects.toArray(); - } - #endif - - return uniqueGameObjects; - } - #endregion setting hierarchy objects selection - - - #region pinging objects in the hierarchy - - // method: (if in the editor:) ping these given game objects in the hierarchy (only each one that is yull), then return the set of these given game objects // - public static HashSet pingUniquesInHierarchy_IfInEditor(this IEnumerable gameObjects) - => gameObjects.forEachUnique(gameObject => - { - if (gameObject.isYull()) - { - Hierarchy.ping_IfInEditor(gameObject); - } - }); - // method: (if in the editor:) ping these given components' game objects in the hierarchy (only each component that is yull (and whose game object is yull)), then return the set of these given components // - public static HashSet pingUniquesInHierarchy_IfInEditor(this IEnumerable components) where ComponentT : Component - => components.forEachUnique(component => - { - if (component.isYull()) - { - Hierarchy.ping_IfInEditor(component); - } - }); - #endregion pinging objects in the hierarchy - - - #region setting hierarchy objects selection then pinging the selection - - // method: (if in the editor:) select and ping this given game object in the hierarchy (if it's yull), then return this given game object // - public static GameObject selectAndPingInHierarchy_IfInEditor(this GameObject gameObject) - => gameObject.after(()=> - Hierarchy.ping_IfInEditor(gameObject.selectInHierarchy_IfInEditor()), - gameObject.isYull()); - // method: (if in the editor:) select and ping this given component's game object in the hierarchy (if this given component and its game object are both yull), then return this given component // - public static ComponentT selectAndPingInHierarchy_IfInEditor(this ComponentT component) where ComponentT : Component - => component.after(()=> - component.gameObject.selectAndPingInHierarchy_IfInEditor(), - component.isYull() && component.gameObject.isYull()); - #endregion setting hierarchy objects selection then pinging the selection + #endregion setting hierarchy expansion #region setting hierarchy expansion @@ -149,21 +83,21 @@ public static GameObject setHierarchyExpansionTo(this GameObject gameObject, boo } return gameObject; } - public static HashSet setHierarchyExpansionOfUniquesTo(this IEnumerable gameObjects, bool expansion) + public static HashSet setHierarchyExpansionTo(this IEnumerable gameObjects, bool expansion) => gameObjects.forEachUnique(gameObject => gameObject.setHierarchyExpansionTo(expansion)); public static GameObject expandInHierarchy(this GameObject gameObject) => gameObject.setHierarchyExpansionTo(true); - public static HashSet expandUniquesInHierarchy(this IEnumerable gameObjects) - => gameObjects.setHierarchyExpansionOfUniquesTo(true); + public static HashSet expandInHierarchy(this IEnumerable gameObjects) + => gameObjects.setHierarchyExpansionTo(true); public static GameObject collapseInHierarchy(this GameObject gameObject) => gameObject.setHierarchyExpansionTo(false); - public static HashSet collapseUniquesInHierarchy(this IEnumerable gameObjects) - => gameObjects.setHierarchyExpansionOfUniquesTo(false); + public static HashSet collapseInHierarchy(this IEnumerable gameObjects) + => gameObjects.setHierarchyExpansionTo(false); public static GameObject setHierarchyExpansionForSelfAndChildrenTo(this GameObject gameObject, bool expansion) => gameObject.after(()=> gameObject.setHierarchyExpansionTo(expansion) - .childObjects().setHierarchyExpansionOfUniquesTo(expansion)); + .childObjects().setHierarchyExpansionTo(expansion)); public static GameObject expandSelfAndChildrenInHierarchy(this GameObject gameObject) => gameObject.setHierarchyExpansionForSelfAndChildrenTo(true); public static GameObject collapseSelfAndChildrenInHierarchy(this GameObject gameObject) @@ -176,8 +110,18 @@ public static GameObject setHierarchyExpansionForLodalsTo(this GameObject gameOb TabTo.hierarchy(); typeof(EditorWindow).Assembly.GetType("UnityEditor.SceneHierarchyWindow") - .GetMethod("SetExpandedRecursive") - .Invoke(Focused.window, new object[] {gameObject.idee(), expansion}); + .GetMethod + ( + "SetExpandedRecursive" + ).Invoke + ( + Focused.window, + new object[] + { + gameObject.instanceIdee(), + expansion + } + ); } return gameObject; @@ -186,6 +130,12 @@ public static GameObject expandLodalsInHierarchy(this GameObject gameObject) => gameObject.setHierarchyExpansionForLodalsTo(true); public static GameObject collapseLodalsInHierarchy(this GameObject gameObject) => gameObject.setHierarchyExpansionForLodalsTo(false); + public static HashSet setHierarchyExpansionForLodalsTo(this IEnumerable gameObjects, bool expansion) + => gameObjects.forEachUnique(gameObject => gameObject.setHierarchyExpansionForLodalsTo(expansion)); + public static HashSet expandLodalsInHierarchy(this IEnumerable gameObjects) + => gameObjects.forEachUnique(gameObject => gameObject.expandLodalsInHierarchy()); + public static HashSet collapseLodalsInHierarchy(this IEnumerable gameObjects) + => gameObjects.forEachUnique(gameObject => gameObject.collapseLodalsInHierarchy()); #endif #endregion setting hierarchy expansion } \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/IEnumerableExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/IEnumerableExtensions.cs index 1b75521..b9dc946 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/IEnumerableExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/IEnumerableExtensions.cs @@ -262,6 +262,12 @@ public static TItem randomItemExceptGivenOtherwiseRandomItem(this IEnumer #region extremes + public static TItem min(this IEnumerable enumerable) where TItem : IComparable + => enumerable.Min(); + + public static TItem max(this IEnumerable enumerable) where TItem : IComparable + => enumerable.Max(); + public static TResult min(this IEnumerable enumerable, Func function) where TResult : IComparable => enumerable.Min(function); diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/InstanceIdeeExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/InstanceIdeeExtensions.cs new file mode 100644 index 0000000..d1297eb --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/InstanceIdeeExtensions.cs @@ -0,0 +1,24 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; + +// Instance Idee Extensions: +// • provides extension methods for handling instance idees +// #instancing #unityobject #gameobject +public static class InstanceIdeeExtensions +{ + // method: return the instance idee of this given Unity object // + public static int instanceIdee(this Object object_) + => object_.GetInstanceID(); + + // method: return whether this given instance idee is the instance idee for the given Unity object // + public static bool isTheInstanceIdeeFor(this int instanceIdee, Object object_) + => object_.instanceIdee() == instanceIdee; + + #if UNITY_EDITOR + // method: if there is a game object corresponding to this given integer as a game object idee, return that game object; otherwise, return null // + public static GameObject asInstanceIdeeToGameObject(this int gameObjectInstanceIdee) + => EditorUtility.InstanceIDToObject(gameObjectInstanceIdee) as GameObject; + #endif +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/InstanceIdeeExtensions.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/InstanceIdeeExtensions.cs.meta new file mode 100644 index 0000000..cfdade5 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/InstanceIdeeExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b09a9922d345de447bcab2e9fea9842a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/LocalityExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/LocalityExtensions.cs index a7e2c0c..264f803 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/LocalityExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/LocalityExtensions.cs @@ -47,14 +47,15 @@ public static bool hasAny ) where ComponentT : Component => component.gameObject.hasAny(function, includeInactiveComponents); - // methods: (via reflection if error:) return whether this given provided game object has any component of the specified interface, optionally including inactive components according to the given boolean // + /* (via reflection) */ + // methods: return whether this given provided game object has any component of the specified interface, optionally including inactive components according to the given boolean // public static bool hasAnyI ( this GameObject gameObject, bool includeInactiveComponents = Default.inclusionOfInactiveComponents ) where ComponentI : class { - if (!typeof(ComponentI).IsInterface) + if (Interfaces.doesNotInclude()) { return false.returnWithError(typeof(ComponentI).simpleClassName_ViaReflection()+" is not an interface"); } @@ -74,7 +75,8 @@ public static bool hasAnyI ) where ComponentI : class => component.gameObject.hasAnyI(includeInactiveComponents); - // methods: (via reflection if error:) return whether this given provided game object has any component of the specified interface for which the given function returns true, optionally including inactive components according to the given boolean // + /* (via reflection) */ + // methods: return whether this given provided game object has any component of the specified interface for which the given function returns true, optionally including inactive components according to the given boolean // public static bool hasAnyI ( this GameObject gameObject, @@ -82,7 +84,7 @@ public static bool hasAnyI bool includeInactiveComponents = Default.inclusionOfInactiveComponents ) where ComponentI : class { - if (!typeof(ComponentI).IsInterface) + if (Interfaces.doesNotInclude()) { return false.returnWithError(typeof(ComponentI).simpleClassName_ViaReflection()+" is not an interface"); } @@ -171,10 +173,11 @@ public static ComponentT first(this Transform transform, bool includ // method: return this given component's game object's first component of the specified class (null if none found), optionally including inactive components according to the given boolean // public static ComponentT first(this Component component, bool includeInactiveComponents = Default.inclusionOfInactiveComponents) where ComponentT : Component => component.gameObject.first(includeInactiveComponents); - // method: (via reflection if error:) return this given game object's first component of the specified interface (null if none found), optionally including inactive components according to the given boolean // + /* (via reflection) */ + // method: return this given game object's first component of the specified interface (null if none found), optionally including inactive components according to the given boolean // public static ComponentI firstI(this GameObject gameObject, bool includeInactiveComponents = Default.inclusionOfInactiveComponents) where ComponentI : class { - if (!typeof(ComponentI).IsInterface) + if (Interfaces.doesNotInclude()) { return default(ComponentI).returnWithError(typeof(ComponentI).simpleClassName_ViaReflection()+" is not an interface"); } @@ -194,7 +197,7 @@ public static IEnumerable accessEachFirst(this Transform // method: return a list of the specified class of components, optionally including inactive components according to the given boolean, on this given game object // public static List pick(this GameObject gameObject, bool includeInactiveComponents = Default.inclusionOfInactiveComponents) where ComponentT : Component => gameObject.GetComponents().where(component => - component.activeGlobally(), + component.isActiveGlobally(), !includeInactiveComponents); // method: return a list of the specified class of components, optionally including inactive components according to the given boolean, on this given transform // public static List pick(this Transform transform, bool includeInactiveComponents = Default.inclusionOfInactiveComponents) where ComponentT : Component @@ -202,16 +205,17 @@ public static List pick(this Transform transform, bool i // method: return a list of the specified class of components on this given component's game object, optionally including inactive components according to the given boolean // public static List pick(this Component component, bool includeInactiveComponents = Default.inclusionOfInactiveComponents) where ComponentT : Component => component.gameObject.pick(includeInactiveComponents); - // method: (via reflection if error:) return a list of the specified interface of components, optionally including inactive components according to the given boolean, on this given game object // + /* (via reflection) */ + // method: return a list of the specified interface of components, optionally including inactive components according to the given boolean, on this given game object // public static List pickI(this GameObject gameObject, bool includeInactiveComponents = Default.inclusionOfInactiveComponents) where ComponentI : class { - if (!typeof(ComponentI).IsInterface) + if (Interfaces.doesNotInclude()) { return default(List).returnWithError(typeof(ComponentI).simpleClassName_ViaReflection()+" is not an interface"); } return gameObject.GetComponents().where(component => - component.castTo().activeGlobally(), + component.castTo().isActiveGlobally(), !includeInactiveComponents); } diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/LodalityExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/LodalityExtensions.cs index 35e36ce..4cd3047 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/LodalityExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/LodalityExtensions.cs @@ -76,10 +76,10 @@ public static bool hasAnyLodal(this Component component, bool includ public static bool hasAnyLodal(this RaycastHit raycastHit, bool includeInactiveComponents = Default.inclusionOfInactiveComponents) where ComponentT : Component => Any.itemsIn(raycastHit.lodal(includeInactiveComponents)); - /* (via reflection if error) */ + /* (via reflection) */ public static bool hasAnyLodalI(this GameObject gameObject, bool includeInactiveComponents = Default.inclusionOfInactiveComponents) where ComponentI : class { - if (!typeof(ComponentI).IsInterface) + if (Interfaces.doesNotInclude()) { return false.returnWithError(typeof(ComponentI).simpleClassName_ViaReflection()+" is not an interface"); } @@ -94,32 +94,38 @@ public static bool hasAnyLodalI(this GameObject gameObject, bool inc // method: return this given game object's first lodal component of the specified class (null if none found), optionally including inactive components according to the given boolean // public static ComponentT firstLodal(this GameObject gameObject, bool includeInactiveComponents = Default.inclusionOfInactiveComponents) where ComponentT : Component => gameObject.GetComponentInChildren(includeInactiveComponents); + // method: return this given transform's first lodal component of the specified class (null if none found), optionally including inactive components according to the given boolean // + public static ComponentT firstLodal(this Transform transform, bool includeInactiveComponents = Default.inclusionOfInactiveComponents) where ComponentT : Component + => transform.GetComponentInChildren(includeInactiveComponents); + // method: return this given component's first lodal component of the specified class (null if none found), optionally including inactive components according to the given boolean // + public static ComponentT firstLodal(this Component component, bool includeInactiveComponents = Default.inclusionOfInactiveComponents) where ComponentT : Component + => component.GetComponentInChildren(includeInactiveComponents); + // method: return this given raycast hit's first lodal component of the specified class (null if none found), optionally including inactive components according to the given boolean // + public static ComponentT firstLodal(this RaycastHit raycastHit, bool includeInactiveComponents = Default.inclusionOfInactiveComponents) where ComponentT : Component + => raycastHit.transform.firstLodal(includeInactiveComponents); + public static ComponentT firstLodalWhere(this GameObject gameObject, Func function, bool includeInactiveComponents = Default.inclusionOfInactiveComponents) where ComponentT : Component => gameObject.lodal(includeInactiveComponents).firstWhere(function); + public static ColliderT firstLodalSolid(this GameObject gameObject, bool includeInactiveColliders = Default.inclusionOfInactiveComponents) where ColliderT : Collider => gameObject.lodalSolid(includeInactiveColliders).first(); public static ColliderT firstLodalSolid(this Component component, bool includeInactiveColliders = Default.inclusionOfInactiveComponents) where ColliderT : Collider => component.gameObject.firstLodalSolid(includeInactiveColliders); + public static ColliderT firstLodalTrigger(this GameObject gameObject, bool includeInactiveColliders = Default.inclusionOfInactiveComponents) where ColliderT : Collider => gameObject.lodalTrigger(includeInactiveColliders).first(); public static ColliderT firstLodalTrigger(this Component component, bool includeInactiveColliders = Default.inclusionOfInactiveComponents) where ColliderT : Collider => component.gameObject.firstLodalTrigger(includeInactiveColliders); - // method: return this given transform's first lodal component of the specified class (null if none found), optionally including inactive components according to the given boolean // - public static ComponentT firstLodal(this Transform transform, bool includeInactiveComponents = Default.inclusionOfInactiveComponents) where ComponentT : Component - => transform.GetComponentInChildren(includeInactiveComponents); - // method: return this given component's first lodal component of the specified class (null if none found), optionally including inactive components according to the given boolean // - public static ComponentT firstLodal(this Component component, bool includeInactiveComponents = Default.inclusionOfInactiveComponents) where ComponentT : Component - => component.GetComponentInChildren(includeInactiveComponents); public static GameObject firstLodalObjectWith(this GameObject gameObject, bool includeInactiveComponents = Default.inclusionOfInactiveComponents) where ComponentT : Component => gameObject.firstLodal().gameObject; public static GameObject firstLodalObjectWith(this Component component, bool includeInactiveComponents = Default.inclusionOfInactiveComponents) where ComponentT : Component => component.firstLodal().gameObject; - /* (via reflection if error) */ + /* (via reflection) */ public static ComponentI firstLodalI(this GameObject gameObject, bool includeInactiveComponents = Default.inclusionOfInactiveComponents) where ComponentI : class { - if (!typeof(ComponentI).IsInterface) + if (Interfaces.doesNotInclude()) { return default(ComponentI).returnWithError(typeof(ComponentI).simpleClassName_ViaReflection()+" is not an interface"); } @@ -145,10 +151,11 @@ public static HashSet lodalTrigger(this GameObject gameObj public static HashSet lodalTrigger(this Component component, bool includeInactiveColliders = Default.inclusionOfInactiveComponents) where ColliderT : Collider => component.gameObject.lodalTrigger(includeInactiveColliders); - // method: (via reflection if error:) return an array of the specified interface of components, optionally including inactive components according to the given boolean, which are lodal to this given game object // + /* (via reflection) */ + // method: return an array of the specified interface of components, optionally including inactive components according to the given boolean, which are lodal to this given game object // public static ComponentI[] lodalI(this GameObject gameObject, bool includeInactiveComponents = Default.inclusionOfInactiveComponents) where ComponentI : class { - if (!typeof(ComponentI).IsInterface) + if (Interfaces.doesNotInclude()) { return default(ComponentI[]).returnWithError(typeof(ComponentI).simpleClassName_ViaReflection()+" is not an interface"); } @@ -156,10 +163,11 @@ public static ComponentI[] lodalI(this GameObject gameObject, bool i return gameObject.GetComponentsInChildren(includeInactiveComponents); } - // method: (via reflection if error:) return the set of game objects with the specified interface of components, optionally including inactive components according to the given boolean, which are lodal to this given game object // + /* (via reflection) */ + // method: return the set of game objects with the specified interface of components, optionally including inactive components according to the given boolean, which are lodal to this given game object // public static HashSet lodalObjectsWithI(this GameObject gameObject, bool includeInactiveComponents = Default.inclusionOfInactiveComponents) where ComponentI : class { - if (!typeof(ComponentI).IsInterface) + if (Interfaces.doesNotInclude()) { return default(HashSet).returnWithError(typeof(ComponentI).simpleClassName_ViaReflection()+" is not an interface"); } diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/MeshRendererExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/MeshRendererExtensions.cs new file mode 100644 index 0000000..f2a4166 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/MeshRendererExtensions.cs @@ -0,0 +1,10 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +// Mesh Renderer Extensions: +// • provides extension methods for handling mesh renderers +public static class MeshRendererExtensions +{ + +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/MeshRendererExtensions.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/MeshRendererExtensions.cs.meta new file mode 100644 index 0000000..e721c72 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/MeshRendererExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3ecdfe32c6dc3ed4f846310ff4b294fa +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/MonoBehaviourExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/MonoBehaviourExtensions.cs index dfd9de1..4593a48 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/MonoBehaviourExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/MonoBehaviourExtensions.cs @@ -38,6 +38,68 @@ public static MonoBehaviour executeAfter(this MonoBehaviour monoBehaviour, float #endregion planning to execute methods + #region validation + + // method: (via reflection:) (if in the editor:) have this given mono behaviour validate if it has validation defined (if it has an 'OnValidate' method, call it), then return this given mono behaviour // + public static MonoBehaviourT validate_IfInEditor_ViaReflection(this MonoBehaviourT monoBehaviour) where MonoBehaviourT : MonoBehaviour + { + #if UNITY_EDITOR + if (monoBehaviour.isNull()) + { + return "MonoBehaviourExtensions.validate_IfInEditor_ViaReflection given null mono behaviour".printAsErrorAndReturnDefault(); + } + + dynamic monoBehaviourDynamo = monoBehaviour; + try + { + monoBehaviourDynamo.OnValidate(); + } + catch (Exception exception) // should be a 'RuntimeBinderException' – unfortunately, that class isn't available in with Unity, for some unknown reason... so it's checked to be via reflection, below, and an error is printed if it isn't + { + if + ( + exception.hasNoSelfOrInheritedSimpleClassName_ViaReflection(selfOrInheritedSimpleClassName => + selfOrInheritedSimpleClassName.contains("RuntimeBinder")) + ) + { + monoBehaviour.returnWithError("MonoBehaviourExtensions.validate_IfInEditor_ViaReflection encountered unexpected exception:\n"+exception); + } + } + #endif + + return monoBehaviour; + } + + /* (via reflection) */ + public static MonoBehaviourI validateI_IfInEditor_ViaReflection(this MonoBehaviourI monoBehaviour) where MonoBehaviourI : class + { + if (Interfaces.doesNotInclude()) + { + return default(MonoBehaviourI).returnWithError(typeof(MonoBehaviourI).simpleClassName_ViaReflection()+" is not an interface"); + } + + return monoBehaviour.after(()=> + monoBehaviour.castTo().validate_IfInEditor_ViaReflection()); + } + + // method: (if in the editor:) have this given set of mono behaviours validate, then return this given set of mono behaviours // + public static HashSet validate_IfInEditor_ViaReflection(this HashSet monoBehaviours) where MonoBehaviourT : MonoBehaviour + => monoBehaviours.forEach(monoBehaviour => monoBehaviour.validate_IfInEditor_ViaReflection()); + + /* (via reflection) */ + public static HashSet validateI_IfInEditor_ViaReflection(this HashSet monoBehaviours) where MonoBehaviourI : class + { + if (Interfaces.doesNotInclude()) + { + return default(HashSet).returnWithError(typeof(MonoBehaviourI).simpleClassName_ViaReflection()+" is not an interface"); + } + + return monoBehaviours.after(()=> + monoBehaviours.forEach(monoBehaviour => monoBehaviour.validateI_IfInEditor_ViaReflection())); + } + #endregion validation + + #region conversion #if UNITY_EDITOR diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/PingingExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/PingingExtensions.cs new file mode 100644 index 0000000..3849866 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/PingingExtensions.cs @@ -0,0 +1,45 @@ +using System.Collections; +using System.Collections.Generic; +#if UNITY_EDITOR +using UnityEditor; +#endif +using UnityEngine; + +// Pinging Extensions: +// • provides extension methods for pinging (in the editor) +// #pinging +public static class PingingExtensions +{ + // method: (if in the editor:) ping this given game object (if it's yull), then return this given game object // + public static GameObject ping_IfInEditor(this GameObject gameObject) + => gameObject.after(gameObject_ => + { + #if UNITY_EDITOR + EditorGUIUtility.PingObject(gameObject_); + #endif + }, gameObject.isYull() && UnityIs.inEditor); + // method: (if in the editor:) ping this given component's game object (if this given component and its game object are both yull), then return this given component // + public static ComponentT ping_IfInEditor(this ComponentT component) where ComponentT : Component + => component.after(()=> + ping_IfInEditor(component.gameObject), + component.isYull() && component.gameObject.isYull()); + + // method: (if in the editor:) ping these given game objects (only each one that is yull), then return the set of these given game objects // + public static HashSet pingUniques_IfInEditor(this IEnumerable gameObjects) + => gameObjects.forEachUnique(gameObject => + { + if (gameObject.isYull()) + { + gameObject.ping_IfInEditor(); + } + }); + // method: (if in the editor:) ping these given components' game objects (only each component that is yull (and whose game object is yull)), then return the set of these given components // + public static HashSet pingUniques_IfInEditor(this IEnumerable components) where ComponentT : Component + => components.forEachUnique(component => + { + if (component.isYull()) + { + component.ping_IfInEditor(); + } + }); +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/PingingExtensions.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/PingingExtensions.cs.meta new file mode 100644 index 0000000..0d00a1e --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/PingingExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6c6ac2f7f2971164b84034f94881360f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/PrintingExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/PrintingExtensions.cs index 2508489..f75306d 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/PrintingExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/PrintingExtensions.cs @@ -29,13 +29,18 @@ public static string print(this string string_, GameObject contextGameObject = n return string_; } - // method: print this given object, optionally with the given game object as the context, then return it // + // method: print this given object, optionally with the given game object as the context, then return this given object // public static ObjectT print(this ObjectT object_, GameObject contextGameObject = null) => object_.returnAnd(()=> object_.ToString().print(contextGameObject)); // method: print this given game object with itself as the context, then return it // public static GameObject print(this GameObject gameObject) => gameObject.print(gameObject); + + // method: print whether this given object is yull, optionally with the given game object as the context, then return this given object // + public static ObjectT printYullness(this ObjectT object_, GameObject contextGameObject = null) + => object_.returnAnd(()=> + object_.isYull().print(contextGameObject)); // method: print this given object, optionally with the given game object as the context, logged as following the given prefix and using the given logging separator, then return this given object // public static ObjectT logAs(this ObjectT object_, string prefix, GameObject contextGameObject = null, string loggingSeparator = Default.loggingSeparator) diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/ProvidingExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/ProvidingExtensions.cs index 8e31884..e9190f7 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/ProvidingExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/ProvidingExtensions.cs @@ -39,7 +39,8 @@ public static Transform provideTransform(this object dynamo) } else { - return default(Transform).returnWithError("ProvidingExtensions.provideTransform given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()); + return ("ProvidingExtensions.provideTransform given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()) + .printAsErrorAndReturnDefault(); } } @@ -61,7 +62,8 @@ public static GameObject provideGameObject(this object dynamo) } else { - return default(GameObject).returnWithError("ProvidingExtensions.provideGameObject given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()); + return ("ProvidingExtensions.provideGameObject given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()) + .printAsErrorAndReturnDefault(); } } @@ -87,7 +89,8 @@ public static string provideTag(this object dynamo) } else { - return default(string).returnWithError("ProvidingExtensions.provideTag given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()); + return ("ProvidingExtensions.provideTag given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()) + .printAsErrorAndReturnDefault(); } } @@ -97,7 +100,8 @@ public static int provideLayerIndex(this object dynamo) { if (dynamo.isNull()) { - return default(int).returnWithError("ProvidingExtensions.provideLayerIndex given null dynamo"); + return ("ProvidingExtensions.provideLayerIndex given null dynamo") + .printAsErrorAndReturnDefault(); } else if (dynamo is int) { @@ -117,7 +121,8 @@ public static int provideLayerIndex(this object dynamo) } else { - return default(int).returnWithError("ProvidingExtensions.provideLayerIndex given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()); + return ("ProvidingExtensions.provideLayerIndex given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()) + .printAsErrorAndReturnDefault(); } } /* (via reflection if error) */ @@ -145,7 +150,8 @@ public static string provideLayerName(this object dynamo) } else { - return default(string).returnWithError("ProvidingExtensions.provideLayerName given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()); + return ("ProvidingExtensions.provideLayerName given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()) + .printAsErrorAndReturnDefault(); } } /* (via reflection if error) */ @@ -189,7 +195,8 @@ public static HashSet provideUniqueLayerNames(this object dynamo) } else { - return default(HashSet).returnWithError("ProvidingExtensions.provideUniqueLayerNames given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()); + return ("ProvidingExtensions.provideUniqueLayerNames given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()) + .printAsErrorAndReturnDefault>(); } } @@ -223,7 +230,8 @@ public static Collider provideCollider(this object dynamo) } else { - return default(Collider).returnWithError("ProvidingExtensions.provideCollider given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()); + return ("ProvidingExtensions.provideCollider given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()) + .printAsErrorAndReturnDefault(); } } /* (via reflection if error) */ @@ -251,7 +259,8 @@ public static Collider provideSolidCollider(this object dynamo) } else { - return default(Collider).returnWithError("ProvidingExtensions.provideSolidCollider given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()); + return ("ProvidingExtensions.provideSolidCollider given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()) + .printAsErrorAndReturnDefault(); } } /* (via reflection if error) */ @@ -279,7 +288,8 @@ public static Collider provideTriggerCollider(this object dynamo) } else { - return default(Collider).returnWithError("ProvidingExtensions.provideTriggerCollider given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()); + return ("ProvidingExtensions.provideTriggerCollider given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()) + .printAsErrorAndReturnDefault(); } } @@ -297,7 +307,8 @@ public static RaycastHit provideRaycastHit(this object dynamo) } else { - return default(RaycastHit).returnWithError("ProvidingExtensions.provideRaycastHit given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()); + return ("ProvidingExtensions.provideRaycastHit given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()) + .printAsErrorAndReturnDefault(); } } @@ -337,7 +348,8 @@ public static Vector3 providePosition(this object dynamo) } else { - return default(Vector3).returnWithError("ProvidingExtensions.providePosition given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()); + return ("ProvidingExtensions.providePosition given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()) + .printAsErrorAndReturnDefault(); } } @@ -363,7 +375,8 @@ public static Rigidbody provideRigidbody(this object dynamo) } else { - return default(Rigidbody).returnWithError("ProvidingExtensions.provideRigidbody given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()); + return ("ProvidingExtensions.provideRigidbody given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()) + .printAsErrorAndReturnDefault(); } } /* (via reflection if error) */ @@ -399,7 +412,8 @@ public static List provideRigidbodies(this object dynamo) } else { - return default(List).returnWithError("ProvidingExtensions.provideRigidbodies given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()); + return ("ProvidingExtensions.provideRigidbodies given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()) + .printAsErrorAndReturnDefault>(); } } @@ -443,7 +457,8 @@ public static Mesh provideMesh(this object dynamo) } else { - return default(Mesh).returnWithError("ProvidingExtensions.provideMesh given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()); + return ("ProvidingExtensions.provideMesh given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()) + .printAsErrorAndReturnDefault(); } } /* (via reflection if error) */ @@ -467,7 +482,8 @@ public static Mesh provideSharedMesh(this object dynamo) } else { - return default(Mesh).returnWithError("ProvidingExtensions.provideSharedMesh given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()); + return ("ProvidingExtensions.provideSharedMesh given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()) + .printAsErrorAndReturnDefault(); } } @@ -505,7 +521,8 @@ public static Vector3 providePrimitiveColliderCenterPosition(this object dynamo) { return firstLodalCapsuleCollider.centerPosition(); } - return default(Vector3).returnWithError("ProvidingExtensions.providePrimitiveColliderCenterPosition given game object (or component, earlier) without a primitive collider"); + return ("ProvidingExtensions.providePrimitiveColliderCenterPosition given game object (or component, earlier) without a primitive collider") + .printAsErrorAndReturnDefault(); } else if (dynamo is Component) { @@ -513,7 +530,8 @@ public static Vector3 providePrimitiveColliderCenterPosition(this object dynamo) } else { - return default(Vector3).returnWithError("ProvidingExtensions.providePrimitiveColliderCenterPosition given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()); + return ("ProvidingExtensions.providePrimitiveColliderCenterPosition given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()) + .printAsErrorAndReturnDefault(); } } /* (via reflection if error) */ @@ -549,7 +567,8 @@ public static Vector3 providePrimitiveColliderLocalCenterPosition(this object dy { return firstLodalCapsuleCollider.localCenterPosition(); } - return default(Vector3).returnWithError("ProvidingExtensions.providePrimitiveColliderLocalCenterPosition given game object (or component, earlier) without a primitive collider"); + return ("ProvidingExtensions.providePrimitiveColliderLocalCenterPosition given game object (or component, earlier) without a primitive collider") + .printAsErrorAndReturnDefault(); } else if (dynamo is Component) { @@ -557,7 +576,8 @@ public static Vector3 providePrimitiveColliderLocalCenterPosition(this object dy } else { - return default(Vector3).returnWithError("ProvidingExtensions.providePrimitiveColliderLocalCenterPosition given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()); + return ("ProvidingExtensions.providePrimitiveColliderLocalCenterPosition given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()) + .printAsErrorAndReturnDefault(); } } @@ -587,7 +607,8 @@ public static HashSet provideUniqueGameObjects(this object dynamo) } else { - return default(HashSet).returnWithError("ProvidingExtensions.provideUniqueGameObjects given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()); + return ("ProvidingExtensions.provideUniqueGameObjects given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()) + .printAsErrorAndReturnDefault>(); } } #endregion Unity @@ -622,7 +643,8 @@ public static Unit provideUnit(this object dynamo) } else { - return default(Unit).returnWithError("ProvidingExtensions.provideUnit given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()); + return ("ProvidingExtensions.provideUnit given unrecognized dynamo of type "+dynamo.derivedType_ViaReflection()) + .printAsErrorAndReturnDefault(); } } diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/ReflectionExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/ReflectionExtensions.cs new file mode 100644 index 0000000..66afaed --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/ReflectionExtensions.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using UnityEngine; + +// Reflection Extensions: +// • provides extension methods for handling reflection +// #reflection +public static class ReflectionExtensions +{ + public static Type asClassNameToType(this string className) + => Type.GetType(className); + + public static Assembly assembly(this Type type) + => type.Assembly; + + public static Type classNamed(this Assembly assembly, string className) + => assembly.GetType(className); + + public static FieldInfo fieldNamed(this Type type, string fieldName) + => type.GetField(fieldName); + public static FieldInfo fieldNamed(this Type type, string fieldName, BindingFlags bindingFlags) + => type.GetField(fieldName, bindingFlags); + public static FieldInfo publicInstanceFieldNamed(this Type type, string fieldName) + => type.GetField + ( + fieldName, + BindingFlags.Public | BindingFlags.Instance + ); + public static FieldInfo nonpublicInstanceFieldNamed(this Type type, string fieldName) + => type.GetField + ( + fieldName, + BindingFlags.NonPublic | BindingFlags.Instance + ); + + public static object valueOf(this object object_, FieldInfo field) + => field.GetValue(object_); + + public static PropertyInfo propertyNamed(this Type type, string propertyName) + => type.GetProperty(propertyName); + public static PropertyInfo propertyNamed(this Type type, string propertyName, BindingFlags bindingFlags) + => type.GetProperty(propertyName, bindingFlags); + public static PropertyInfo publicInstancePropertyNamed(this Type type, string propertyName) + => type.GetProperty + ( + propertyName, + BindingFlags.Public | BindingFlags.Instance + ); + public static PropertyInfo nonpublicInstancePropertyNamed(this Type type, string propertyName) + => type.GetProperty + ( + propertyName, + BindingFlags.NonPublic | BindingFlags.Instance + ); + + public static object valueOf(this object object_, PropertyInfo property) + => property.GetValue(object_); + + public static MethodInfo methodNamed(this Type type, string methodName) + => type.GetMethod(methodName); + public static MethodInfo methodNamed(this Type type, string methodName, BindingFlags bindingFlags) + => type.GetMethod(methodName, bindingFlags); + public static MethodInfo methodNamed(this Type type, string methodName, params Type[] parameterTypes) + => type.GetMethod(methodName, parameterTypes); + public static MethodInfo publicInstanceMethodNamed(this Type type, string methodName) + => type.GetMethod + ( + methodName, + BindingFlags.Public | BindingFlags.Instance + ); + public static MethodInfo nonpublicInstanceMethodNamed(this Type type, string methodName) + => type.GetMethod + ( + methodName, + BindingFlags.NonPublic | BindingFlags.Instance + ); + public static MethodInfo possiblyInheritedMethodNamed(this Type type, string methodName) + => type.GetMethod + ( + methodName, + BindingFlags.FlattenHierarchy + ); + public static MethodInfo possiblyInheritedPublicInstanceMethodNamed(this Type type, string methodName) + => type.GetMethod + ( + methodName, + BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Instance + ); + public static MethodInfo possiblyInheritedNonpublicInstanceMethodNamed(this Type type, string methodName) + => type.GetMethod + ( + methodName, + BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Instance + ); + + public static MethodInfo[] methods(this Type type) + => type.GetMethods(); + public static MethodInfo[] methods(this Type type, BindingFlags bindingFlags) + => type.GetMethods(bindingFlags); + public static MethodInfo[] possiblyInheritedPublicInstanceMethods(this Type type) + => type.methods(BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Instance); + + public static object invokeGetResult(this ObjectT object_, MethodInfo method) where ObjectT : class + => method.Invoke(object_, null); + public static object invokeGetResult(this ObjectT object_, MethodInfo method, params object[] parameters) where ObjectT : class + => method.Invoke(object_, parameters); + + public static ObjectT invoke(this ObjectT object_, MethodInfo method) where ObjectT : class + => object_.after(()=> + object_.invokeGetResult(method)); + public static ObjectT invoke(this ObjectT object_, MethodInfo method, params object[] parameters) where ObjectT : class + => object_.after(()=> + object_.invokeGetResult(method, parameters)); +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/ReflectionExtensions.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/ReflectionExtensions.cs.meta new file mode 100644 index 0000000..be552d1 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/ReflectionExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e34c32144d8ece44c9bc94661a4fd67a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/RendererExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/RendererExtensions.cs index c3e960f..bb0fe30 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/RendererExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/RendererExtensions.cs @@ -6,13 +6,13 @@ // Renderer Extensions: provides extension methods for handling renderers // public static class RendererExtensions { - #region game object's renderer enablement + #region setting enablement // method: set the enablement of this given game object's renderer to the given boolean, then return this given game object // public static GameObject setRendererEnablementTo(this GameObject gameObject, bool enablement) => gameObject.after(()=> gameObject.first().setEnablementTo(enablement)); - #endregion game object's renderer enablement + #endregion setting enablement #region setting materials diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/RequireComponentExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/RequireComponentExtensions.cs index cc1e9a6..141bb88 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/RequireComponentExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/RequireComponentExtensions.cs @@ -25,9 +25,9 @@ public static bool hasAnyRequireComponentAttributes_ViaAdditionalReflection(this public static bool requires_ViaAdditionalReflection(this Component component, Type potentiallyRequiredComponentType, bool considerInheritedRequireComponents = true) => component.hasAnyRequireComponentAttributes_ViaAdditionalReflection(requireComponentAttribute => ( - requireComponentAttribute.m_Type0.isAssignableFrom_ViaReflection(potentiallyRequiredComponentType) || - requireComponentAttribute.m_Type1.isAssignableFrom_ViaReflection(potentiallyRequiredComponentType) || - requireComponentAttribute.m_Type2.isAssignableFrom_ViaReflection(potentiallyRequiredComponentType) + potentiallyRequiredComponentType.inheritsIfYull_ViaReflection(requireComponentAttribute.m_Type0) || + potentiallyRequiredComponentType.inheritsIfYull_ViaReflection(requireComponentAttribute.m_Type1) || + potentiallyRequiredComponentType.inheritsIfYull_ViaReflection(requireComponentAttribute.m_Type2) ), considerInheritedRequireComponents); diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/RessingExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/RessingExtensions.cs new file mode 100644 index 0000000..06f5f3d --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/RessingExtensions.cs @@ -0,0 +1,21 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +// Ressing Extensions: +// • provides extension methods for ressing (as in the creation of (file) addresses or filepaths) +// #ressing +public static class RessingExtensions +{ + public static string ress(this string string_) + => string_+Ress.string_; + + public static string potentiallyPreressed(this string string_) + => string_.withPotentialPrefix(Ress.string_); + + public static string potentiallyPostressed(this string string_) + => string_.withPotentialSuffix(Ress.string_); + + public static string withPotentialRessingSuffix(this string string_, string suffix) + => string_+suffix.potentiallyPreressed(); +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/AddressExtensions.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/RessingExtensions.cs.meta similarity index 100% rename from Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/AddressExtensions.cs.meta rename to Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/RessingExtensions.cs.meta diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/SelectingAndPingingExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/SelectingAndPingingExtensions.cs new file mode 100644 index 0000000..583db10 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/SelectingAndPingingExtensions.cs @@ -0,0 +1,23 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +// Selecting And Pinging Extensions: +// • provides extension methods for selecting and pinging (in the editor) +// #selection #pinging +public static class SelectingAndPingingExtensions +{ + #region setting selection then pinging the selection + + // method: (if in the editor:) select and ping this given game object (if it's yull), then return this given game object // + public static GameObject selectAndPing_IfInEditor(this GameObject gameObject) + => gameObject.after(()=> + gameObject.select_IfInEditor().ping_IfInEditor(), + gameObject.isYull()); + // method: (if in the editor:) select and ping this given component's game object (if this given component and its game object are both yull), then return this given component // + public static ComponentT selectAndPing_IfInEditor(this ComponentT component) where ComponentT : Component + => component.after(()=> + component.gameObject.selectAndPing_IfInEditor(), + component.isYull() && component.gameObject.isYull()); + #endregion setting selection then pinging the selection +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/SelectingAndPingingExtensions.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/SelectingAndPingingExtensions.cs.meta new file mode 100644 index 0000000..b8183d3 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/SelectingAndPingingExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2b9fa9c6849095147bda9ff397ee9517 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/SelectionExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/SelectionExtensions.cs new file mode 100644 index 0000000..d46817b --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/SelectionExtensions.cs @@ -0,0 +1,60 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +// Selection Extensions: +// • provides extension methods for handling selection (in the editor) +// #selection +public static class SelectionExtensions +{ + #region determining selection + + #if UNITY_EDITOR + // method: return whether this given game object is currently selected in the hierarchy // + public static bool isSelected(this GameObject gameObject) + => UnityEditor.Selection.gameObjects.contains(gameObject); + #endif + + #if UNITY_EDITOR + // method: return whether this given game object is not currently selected in the hierarchy // + public static bool isNotSelected(this GameObject gameObject) + => !gameObject.isSelected(); + #endif + #endregion determining selection + + + #region setting selection + + // method: (if in the editor:) select this given game object, then return this given game object // + public static GameObject select_IfInEditor(this GameObject gameObject) + { + #if UNITY_EDITOR + if (UnityIs.inEditor) + { + return UnityEditor.Selection.activeGameObject = gameObject; + } + #endif + + return gameObject; + } + // method: (if in the editor:) select this given component's game object (if this given component and its game object are both yull), then return this given component // + public static ComponentT select_IfInEditor(this ComponentT component) where ComponentT : Component + => component.after(()=> + component.gameObject.select_IfInEditor(), + component.isYull() && component.gameObject.isYull()); + // method: (if in the editor:) select the uniques of these given game objects, then return the set of these given game objects // + public static HashSet selectUniques_IfInEditor(this IEnumerable gameObjects) + { + HashSet uniqueGameObjects = gameObjects.uniques(); + + #if UNITY_EDITOR + if (UnityIs.inEditor) + { + Select.only(uniqueGameObjects); + } + #endif + + return uniqueGameObjects; + } + #endregion setting selection +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/SelectionExtensions.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/SelectionExtensions.cs.meta new file mode 100644 index 0000000..264d738 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/SelectionExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f266e1f8086a72f48b68d24382a7ee5e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/SkinnedMeshRendererExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/SkinnedMeshRendererExtensions.cs new file mode 100644 index 0000000..3873a62 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/SkinnedMeshRendererExtensions.cs @@ -0,0 +1,10 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +// Skinned Mesh Renderer Extensions: +// • provides extension methods for handling skinned mesh renderers +public static class SkinnedMeshRendererExtensions +{ + +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/SkinnedMeshRendererExtensions.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/SkinnedMeshRendererExtensions.cs.meta new file mode 100644 index 0000000..d2a2046 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/SkinnedMeshRendererExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4ab498eaf99d5c74aabd9a1e3840c632 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/StringExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/StringExtensions.cs index c6afc11..64b47d7 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/StringExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/StringExtensions.cs @@ -42,7 +42,7 @@ public static bool isNotEmpty(this string string_) public static bool isEmptyOrNull(this string string_) => (string_.isNull() || string_.isEmpty()); - // method: return whether this given string is not empty nor null // + // method: return whether this given string is neither empty nor null // public static bool isNotEmptyNorNull(this string string_) => !string_.isEmptyOrNull(); @@ -54,11 +54,11 @@ public static string emptyIfNull(this string string_) public static string withNullRepresented(this string string_) => string_ ?? "null"; - // method: return this given string with a newline prefix if it is not empty nor null // + // method: return this given string with a newline prefix if it is neither empty nor null // public static string withPotentialPrefixedNewline(this string string_) => string_.withPotentialPrefix("\n"); - // method: return this given string with a newline suffix if it is not empty nor null // + // method: return this given string with a newline suffix if it is neither empty nor null // public static string withPotentialSuffixedNewline(this string string_) => string_.withPotentialSuffix("\n"); @@ -144,8 +144,10 @@ public static int indexAfterFirst(this string string_, string soughtString) #region replacing characters - public static string withReplaced(this string string_, string stringTemplateToReplace, string replacementString) - => string_.Replace(stringTemplateToReplace, replacementString); + public static string withReplaced(this string string_, string stringTemplateToReplace, string replacementString, bool boolean = true) + => boolean ? + string_.Replace(stringTemplateToReplace, replacementString) : + string_; #endregion replacing characters diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/TransformExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/TransformExtensions.cs index 2501eba..f4ebd1b 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/TransformExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/TransformExtensions.cs @@ -24,50 +24,6 @@ public static void destroyObject(this Transform transform) #endregion destruction - #region activity - - // method: return whether this given transform is active locally // - public static bool activeLocally(this Transform transform) - => transform.gameObject.activeLocally(); - - // method: return whether this given transform is active globally // - public static bool activeGlobally(this Transform transform) - => transform.gameObject.activeGlobally(); - - // method: set the activity of this given transform to the given boolean, then return this given transform // - public static Transform setActivityTo(this Transform transform, bool activity) - => transform.gameObject.setActivityTo(activity).transform; - - // method: activate this given transform, then return it // - public static Transform activate(this Transform transform) - => transform.gameObject.activate().transform; - - // method: deactivate this given transform, then return it // - public static Transform deactivate(this Transform transform) - => transform.gameObject.activate().transform; - - // method: toggle the activity of this given transform using the given toggling, then return this given transform // - public static Transform toggleActivityBy(this Transform transform, Toggling toggling) - => transform.gameObject.toggleActivityBy(toggling).transform; - - // method: toggle the activity of these given transforms using the given toggling, then return them // - public static Transform[] toggleActivityBy(this Transform[] transforms, Toggling toggling) - => transforms.forEach(transform => transform.toggleActivityBy(toggling)); - - // method: set the activity of these given transforms to the given boolean, then return them // - public static Transform[] setActivityTo(this Transform[] transforms, bool activity) - => transforms.forEach(transform => transform.setActivityTo(activity)); - - // method: activate these given transforms, then return them // - public static Transform[] activate(this Transform[] transforms) - => transforms.setActivityTo(true); - - // method: deactivate these given transforms, then return them // - public static Transform[] deactivate(this Transform[] transforms) - => transforms.setActivityTo(false); - #endregion activity - - #region calling local methods // method: execute all of this transform's game object's mono behaviours' defined methods (ignoring inherited methods that haven't been overriden) with the given name, then return this given game object // diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/TypeExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/TypeExtensions.cs index 477ec7e..6a60c8f 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/TypeExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/TypeExtensions.cs @@ -8,21 +8,71 @@ // #types #reflection public static class TypeExtensions { + #region interface determination + + // method: return whether the specified type is an interface // + public static bool isAnInterface(this Type type) + => type.IsInterface; + public static bool isNotAnInterface(this Type type) + => !type.isAnInterface(); + #endregion interface determination + + + #region inheritance determination + + // method: (via reflection:) return whether this given type is inherited by the other given type // + public static bool isInheritedBy_ViaReflection(this Type type, Type otherType) + => type.IsAssignableFrom(otherType); + // method: (via reflection:) return whether this given type is not inherited by the other given type // + public static bool isNotInheritedBy_ViaReflection(this Type type, Type otherType) + => !type.isInheritedBy_ViaReflection(otherType); + + // method: (via reflection:) return whether this given type inherits the other given type // + public static bool inherits_ViaReflection(this Type type, Type otherType) + => type.IsSubclassOf(otherType); + // method: (via reflection:) return whether this given type does not inherit the other given type // + public static bool doesNotInherit_ViaReflection(this Type type, Type otherType) + => !type.inherits_ViaReflection(otherType); + + // method: (via reflection:) return whether this given type inherits the other given type if that other given type is yull // + public static bool inheritsIfYull_ViaReflection(this Type type, Type otherType) + => otherType.isNull() || type.inherits_ViaReflection(otherType); + // method: (via reflection:) return whether this given type does not inherit the other given type if that other given type is yull // + public static bool doesNotInheritIfYull_ViaReflection(this Type type, Type otherType) + => !type.inheritsIfYull_ViaReflection(otherType); + #endregion inheritance determination + + + #region implementation determination + + // method: return whether this given type implements the specified interface type // + public static bool implements(this Type type) where I : class + { + if (Interfaces.doesNotInclude()) + { + return false.returnWithError(typeof(I).simpleClassName_ViaReflection()+" is not an interface"); + } + + return typeof(I).IsAssignableFrom(type); + } + public static bool doesNotImplement(this Type type) where I : class + => !type.implements(); + #endregion implementation determination + + #if UNITY_EDITOR // method: (via reflection:) return the project path of the script asset with this given script asset type (class of a script asset) // public static string projectPath_ViaReflection(this Type scriptAssetType) => Project.pathForScriptAssetType_ViaReflection(scriptAssetType); #endif + // method: (via reflection:) return the static property of this given type with the given name and the specified type // public static PropertyT getStaticProperty_ViaReflection(this Type type, string propertyName) => (PropertyT) type.GetProperty(propertyName).GetValue(null); + // method: (via reflection:) return the static field of this given type with the given name and the specified type // public static FieldT getStaticField_ViaReflection(this Type type, string propertyName) => (FieldT) type.GetField(propertyName).GetValue(null); - - // method: (via reflection:) return whether this given type is assignable from the other given type // - public static bool isAssignableFrom_ViaReflection(this Type type, Type otherType) - => type.isYull() && type.IsAssignableFrom(otherType); } \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/TypeOrObjectExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/TypeOrObjectExtensions.cs index 6b12706..2a0bf1b 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/TypeOrObjectExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/TypeOrObjectExtensions.cs @@ -129,6 +129,8 @@ public static bool hasAnySelfOrInheritedSimpleClassName_ViaReflection(this Type // method: (via reflection:) return whether this given object has any self or inherited simple class name for which the given function returns true // public static bool hasAnySelfOrInheritedSimpleClassName_ViaReflection(this ObjectT object_, Func function) => object_.accessSelfThenInheritedSimpleClassNames_ViaReflection().hasAny(function); + public static bool hasNoSelfOrInheritedSimpleClassName_ViaReflection(this ObjectT object_, Func function) + => !object_.hasAnySelfOrInheritedSimpleClassName_ViaReflection(function); // method: (via reflection:) return the (pascal) spaced simple class name of this given type // public static string spacedSimpleClassName_ViaReflection(this Type type) diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/UnityObjectExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/UnityObjectExtensions.cs index a912991..36416c7 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/UnityObjectExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/UnityObjectExtensions.cs @@ -1,11 +1,14 @@ using System; using System.Collections; using System.Collections.Generic; +#if UNITY_EDITOR +using UnityEditor; +#endif using UnityEngine; // Unity Object Extensions: // • provides extension methods for handling Unity objects -// #gameobject #component #destruction +// #unityobject #gameobject #component #destruction #assets public static class UnityObjectExtensions { #region destruction @@ -92,4 +95,17 @@ public static void destroy(this Component component, bool boolean = true) } #endregion public #endregion destruction + + + + + #region conversion + + + #if UNITY_EDITOR + // method: return the serialized object for this given Unity object // + public static SerializedObject asSerializedObject(this UnityEngine.Object object_) + => new SerializedObject(object_); + #endif + #endregion conversion } \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/VectorExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/VectorExtensions.cs index 5807d5d..596578f 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/VectorExtensions.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Extensions/VectorExtensions.cs @@ -108,7 +108,7 @@ public static bool isFinite(this Vector3 vector) // method: return whether this given vector is all zeroes // public static bool isZeroes(this Vector3 vector) - => (vector.x.isZero() && vector.y.isZero() && vector.z.isZero()); + => vector == FloatsVector.zeroes; // method: return whether this given vector is nonnegative // public static bool isNonnegative(this Vector3 vector) @@ -258,6 +258,12 @@ public static Vector3 average(this IEnumerable vectors) // method: return this given vector multiplied by the other given vector (axis-respectively) // public static Vector3 multiplyBy(this Vector3 vector, Vector3 otherVector) => new Vector3(vector.x * otherVector.x, vector.y * otherVector.y, vector.z * otherVector.z); + + public static float min(this Vector3 vector) + => vector.toArray().min(); + + public static float max(this Vector3 vector) + => vector.toArray().max(); #endregion math operations diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/CleanNullGameObjectsForComponentCachingUponChangingEditorMode.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/CleanNullGameObjectsForComponentCachingUponChangingEditorMode.cs index 080e7c5..11eafa4 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/CleanNullGameObjectsForComponentCachingUponChangingEditorMode.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/CleanNullGameObjectsForComponentCachingUponChangingEditorMode.cs @@ -10,7 +10,7 @@ public static class CleanNullGameObjectsForComponentCachingUponChangingEditorMod { static CleanNullGameObjectsForComponentCachingUponChangingEditorMode() { - EditorApplication.playModeStateChanged += cleanNullGameObjectsForComponentCaching; + Execute.atNextPlaymodeChange_IfInEditor(cleanNullGameObjectsForComponentCaching); } private static void cleanNullGameObjectsForComponentCaching(PlayModeStateChange playModeStateChange) diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/DeselectAtStart.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/DeselectAtStart.cs new file mode 100644 index 0000000..ddd9b95 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/DeselectAtStart.cs @@ -0,0 +1,24 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +// Deselect At Start: +// • at the start, deselects the (entire current) selection +// · this happens optionally based on (the opposite state of) Whether To Not Deselect At Start +[InitializeOnLoad] +public static class DeselectAtStart +{ + static DeselectAtStart() + { + Execute.atNextPlaymodeChange_IfInEditor(deselect); + } + + private static void deselect(PlayModeStateChange playModeStateChange) + { + if (!WhetherToNotDeselectAtStart.state && (playModeStateChange == PlayModeStateChange.EnteredPlayMode)) + { + Deselect.all(); + } + } +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/DeselectHierarchyAtStart.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/DeselectAtStart.cs.meta similarity index 100% rename from Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/DeselectHierarchyAtStart.cs.meta rename to Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/DeselectAtStart.cs.meta diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/DeselectHierarchyAtStart.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/DeselectHierarchyAtStart.cs deleted file mode 100644 index ba968dc..0000000 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/DeselectHierarchyAtStart.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; - -// Deselect Hierarchy At Start: -// • at the start, deselects the current hierarchy selection -// · this happens optionally based on (the opposite state of) Whether To Not Deselect Hierarchy At Start -[InitializeOnLoad] -public static class DeselectHierarchyAtStart -{ - static DeselectHierarchyAtStart() - { - EditorApplication.playModeStateChanged += deselectHierarchy; - } - - private static void deselectHierarchy(PlayModeStateChange playModeStateChange) - { - if (!WhetherToNotDeselectHierarchyAtStart.state && (playModeStateChange == PlayModeStateChange.EnteredPlayMode)) - { - Hierarchy.deselect(); - } - } -} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/PauseAtStart.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/PauseAtStart.cs index 1da5404..7383f76 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/PauseAtStart.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/PauseAtStart.cs @@ -11,7 +11,7 @@ public static class PauseAtStart { static PauseAtStart() { - EditorApplication.playModeStateChanged += pause; + Execute.atNextPlaymodeChange_IfInEditor(pause); } private static void pause(PlayModeStateChange playModeStateChange) diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/TabToSceneAtStart.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/TabToSceneAtStart.cs index a1a73e8..c9432d9 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/TabToSceneAtStart.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Changing Editor Mode/Editor/TabToSceneAtStart.cs @@ -11,7 +11,7 @@ public static class TabToSceneAtStart { static TabToSceneAtStart() { - EditorApplication.playModeStateChanged += tabToScene; + Execute.atNextPlaymodeChange_IfInEditor(tabToScene); } private static void tabToScene(PlayModeStateChange playModeStateChange) diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Compilation/WhenPlayingTemporarilyDisableCompiling.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Compilation/WhenPlayingTemporarilyDisableCompiling.cs deleted file mode 100644 index 4fc3550..0000000 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Compilation/WhenPlayingTemporarilyDisableCompiling.cs +++ /dev/null @@ -1,26 +0,0 @@ -#if UNITY_EDITOR -using System.Collections; -using System.Collections.Generic; -using UnityEditor; -using UnityEngine; - -// #compilation -[InitializeOnLoad] -public static class WhenPlayingTemporarilyDisableCompiling -{ - static WhenPlayingTemporarilyDisableCompiling() - { - EditorApplication.playModeStateChanged += playModeStateChange => - { - if (playModeStateChange == PlayModeStateChange.EnteredPlayMode) - { - EditorApplication.LockReloadAssemblies(); - } - else if (playModeStateChange == PlayModeStateChange.ExitingPlayMode) - { - EditorApplication.UnlockReloadAssemblies(); - } - }; - } -} -#endif \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Asset.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Asset.cs similarity index 83% rename from Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Asset.cs rename to Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Asset.cs index 49705f1..ca4eb3e 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Asset.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Asset.cs @@ -31,6 +31,15 @@ public static string[] ideesForPrefabAssetsFilteredBy(string filterString) + #region accessing particular assets + + public static string ideeForFirstAsset => ideesForAssets.first(); + public static string pathForFirstAsset => pathForAssetIdee(ideeForFirstAsset); + #endregion accessing particular assets + + + + #region conversion @@ -88,17 +97,25 @@ public static string filenameForAssetIdee(this string assetIdee) #region to assets // method: return the asset of the specified type at the given project path // - public static AssetT atProjectPathOfType(string projectPath) where AssetT : class - => AssetDatabase.LoadAssetAtPath(projectPath, typeof(AssetT)) as AssetT; + public static AssetT atProjectPathOfType(string projectPath) where AssetT : UnityEngine.Object + => AssetDatabase.LoadAssetAtPath(projectPath) as AssetT; // method: return the asset of the specified type at the given asset path // - public static AssetT atAssetPathOfType(string assetPath) where AssetT : class + public static AssetT atAssetPathOfType(string assetPath) where AssetT : UnityEngine.Object => atProjectPathOfType(Project.pathFor(assetPath)); + + // method: return the folder asset of the at the given asset path // + public static UnityEngine.Object folderAtAssetPath(string folderAssetPath) + => atAssetPathOfType(folderAssetPath); #endregion to assets #region to asset paths + // method: return the asset path for the asset with the given asset idee // + public static string pathForAssetIdee(string assetIdee) + => AssetDatabase.GUIDToAssetPath(assetIdee); + // method: return the asset path for the asset with the given title at the given asset address // public static string pathFor(string assetTitle, string assetAddress) => assetAddress.ress()+assetTitle; diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Asset.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Asset.cs.meta similarity index 100% rename from Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Asset.cs.meta rename to Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Asset.cs.meta diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Assets.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Assets.cs new file mode 100644 index 0000000..ec8b0bc --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Assets.cs @@ -0,0 +1,180 @@ +#if UNITY_EDITOR +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using UnityEditor; +using UnityEditor.IMGUI.Controls; +using UnityEngine; + +// Assets: +// • provides functionality for handling assets +// #assets +public static class Assets +{ + #region state + + + #region window + public static Type windowType_ViaReflection => EditorAssembly.classNamed("UnityEditor.ProjectBrowser"); + public static UnityEngine.Object ensuredWindow_ViaReflection + { + get + { + UnityEngine.Object[] assetsWindowsAlreadyOpen = Resources.FindObjectsOfTypeAll(windowType_ViaReflection); + + return Any.itemsIn(assetsWindowsAlreadyOpen) ? + assetsWindowsAlreadyOpen.first() : + New.assetsWindow_ViaReflection; + } + } + public static object treeViewControllerFor_ViaReflection(UnityEngine.Object assetsWindow) + => assetsWindow.valueOf(windowType_ViaReflection.nonpublicInstanceFieldNamed("m_FolderTree")); + public static object ensuredWindowTreeViewController_ViaReflection + => treeViewControllerFor_ViaReflection(ensuredWindow_ViaReflection); + public static object treeViewItemFor_ViaReflection(object treeViewController) + => TreeViews.itemFor_ViaReflection(instanceIdee, treeViewController); + public const string columnationEnumPropertyName = "m_ViewMode"; + #endregion window + + #region filepathing + public const string folderName = "Assets"; + public static string folderNameRess = folderName.ress(); + public const string projectPath = folderName; + public const string assetAddress = ""; + public const string assetPath = ""; + public static string address = Project.filepath; + public static string filepath = Project.filepathRess+folderName; + public static string filepathRess = filepath.ress(); + #endregion filepathing + + #region assethood + public static readonly UnityEngine.Object folder = Asset.folderAtAssetPath(assetPath); + #endregion assethood + + #region instancing + public static readonly int instanceIdee = folder.instanceIdee(); + #endregion instancing + #endregion state + + + + + + + + + #region accessing assets + + + public static UnityEngine.Object first + => Asset.atAssetPathOfType(Asset.pathForFirstAsset); + + // method: return the set of assets of the specified type corresponding to each of the given project paths // + public static HashSet atProjectPathsOfType(IEnumerable projectPaths) where AssetT : UnityEngine.Object + => projectPaths.pickUnique(projectPath => + Asset.atProjectPathOfType(projectPath)); + + // method: (via reflection:) return the set of assets of the specified type // + public static HashSet ofType_ViaReflection() where AssetT : UnityEngine.Object + => atProjectPathsOfType(Project.pathsForAssetsOfType_ViaReflection()); + // method: (via reflection:) return the list of assets of the specified type // + public static List manifestedOfType_ViaReflection() where AssetT : UnityEngine.Object + => ofType_ViaReflection().manifested(); + + // method: (via reflection:) return the set of assets not from the Moon Motion Toolkit that are of the specified type // + public static HashSet notFromMoonMotionToolkitOfType_ViaReflection() where AssetT : UnityEngine.Object + => atProjectPathsOfType(Project.pathsForNonMoonMotionToolkitAssetsOfType_ViaReflection()); + // method: (via reflection:) return the list of assets not from the Moon Motion Toolkit that are of the specified type // + public static List notFromMoonMotionToolkitManifestedOfType_ViaReflection() where AssetT : UnityEngine.Object + => notFromMoonMotionToolkitOfType_ViaReflection().manifested(); + #endregion accessing assets + + + + + + + + + #region methods + + + + + #region window manipulation + + #region columnation mode switching + public static void switchToTwoColumnsModeIn_ViaReflection(UnityEngine.Object assetsWindow) + { + if (assetsWindow.asSerializedObject().FindProperty(columnationEnumPropertyName).enumValueIndex != 1) + { + assetsWindow.invoke(windowType_ViaReflection.nonpublicInstanceMethodNamed("SetTwoColumns")); + } + } + public static void switchToTwoColumnsMode_ViaReflection() + => switchToTwoColumnsModeIn_ViaReflection(ensuredWindow_ViaReflection); + public static void switchToOneColumnModeIn_ViaReflection(UnityEngine.Object assetsWindow) + { + if (assetsWindow.asSerializedObject().FindProperty(columnationEnumPropertyName).enumValueIndex != 0) + { + assetsWindow.invoke(windowType_ViaReflection.nonpublicInstanceMethodNamed("SetOneColumn")); + } + } + public static void switchToOneColumnMode_ViaReflection() + => switchToOneColumnModeIn_ViaReflection(ensuredWindow_ViaReflection); + #endregion columnation mode switching + + #region folder opening + public static void openFolder_ViaReflection(string folderAssetPath) + { + UnityEngine.Object assetsWindowToUse = ensuredWindow_ViaReflection; + + // switch the assets window to use to "two columns" mode (since that mode is necessary for opening folders) // + switchToTwoColumnsModeIn_ViaReflection(assetsWindowToUse); + + assetsWindowToUse.invoke + ( + windowType_ViaReflection.nonpublicInstanceMethodNamed("ShowFolderContents"), + Instance.ideeForAssetPath(folderAssetPath), true + ); + } + public static void openFolder_ViaReflection() + => openFolder_ViaReflection(""); + #endregion folder opening + + // method: (via reflection:) collapse the assets (collapse all asset folders (those visible in the 'Project' window)) (– not including the 'Assets' folder) + // reference: https://forum.unity.com/threads/collapse-all-folders-in-project-all-gameobjects-in-hierarchy-editor-script.502256/ + public static void collapse_ViaReflection() + { + object treeViewController = ensuredWindowTreeViewController_ViaReflection; + object assetsTreeViewItem = treeViewItemFor_ViaReflection(treeViewController); + MethodInfo method_ChangeExpandedState + = TreeViews.controllerType_ViaReflection.nonpublicInstanceMethodNamed("ChangeExpandedState"); + treeViewController.invoke + ( + method_ChangeExpandedState, + assetsTreeViewItem, false, true + ); + treeViewController.invoke + ( + method_ChangeExpandedState, + assetsTreeViewItem, true, false + ); + } + #endregion window manipulation + + + #region ensuring assets + + public static void ensureFolderFor(string assetAddress) + { + if (!AssetDatabase.IsValidFolder(Assets.folderNameRess+assetAddress)) + { + AssetDatabase.CreateFolder(Assets.folderName, assetAddress); + } + } + #endregion ensuring assets + #endregion methods +} +#endif \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Assets.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Assets.cs.meta similarity index 100% rename from Assets/Plugins/Moon Motion Toolkit/Utilities/Explicit/Assets.cs.meta rename to Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Assets.cs.meta diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Clear.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Clear.cs index f964a9d..a7f062a 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Clear.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Clear.cs @@ -5,15 +5,12 @@ using UnityEditor; using UnityEngine; -// Clear: provides a method for clearing the console // +// Clear: provides methods for clearing things // public static class Clear { + // method: clear the console + // reference: https://answers.unity.com/questions/707636/clear-console-window.html public static void console_ViaReflection() - { - var assembly = Assembly.GetAssembly(typeof(SceneView)); - var type = assembly.GetType("UnityEditor.LogEntries"); - var method = type.GetMethod("Clear"); - method.Invoke(new object(), null); - } + => New.genericObject.invoke(typeof(SceneView).assembly().classNamed("UnityEditor.LogEntries").methodNamed("Clear")); } #endif \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Deselect.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Deselect.cs new file mode 100644 index 0000000..f183438 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Deselect.cs @@ -0,0 +1,16 @@ +#if UNITY_EDITOR +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +// Deselect: +// • provides methods for deselecting (in the editor) +public static class Deselect +{ + public static void all() + { + Select.onlyAssetsFolder(); + Select.only(New.arrayOf()); + } +} +#endif \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Deselect.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Deselect.cs.meta new file mode 100644 index 0000000..53cc894 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Deselect.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fab328e9979694041b91a06b167660d8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Layout.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Layout.cs index dec3768..bf10670 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Layout.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Layout.cs @@ -12,7 +12,7 @@ // #layouts public static class Layout { - public static Type type => Type.GetType("UnityEditor.WindowLayout,UnityEditor"); + public static Type type => "UnityEditor.WindowLayout,UnityEditor".asClassNameToType(); public static void saveAs(string assetName, string assetAddress = "Layouts") { diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Ping.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Ping.cs new file mode 100644 index 0000000..aa267a0 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Ping.cs @@ -0,0 +1,22 @@ +#if UNITY_EDITOR +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +// Ping: +// • provides methods for pinging (in the editor) +public static class Ping +{ + public static GameObject selectedGameObject() + => Selected.gameObject.ping_IfInEditor(); + public static HashSet selectedGameObjects() + => Selected.gameObjects.pingUniques_IfInEditor(); + + // method: ping the selected game object, have it log the given string, then return the selected game object // + public static GameObject selectedGameObjectLogging(string string_) + => selectedGameObject().log(string_); + // method: ping the selected game objects, have each selected game object log the given string, then return the set of selected game objects // + public static HashSet selectedGameObjectsEachLogging(string string_) + => selectedGameObjects().uniquesAfterAsEachObjectLogging(string_); +} +#endif \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Ping.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Ping.cs.meta new file mode 100644 index 0000000..de57899 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Ping.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7b34d1ff03629c54ebf309a7e9945899 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Plugins.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Plugins.cs new file mode 100644 index 0000000..b2feb4b --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Plugins.cs @@ -0,0 +1,13 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +// Plugins: +// • provides functionality for plugins +public static class Plugins +{ + public const string folderName = "Plugins"; + public static readonly string assetAddress = Assets.filepath; + public const string assetPath = folderName; + public static Object folder => Asset.folderAtAssetPath(assetPath); +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Plugins.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Plugins.cs.meta new file mode 100644 index 0000000..0b109e1 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Plugins.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 936c4bec50603724eb6266b163e8a0ee +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Select.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Select.cs new file mode 100644 index 0000000..15f74cd --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Select.cs @@ -0,0 +1,42 @@ +#if UNITY_EDITOR +using System.Collections; +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; + +// Select: +// • provides methods for selecting (in the editor) +// #selection +public static class Select +{ + #region given Unity objects + + // method: select only the given Unity objects, then return the set of the given Unity objects // + public static HashSet only(params Object[] objects) + { + Selection.objects = objects; + + return objects.uniques(); + } + public static HashSet only(IEnumerable objects) + => only(objects.toArray()); + public static Object only(Object object_) + => object_.after(()=> + only(object_.startEnumerable())); + #endregion given Unity objects + + + #region particular assets + + public static Object onlyFirstAsset() + => only(Assets.first); + + #region folders + public static Object onlyAssetsFolder() + => only(Assets.folder); + public static Object onlyPluginsFolder() + => only(Plugins.folder); + #endregion folders + #endregion particular assets +} +#endif \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Select.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Select.cs.meta new file mode 100644 index 0000000..a310898 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Select.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1c285cda016a3984b8d1bf426a9dd10e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Selected.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Selected.cs new file mode 100644 index 0000000..c52599c --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Selected.cs @@ -0,0 +1,17 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +// Selected: +// • provides functionality for handling that which is selected (in the editor) +// #selection +public static class Selected +{ + #region accessing selection + + // the (first) (currently) selected game object // + public static GameObject gameObject => UnityEditor.Selection.activeGameObject; + // the set of (currently) selected game objects // + public static HashSet gameObjects => UnityEditor.Selection.gameObjects.uniques(); + #endregion accessing selection +} \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Selected.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Selected.cs.meta new file mode 100644 index 0000000..f81ff47 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/Selected.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 86340eb784a4a7841bd8df5e7e35aad7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/TabTo.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/TabTo.cs index 395b3ee..412b875 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/TabTo.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Explicit/TabTo.cs @@ -7,8 +7,8 @@ // Tab To: provides methods for tabbing to editor windows // public static class TabTo { - private static void window() where SearchableEditorWindowT : SearchableEditorWindow - => EditorWindow.FocusWindowIfItsOpen(typeof(SearchableEditorWindowT)); + private static void window() where EditorWindowT : EditorWindow + => EditorWindow.FocusWindowIfItsOpen(typeof(EditorWindowT)); public static void scene() => window(); diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Extensions.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Extensions.meta new file mode 100644 index 0000000..6a91750 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Extensions.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 18f9509dc3dd5724e816748a33e61b8c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Extensions/EditorWindowExtensions.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Extensions/EditorWindowExtensions.cs new file mode 100644 index 0000000..8222f40 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Extensions/EditorWindowExtensions.cs @@ -0,0 +1,16 @@ +#if UNITY_EDITOR +using System.Collections; +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; + +// Editor Window Extensions: +// • provides extension methods for handling editor windows +public static class EditorWindowExtensions +{ + // method: show this given editor window, then return it // + public static EditorWindow show(this EditorWindow editorWindow) + => editorWindow.after(()=> + editorWindow.Show()); +} +#endif \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Extensions/EditorWindowExtensions.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Extensions/EditorWindowExtensions.cs.meta new file mode 100644 index 0000000..208c5d5 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Extensions/EditorWindowExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ff87144bb3169574e9530e2d6d55e107 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Hierarchy/Editor/HierarchyStyle.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Hierarchy/Editor/HierarchyStyle.cs index 5b952d2..bce377a 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Hierarchy/Editor/HierarchyStyle.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Hierarchy/Editor/HierarchyStyle.cs @@ -44,8 +44,8 @@ private static GUIStyle nameStyleInactiveLocally } } private static GUIStyle hierarchyNameStyle(this GameObject gameObject) - => gameObject.activeLocally() ? - (gameObject.activeGlobally() ? + => gameObject.isActiveLocally() ? + (gameObject.isActiveGlobally() ? nameStyleActive : nameStyleInactiveOnlyGlobally) : nameStyleInactiveLocally; @@ -64,9 +64,9 @@ public static GUIStyle layerStyle private static GUIStyle hierarchyLayerStyle(this GameObject gameObject) => layerStyle; - private static void stylizeHierarchy(int gameObjectIdee, Rect selectionRectangle) + private static void stylizeHierarchy(int gameObjectInstanceIdee, Rect selectionRectangle) { - GameObject gameObject = gameObjectIdee.gameObject(); + GameObject gameObject = gameObjectInstanceIdee.asInstanceIdeeToGameObject(); if (gameObject.exists()) { if (gameObject.isNotOnDefaultLayer()) diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/ClearConsole.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/ClearConsole.cs deleted file mode 100644 index 9c6a7b3..0000000 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/ClearConsole.cs +++ /dev/null @@ -1,17 +0,0 @@ -#if UNITY_EDITOR -using System.Reflection; -using UnityEditor; -using UnityEngine; - -// Clear Console: -// • provides a menubar command to clear the console -// • based on code from: https://answers.unity.com/questions/707636/clear-console-window.html -public static class ClearConsole -{ - [MenuItem("Status/Clear Console &%q")] - public static void clearConsole() - { - Clear.console_ViaReflection(); - } -} -#endif \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/ClearConsoleAndDeselect.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/ClearConsoleAndDeselect.cs deleted file mode 100644 index bf5fa21..0000000 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/ClearConsoleAndDeselect.cs +++ /dev/null @@ -1,17 +0,0 @@ -#if UNITY_EDITOR -using System.Reflection; -using UnityEditor; -using UnityEngine; - -// Clear Console: -// • provides a menubar command to clear the console and deselect -public static class ClearConsoleAndDeselect -{ - [MenuItem("Status/Clear Console And Deselect %q")] - public static void clearConsoleAndDeselect() - { - Clear.console_ViaReflection(); - Hierarchy.deselect(); - } -} -#endif \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/CreateNewObject.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/CreateNewObject.cs deleted file mode 100644 index 6661f7f..0000000 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/CreateNewObject.cs +++ /dev/null @@ -1,14 +0,0 @@ -#if UNITY_EDITOR -using System.Reflection; -using UnityEditor; -using UnityEngine; - -// Create New Object: -// • provides a menubar command to create a new object at the origin and select it -public static class CreateNewObject -{ - [MenuItem("Create/New Object (at origin) %e")] - public static void createNewObject() - => "New Object".createAsObject().resetPosition().selectInHierarchy_IfInEditor(); -} -#endif \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/FindMissingReferencesInScene.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/FindMissingReferencesInScene.cs index 61a7456..463f9a1 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/FindMissingReferencesInScene.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/FindMissingReferencesInScene.cs @@ -3,7 +3,7 @@ using UnityEngine; // Find Missing References In Scene: -// • provides a menubar command to log errors for each missing reference in the scene +// • provides a menubar operation to log errors for each missing reference in the scene // • based on code from: https://www.reddit.com/r/Unity3D/comments/2ogoaq/find_missing_references_in_the_unity_editor/cmnoge0?utm_source=share&utm_medium=web2x public static class FindMissingReferencesInScene { @@ -17,7 +17,7 @@ private static void logPropertyMissingReferenceError(string objectName, string p Debug.LogError("Missing reference found in: "+objectName+" - property: "+propertyName); } - [MenuItem("Status/Find Missing References In Scene %#q")] + [MenuItem("Macros/Find Missing References In Scene &%q")] public static void findMissingReferencesInScene() { bool issueFound = false; diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/MenubarMacros.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/MenubarMacros.cs new file mode 100644 index 0000000..f590211 --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/MenubarMacros.cs @@ -0,0 +1,36 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; + +// Menubar Macros: +// • provides various editor macros as menubar operations +public static class MenubarMacros +{ + [MenuItem("Macros/Clear Console %q")] + public static void clearConsole() + => Clear.console_ViaReflection(); + + [MenuItem("Macros/Freshen Layout %w")] + public static void freshenLayout() + { + Clear.console_ViaReflection(); + Assets.collapse_ViaReflection(); + Assets.openFolder_ViaReflection(); + Hierarchy.collapseAllObjects(); + Deselect.all(); + AutoBehaviours.validateAllInHierarchy(); + } + + [MenuItem("Macros/Create New Object (at origin) %e")] // (and select it) + public static void createNewObject() + => New.gameObject.select_IfInEditor(); + + [MenuItem("Macros/Open Build Folder &%#b")] + public static void openBuildFolder() + => Application.OpenURL("file://"+Build.folderPath); + + [MenuItem("Macros/Launch Build Executable &%b")] + public static void launchBuildExecutable() + => Application.OpenURL("file://"+Build.executablePath); +} +#endif \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/OpenBuild.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/MenubarMacros.cs.meta similarity index 100% rename from Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/OpenBuild.cs.meta rename to Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/MenubarMacros.cs.meta diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/OpenBuild.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/OpenBuild.cs deleted file mode 100644 index 61ea81a..0000000 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/OpenBuild.cs +++ /dev/null @@ -1,20 +0,0 @@ -#if UNITY_EDITOR -using System.Reflection; -using UnityEditor; -using UnityEngine; - -// Menubar Build: -// • provides menubar commands to: -// · open the build folder -// · launch the build executable -public static class MenubarBuild -{ - [MenuItem("Build/Open Folder &%#b")] - public static void openFolder() - => Application.OpenURL("file://"+Build.folderPath); - - [MenuItem("Build/Launch Executable &%b")] - public static void launchExecutable() - => Application.OpenURL("file://"+Build.executablePath); -} -#endif \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/ReloadLayout.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/ReloadLayout.cs deleted file mode 100644 index 50e79dc..0000000 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/ReloadLayout.cs +++ /dev/null @@ -1,13 +0,0 @@ -#if UNITY_EDITOR -using System.Reflection; -using UnityEditor; -using UnityEngine; - -// #layouts -public static class ReloadLayout -{ - [MenuItem("Status/Reload Layout &%#q")] - public static void reloadLayout() - => Layout.reload(); -} -#endif \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/ReloadLayout.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/ReloadLayout.cs.meta deleted file mode 100644 index a5dae96..0000000 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/ReloadLayout.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 04bbdddd60ca54a4c87330c50d78d3d7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/HierarchySelectionOperations.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/SelectionOperations.cs similarity index 64% rename from Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/HierarchySelectionOperations.cs rename to Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/SelectionOperations.cs index 84c3d53..757849c 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/HierarchySelectionOperations.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/SelectionOperations.cs @@ -4,27 +4,27 @@ using UnityEditor; using UnityEngine; -// Hierarchy Selection Operations: -// • provides menubar operations for the current hierarchy selection +// Selection Operations: +// • provides menubar operations for the (current) selection // #hierarchy -public static class HierarchySelectionOperations +public static class SelectionOperations { - #region operation methods for: hierarchy selection + #region operation methods for: selection [MenuItem("Selection/Deselect %#D")] public static void deselect() - => Hierarchy.deselect(); - #endregion operation methods for: hierarchy selection + => Deselect.all(); + #endregion operation methods for: selection #region operation methods for: game object activity [MenuItem("Selection/Toggle Activity %t")] public static void toggleActivity() - => Hierarchy.pingSelectedGameObjects().toggleActivity(); + => Ping.selectedGameObjects().toggleActivity(); [MenuItem("Selection/Toggle Activity %t", true)] public static bool toggleActivity_Validator() - => Hierarchy.selectedGameObject; + => Selected.gameObject; #endregion operation methods for: game object activity @@ -32,10 +32,10 @@ public static bool toggleActivity_Validator() [MenuItem("Selection/Reset Transformations %#r")] public static void resetTransformations() - => Hierarchy.pingSelectedGameObjects().resetLocalsForEach(); + => Ping.selectedGameObjects().resetLocalsForEach(); [MenuItem("Selection/Reset Transformations %#r", true)] public static bool resetTransformations_Validator() - => Hierarchy.selectedGameObject; + => Selected.gameObject; #endregion operation methods for: transformations @@ -43,10 +43,10 @@ public static bool resetTransformations_Validator() [MenuItem("Selection/Zero Velocities &%#r")] public static void zeroVelocities() - => Hierarchy.pingSelectedGameObjects().zeroVelocitiesOfEach(); + => Ping.selectedGameObjects().zeroVelocitiesOfEach(); [MenuItem("Selection/Zero Velocities &%#r", true)] public static bool zeroVelocities_Validator() - => Hierarchy.selectedGameObject; + => Selected.gameObject; #endregion operation methods for: velocities @@ -54,17 +54,17 @@ public static bool zeroVelocities_Validator() [MenuItem("Selection/Render Descendant Lights By Pixel")] public static void renderDescendantLightsByPixel() - => Hierarchy.pingSelectedGameObjectsEachLogging("rendering descendant lights by pixel").forEachRenderDescendantLightsByPixel(); + => Ping.selectedGameObjectsEachLogging("rendering descendant lights by pixel").forEachRenderDescendantLightsByPixel(); [MenuItem("Selection/Render Descendant Lights By Pixel", true)] public static bool renderDescendantLightsByPixel_Validator() - => Hierarchy.selectedGameObject; + => Selected.gameObject; [MenuItem("Selection/Render Descendant Lights By Vertex")] public static void renderDescendantLightsByVertex() - => Hierarchy.pingSelectedGameObjectsEachLogging("rendering descendant lights by vertex").forEachRenderDescendantLightsByVertex(); + => Ping.selectedGameObjectsEachLogging("rendering descendant lights by vertex").forEachRenderDescendantLightsByVertex(); [MenuItem("Selection/Render Descendant Lights By Vertex", true)] public static bool renderDescendantLightsByVertex_Validator() - => Hierarchy.selectedGameObject; + => Selected.gameObject; #endregion operation methods for: descendant lights } #endif \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/HierarchySelectionOperations.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/SelectionOperations.cs.meta similarity index 100% rename from Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/HierarchySelectionOperations.cs.meta rename to Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/SelectionOperations.cs.meta diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/WhetherToNotDeselectAtStart.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/WhetherToNotDeselectAtStart.cs new file mode 100644 index 0000000..5d4c83b --- /dev/null +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/WhetherToNotDeselectAtStart.cs @@ -0,0 +1,20 @@ +#if UNITY_EDITOR +using System.Collections; +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; + +// Whether To Not Deselect At Start: +// • determines whether Deselect At Start does not run +[InitializeOnLoad] +public static class WhetherToNotDeselectAtStart +{ + private const string menuItem = "At Start/Do Not Deselect &%#T"; + + public static bool state => Menu.GetChecked(menuItem); + + [MenuItem(menuItem)] + public static void toggleWhetherToNotDeselectAtStart() + => Menu.SetChecked(menuItem, !state); +} +#endif \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/WhetherToNotDeselectHierarchyAtStart.cs.meta b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/WhetherToNotDeselectAtStart.cs.meta similarity index 100% rename from Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/WhetherToNotDeselectHierarchyAtStart.cs.meta rename to Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/WhetherToNotDeselectAtStart.cs.meta diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/WhetherToNotDeselectHierarchyAtStart.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/WhetherToNotDeselectHierarchyAtStart.cs deleted file mode 100644 index 8d3ea69..0000000 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/WhetherToNotDeselectHierarchyAtStart.cs +++ /dev/null @@ -1,20 +0,0 @@ -#if UNITY_EDITOR -using System.Collections; -using System.Collections.Generic; -using UnityEditor; -using UnityEngine; - -// Whether To Not Deselect Hierarchy At Start: -// • determines whether Deselect Hierarchy At Start does not run -[InitializeOnLoad] -public static class WhetherToNotDeselectHierarchyAtStart -{ - private const string menuItem = "At Start/Do Not Deselect Hierarchy &%#T"; - - public static bool state => Menu.GetChecked(menuItem); - - [MenuItem(menuItem)] - public static void toggleWhetherToNotDeselectHierarchyAtStart() - => Menu.SetChecked(menuItem, !state); -} -#endif \ No newline at end of file diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/WhetherToShowCommonBehaviours.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/WhetherToShowCommonBehaviours.cs index a27c512..b87dec9 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/WhetherToShowCommonBehaviours.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Menubar/WhetherToShowCommonBehaviours.cs @@ -17,7 +17,8 @@ public static void setCheckednessTo(bool boolean) static WhetherToShowCommonBehaviours() { - EditorApplication.delayCall += ()=> setCheckednessTo(Build.includesDefine(define)); + Execute.atNextCheck_IfInEditor(()=> + setCheckednessTo(Build.includesDefine(define))); } public static bool state => Menu.GetChecked(menuItem); diff --git a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Warning/Editor/WarnIfMissingEther.cs b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Warning/Editor/WarnIfMissingEther.cs index f4bdd99..5dd4f9d 100644 --- a/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Warning/Editor/WarnIfMissingEther.cs +++ b/Assets/Plugins/Moon Motion Toolkit/Utilities/Unity Editor/Warning/Editor/WarnIfMissingEther.cs @@ -8,8 +8,8 @@ public static class WarnIfMissingEther { static WarnIfMissingEther() { - EditorApplication.delayCall += potentiallyWarn; - EditorApplication.playModeStateChanged += potentiallyWarn; + Execute.atNextCheck_IfInEditor(potentiallyWarn); + Execute.atNextPlaymodeChange_IfInEditor(potentiallyWarn); } private static void potentiallyWarn()