コード例 #1
0
        private void AddToolTip()
        {
            ToolTipBackgroundMesh ttb      = (ToolTipBackgroundMesh)target;
            ToolTip            tt          = ttb.gameObject.AddComponent <ToolTip>();
            SerializedProperty toolTipProp = serializedObject.FindProperty("toolTip");

            toolTipProp.objectReferenceValue = tt;
        }
コード例 #2
0
        private void CreateMeshRenderer()
        {
            ToolTipBackgroundMesh ttb = (ToolTipBackgroundMesh)target;
            ToolTip    tt             = ttb.GetComponent <ToolTip>();
            GameObject newBackground  = GameObject.CreatePrimitive(PrimitiveType.Quad);

            newBackground.name             = "ToolTip Background Mesh";
            newBackground.transform.parent = tt.ContentParentTransform;
            ttb.BackgroundRenderer         = newBackground.GetComponent <MeshRenderer>();
        }
コード例 #3
0
        public override void OnInspectorGUI()
        {
            ToolTipBackgroundMesh ttb = (ToolTipBackgroundMesh)target;
            ToolTip tt = ttb.GetComponent <ToolTip>();

            if (tt == null)
            {
                HUXEditorUtils.ErrorMessage("This component requires a ToolTip component to work.", AddToolTip, "Add ToolTip Component");
                HUXEditorUtils.SaveChanges(target, serializedObject);
                HUXEditorUtils.EndSectionBox();
                return;
            }

            SerializedProperty toolTipProp = serializedObject.FindProperty("toolTip");

            if (toolTipProp.objectReferenceValue == null)
            {
                toolTipProp.objectReferenceValue = tt;
            }

            HUXEditorUtils.BeginSectionBox("Background Components");
            ttb.BackgroundRenderer = HUXEditorUtils.DropDownComponentField <MeshRenderer>("Mesh Renderer", ttb.BackgroundRenderer, tt.ContentParentTransform);
            if (ttb.BackgroundRenderer == null)
            {
                HUXEditorUtils.ErrorMessage("You must select or create a mesh renderer under the tool tip's content parent.", CreateMeshRenderer, "Create Mesh Renderer");
                HUXEditorUtils.SaveChanges(target, serializedObject);
                HUXEditorUtils.EndSectionBox();
                return;
            }
            if (ttb.BackgroundTransform == null)
            {
                ttb.BackgroundTransform = ttb.BackgroundRenderer.transform;
            }
            else
            {
                ttb.BackgroundTransform = HUXEditorUtils.DropDownComponentField <Transform>("Transform", ttb.BackgroundTransform, tt.ContentParentTransform);
            }
            if (ttb.BackgroundTransform != ttb.BackgroundRenderer.transform)
            {
                HUXEditorUtils.WarningMessage("Not using the BackgroundRenderer's transform may result in unexpected behavior.", "Use BackgroundRenderer's transform", UseRendererTransform);
            }
            ttb.Depth = EditorGUILayout.FloatField("Mesh depth", ttb.Depth);
            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.SaveChanges(target, serializedObject);
        }
