Example #1
0
        protected virtual void OnEnable()
        {
            DrawAttachPoints = SessionState.GetBool(DrawAttachPointsKey, DrawAttachPoints);
            DrawHandles      = SessionState.GetBool(DrawHandlesKey, DrawHandles);
            EditAttachPoint  = SessionState.GetBool(EditAttachPointKey, EditAttachPoint);

            basicSettingsFoldout   = SessionState.GetBool(BasicSettingsFoldoutKey, basicSettingsFoldout);
            groupSettingsFoldout   = SessionState.GetBool(GroupSettingsFoldoutKey, groupSettingsFoldout);
            contentSettingsFoldout = SessionState.GetBool(ContentSettingsFoldoutKey, contentSettingsFoldout);
            editorSettingsFoldout  = SessionState.GetBool(EditorSettingsFoldoutKey, editorSettingsFoldout);
            objectSettingsFoldout  = SessionState.GetBool(ObjectSettingsFoldoutKey, objectSettingsFoldout);

            externalPlot = (ExternalPlot)target;

            serializedObject.ApplyModifiedProperties();
        }
Example #2
0
        protected virtual void OnSceneGUI()
        {
            if (DrawAttachPoints)
            {
                Handles.color = Color.Lerp(Color.clear, Color.red, 0.5f);
                float scale = externalPlot.ContentScale * 0.01f;

                ToolTipUtility.GetAttachPointPositions(ref localAttachPointPositions, externalPlot.LocalContentSize);
                foreach (Vector3 attachPoint in localAttachPointPositions)
                {
                    Handles.SphereHandleCap(0, externalPlot.ContentParentTransform.TransformPoint(attachPoint), Quaternion.identity, scale, EventType.Repaint);
                }
            }

            if (DrawHandles)
            {
                ExternalPlot externalPlot = (ExternalPlot)target;
                float        handleSize   = 0;
                float        arrowSize    = 0;

                BaseMixedRealityLineDataProvider line = externalPlot.GetComponent <BaseMixedRealityLineDataProvider>();
                if (line == null)
                {
                    Handles.color = Color.white;
                    Handles.DrawDottedLine(externalPlot.AnchorPosition, externalPlot.AttachPointPosition, 5f);
                }

                EditorGUI.BeginChangeCheck();

                Handles.color = Color.cyan;
                handleSize    = HandleUtility.GetHandleSize(externalPlot.PivotPosition) * handleSizeMultiplier;
                arrowSize     = handleSize * 2;
                Vector3 newPivotPosition = Handles.FreeMoveHandle(externalPlot.PivotPosition, Quaternion.identity, handleSize, Vector3.zero, Handles.SphereHandleCap);
                Handles.ArrowHandleCap(0, newPivotPosition, Quaternion.LookRotation(Vector3.up), arrowSize, EventType.Repaint);
                Handles.ArrowHandleCap(0, newPivotPosition, Quaternion.LookRotation(Vector3.forward), arrowSize, EventType.Repaint);
                Handles.ArrowHandleCap(0, newPivotPosition, Quaternion.LookRotation(Vector3.right), arrowSize, EventType.Repaint);

                Handles.color = Color.white;
                Handles.Label(newPivotPosition + (Vector3.up * arrowSize), "Pivot", EditorStyles.whiteLabel);

                Handles.color = Color.cyan;
                handleSize    = HandleUtility.GetHandleSize(externalPlot.AnchorPosition) * handleSizeMultiplier;
                arrowSize     = handleSize * 2;
                Vector3 newAnchorPosition = Handles.FreeMoveHandle(externalPlot.AnchorPosition, Quaternion.identity, HandleUtility.GetHandleSize(externalPlot.AnchorPosition) * handleSizeMultiplier, Vector3.zero, Handles.SphereHandleCap);
                Handles.ArrowHandleCap(0, newAnchorPosition, Quaternion.LookRotation(Vector3.up), arrowSize, EventType.Repaint);
                Handles.ArrowHandleCap(0, newAnchorPosition, Quaternion.LookRotation(Vector3.forward), arrowSize, EventType.Repaint);
                Handles.ArrowHandleCap(0, newAnchorPosition, Quaternion.LookRotation(Vector3.right), arrowSize, EventType.Repaint);

                Handles.color = Color.white;
                Handles.Label(newAnchorPosition + (Vector3.up * arrowSize), "Anchor", EditorStyles.whiteLabel);

                if (EditorGUI.EndChangeCheck())
                {
                    if (newAnchorPosition != externalPlot.AnchorPosition)
                    {
                        Undo.RegisterCompleteObjectUndo(externalPlot.Anchor.transform, "Moved Anchor");
                        externalPlot.Anchor.transform.position = newAnchorPosition;
                    }

                    if (newPivotPosition != externalPlot.PivotPosition)
                    {
                        Undo.RegisterCompleteObjectUndo(externalPlot.Pivot.transform, "Moved Pivot");
                        externalPlot.Pivot.transform.position = newPivotPosition;
                    }
                }

                if (EditAttachPoint)
                {
                    EditorGUI.BeginChangeCheck();

                    Handles.color = Color.cyan;
                    handleSize    = HandleUtility.GetHandleSize(externalPlot.AttachPointPosition) * handleSizeMultiplier;
                    arrowSize     = handleSize * 2;
                    Vector3 newAttachPointPosition = Handles.FreeMoveHandle(externalPlot.AttachPointPosition, Quaternion.identity, HandleUtility.GetHandleSize(externalPlot.AttachPointPosition) * handleSizeMultiplier, Vector3.zero, Handles.SphereHandleCap);
                    Handles.ArrowHandleCap(0, newAttachPointPosition, Quaternion.LookRotation(Vector3.up), arrowSize, EventType.Repaint);
                    Handles.ArrowHandleCap(0, newAttachPointPosition, Quaternion.LookRotation(Vector3.forward), arrowSize, EventType.Repaint);
                    Handles.ArrowHandleCap(0, newAttachPointPosition, Quaternion.LookRotation(Vector3.right), arrowSize, EventType.Repaint);

                    Handles.color = Color.white;
                    Handles.Label(newAttachPointPosition + (Vector3.up * arrowSize), "Attach Point", EditorStyles.whiteLabel);

                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(externalPlot, "Moved Attach Point");
                        Undo.RegisterCompleteObjectUndo(externalPlot.Anchor.transform, "Moved Attach Point");
                        externalPlot.AttachPointPosition = newAttachPointPosition;
                    }
                }
            }
        }