diff --git a/Assets/Scripts/Editor.meta b/Assets/Scripts/Editor.meta new file mode 100644 index 0000000..693a207 --- /dev/null +++ b/Assets/Scripts/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 961ab1cb357b32f4e96861e3f4e1dd36 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Editor/AnchoredObjectEditor.cs b/Assets/Scripts/Editor/AnchoredObjectEditor.cs new file mode 100644 index 0000000..35ccac3 --- /dev/null +++ b/Assets/Scripts/Editor/AnchoredObjectEditor.cs @@ -0,0 +1,41 @@ +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; + +[CustomEditor(typeof(AnchoredObject))] +public class AnchoredObjectEditor : Editor +{ + [Header("Connect via editor")] + Anchor myAnchor; + Anchor partnerAnchor; + bool matchScales = true; + + public override void OnInspectorGUI() + { + DrawDefaultInspector(); + + EditorGUILayout.Space(); + EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); + EditorGUILayout.LabelField("Connect the anchors directly via the editor", EditorStyles.boldLabel); + EditorGUILayout.Space(); + + myAnchor = (Anchor) EditorGUILayout.ObjectField("My Anchor", myAnchor, typeof(Anchor), true); + partnerAnchor = (Anchor) EditorGUILayout.ObjectField("Partner Anchor", partnerAnchor, typeof(Anchor), true); + matchScales = EditorGUILayout.Toggle("Match Scales?", matchScales); + + AnchoredObject obj = (AnchoredObject)target; + + if (GUILayout.Button("Connect anchors")) + { + if (!myAnchor || !partnerAnchor) + { + Debug.LogWarning("Anchors not assigned", this); + return; + } + obj.AnchorTo(myAnchor, partnerAnchor, matchScales); + } + } +} + + +#endif \ No newline at end of file diff --git a/Assets/Scripts/Editor/AnchoredObjectEditor.cs.meta b/Assets/Scripts/Editor/AnchoredObjectEditor.cs.meta new file mode 100644 index 0000000..72c9289 --- /dev/null +++ b/Assets/Scripts/Editor/AnchoredObjectEditor.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 28dbead944bac384f8bd3e8a1975b1d5 \ No newline at end of file