コード例 #4
0
        public override void OnInspectorGUI()
        {
            ShowToolTipsHelp = GUILayout.Toggle(ShowToolTipsHelp, "Show help");

            ToolTip tt          = (ToolTip)target;
            Type    toolTipType = tt.GetType();

            HUXEditorUtils.BeginSectionBox("Components");
            pivotProp         = serializedObject.FindProperty("pivot");
            anchorProp        = serializedObject.FindProperty("anchor");
            labelProp         = serializedObject.FindProperty("label");
            contentParentProp = serializedObject.FindProperty("contentParent");

            //HUXEditorUtils.ToolTip(ShowToolTipsHelp, toolTipType, "pivot");
            pivotProp.objectReferenceValue = HUXEditorUtils.DropDownGameObjectField("Pivot", pivotProp.objectReferenceValue as GameObject, tt.transform);
            //HUXEditorUtils.ToolTip(ShowToolTipsHelp, toolTipType, "anchor");
            anchorProp.objectReferenceValue = HUXEditorUtils.DropDownGameObjectField("Anchor", anchorProp.objectReferenceValue as GameObject, tt.transform);
            //HUXEditorUtils.ToolTip(ShowToolTipsHelp, toolTipType, "label");
            labelProp.objectReferenceValue = HUXEditorUtils.DropDownGameObjectField("Label", labelProp.objectReferenceValue as GameObject, tt.transform);
            //HUXEditorUtils.ToolTip(ShowToolTipsHelp, toolTipType, "contentParent");
            contentParentProp.objectReferenceValue = HUXEditorUtils.DropDownGameObjectField("Content Parent", contentParentProp.objectReferenceValue as GameObject, tt.transform);
            HUXEditorUtils.EndSectionBox();

            if (pivotProp.objectReferenceValue == null || anchorProp.objectReferenceValue == null || labelProp.objectReferenceValue == null || contentParentProp.objectReferenceValue == null)
            {
                HUXEditorUtils.ErrorMessage("Not all components were found. You can auto-generate these components if you like.", AutoGenerateComponents, "Auto-Generate Components");
                HUXEditorUtils.SaveChanges(target, serializedObject);
                return;
            }

            HUXEditorUtils.BeginSectionBox("Content");
            SerializedProperty backgroundPaddingProp = serializedObject.FindProperty("backgroundPadding");
            SerializedProperty backgroundOffsetProp  = serializedObject.FindProperty("backgroundOffset");
            SerializedProperty fontSizeProp          = serializedObject.FindProperty("fontSize");

            //HUXEditorUtils.ToolTip(ShowToolTipsHelp, toolTipType, "toolTipText");
            tt.ToolTipText = EditorGUILayout.TextArea(tt.ToolTipText);
            //HUXEditorUtils.ToolTip(ShowToolTipsHelp, toolTipType, "contentScale");
            tt.ContentScale = EditorGUILayout.Slider("Content Scale", tt.ContentScale, 0.01f, 3f);
            //HUXEditorUtils.ToolTip(ShowToolTipsHelp, toolTipType, "backgroundPadding");
            backgroundPaddingProp.vector2Value = EditorGUILayout.Vector2Field("Background padding", backgroundPaddingProp.vector2Value);
            //HUXEditorUtils.ToolTip(ShowToolTipsHelp, toolTipType, "backgroundOffset");
            backgroundOffsetProp.vector3Value = EditorGUILayout.Vector3Field("Background offset", backgroundOffsetProp.vector3Value);
            HUXEditorUtils.EndSectionBox();


            HUXEditorUtils.BeginSectionBox("State");
            GUILayout.Toggle(tt.IsOn, "Is On");
            tt.TipState = (ToolTip.TipDisplayModeEnum)EditorGUILayout.EnumPopup("Tip State", tt.TipState);
            EditorGUILayout.LabelField("Group Tip State: " + tt.GroupTipState);
            EditorGUILayout.LabelField("Master Tip State: " + tt.MasterTipState);
            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.BeginSectionBox("Additional components");
            SerializedProperty lineProp        = serializedObject.FindProperty("toolTipLine");
            SerializedProperty attachPointProp = serializedObject.FindProperty("attachPointType");


            lineProp.objectReferenceValue = HUXEditorUtils.DropDownComponentField <Line>("Line", lineProp.objectReferenceValue as Line, tt.transform, true);
            EditorGUILayout.PropertyField(attachPointProp);

            HoloToolkit.Unity.Billboard bb = tt.Pivot.GetComponent <HoloToolkit.Unity.Billboard>();
            if (bb == null)
            {
                if (GUILayout.Button("Add default billboard to content?"))
                {
                    bb           = tt.Pivot.AddComponent <HoloToolkit.Unity.Billboard>();
                    bb.PivotAxis = HoloToolkit.Unity.PivotAxis.Y;
                }
            }

            if (lineProp.objectReferenceValue == null)
            {
                Line line = tt.gameObject.GetComponent <Line>();
                if (line == null)
                {
                    if (GUILayout.Button("Add Default Line?"))
                    {
                        Line      toolTipLine         = tt.gameObject.AddComponent <Line>();
                        LineUnity toolTipLineRenderer = tt.gameObject.AddComponent <LineUnity>();
                        toolTipLineRenderer.Target = toolTipLine;
                    }
                }
                else
                {
                    lineProp.objectReferenceValue = line;
                }
            }
            ToolTipBackground[] backgrounds = tt.gameObject.GetComponents <ToolTipBackground>();
            if (backgrounds.Length == 0)
            {
                if (GUILayout.Button("Add Default Background?"))
                {
                    ToolTipBackgroundMesh toolTipBackground = tt.gameObject.AddComponent <ToolTipBackgroundMesh>();
                }
            }
            HUXEditorUtils.EndSectionBox();
            HUXEditorUtils.SaveChanges(target, serializedObject);
        }
コード例 #5
0
        private void UseRendererTransform()
        {
            ToolTipBackgroundMesh ttb = (ToolTipBackgroundMesh)target;

            ttb.BackgroundTransform = ttb.BackgroundRenderer.transform;
        }