コード例 #1
0
    public override void OnInspectorGUI()
    {
        SimpleHelvetica targetSH = (target as SimpleHelvetica);         // find target component

        if (!targetSH.enabled)
        {
            if (GUILayout.Button("Edit Text", GUILayout.MaxWidth(120)))
            {
                targetSH.EnableSelf();
            }
        }
        else
        {
            GUILayout.Label("Text");
            EditorGUILayout.HelpBox("- WARNING: Changing text will reset individual character transform changes\n- Multiple lines supported\n- Undo not supported for this Text area", MessageType.None);
            targetSH.Text             = EditorGUILayout.TextArea((target as SimpleHelvetica).Text);
            targetSH.CharacterSpacing = EditorGUILayout.FloatField("Character Spacing", (target as SimpleHelvetica).CharacterSpacing);
            targetSH.LineSpacing      = EditorGUILayout.FloatField("Line Spacing", (target as SimpleHelvetica).LineSpacing);
            targetSH.SpaceWidth       = EditorGUILayout.FloatField("Space Width", (target as SimpleHelvetica).SpaceWidth);

            //tell SimpleHelvetica.cs that something has changed (so it runs ManualUpdate() ) when Text | variables are modified
            if (targetSH.Text != PrevFrameText ||
                targetSH.CharacterSpacing != PrevFrameCharacterSpacing ||
                targetSH.LineSpacing != PrevFrameLineSpacing ||
                targetSH.SpaceWidth != PrevFrameSpaceWidth)
            {
                PrevFrameText             = targetSH.Text;
                PrevFrameCharacterSpacing = targetSH.CharacterSpacing;
                PrevFrameLineSpacing      = targetSH.LineSpacing;
                PrevFrameSpaceWidth       = targetSH.SpaceWidth;
                targetSH.GenerateText();
            }

            //DrawDefaultInspector();

            /*
             * if (!targetSH.UpdateInRealtime){
             * if(GUILayout.Button("Update Text", GUILayout.MaxWidth(120))) {
             *              targetSH.GenerateText();
             * }
             * }
             */


            EditorGUILayout.Space();
            if (GUILayout.Button("Apply\nMesh Renderer\nSettings", GUILayout.MaxWidth(120)))
            {
                targetSH.ApplyMeshRenderer();
            }
            EditorGUILayout.HelpBox("Cannot Undo when Applying Mesh Renderer Settings", MessageType.None);
        }
    }
コード例 #2
0
    public override void OnInspectorGUI()
    {
                #if UNITY_EDITOR
        SimpleHelvetica targetSH = (target as SimpleHelvetica);         // find target component

        if (!targetSH.enabled)
        {
            if (GUILayout.Button("Edit Text", GUILayout.MaxWidth(120)))
            {
                targetSH.EnableSelf();
            }
        }
        else
        {
            GUILayout.Label("Text");
            EditorGUILayout.HelpBox("- WARNING: Changing text will reset individual character transform changes\n- Multiple lines supported\n- Undo not supported for this Text area", MessageType.None);
            targetSH.Text             = EditorGUILayout.TextArea((target as SimpleHelvetica).Text);
            targetSH.CharacterSpacing = EditorGUILayout.FloatField("Character Spacing", (target as SimpleHelvetica).CharacterSpacing);
            targetSH.LineSpacing      = EditorGUILayout.FloatField("Line Spacing", (target as SimpleHelvetica).LineSpacing);
            targetSH.SpaceWidth       = EditorGUILayout.FloatField("Space Width", (target as SimpleHelvetica).SpaceWidth);

            //tell SimpleHelvetica.cs that something has changed (so it runs ManualUpdate() ) when Text | variables are modified
            if (targetSH.Text != PrevFrameText ||
                targetSH.CharacterSpacing != PrevFrameCharacterSpacing ||
                targetSH.LineSpacing != PrevFrameLineSpacing ||
                targetSH.SpaceWidth != PrevFrameSpaceWidth)
            {
                PrevFrameText             = targetSH.Text;
                PrevFrameCharacterSpacing = targetSH.CharacterSpacing;
                PrevFrameLineSpacing      = targetSH.LineSpacing;
                PrevFrameSpaceWidth       = targetSH.SpaceWidth;
                targetSH.GenerateText();
            }

            //DrawDefaultInspector();

            /*
             * if (!targetSH.UpdateInRealtime){
             * if(GUILayout.Button("Update Text", GUILayout.MaxWidth(120))) {
             *              targetSH.GenerateText();
             * }
             * }
             */
            EditorGUILayout.Space();

            if (!targetSH.BoxColliderAdded)
            {
                if (GUILayout.Button("+ Box Colliders", GUILayout.MaxWidth(120)))
                {
                    targetSH.AddBoxCollider();
                }
            }

            if (targetSH.BoxColliderAdded)
            {
                if (GUILayout.Button("- Box Colliders", GUILayout.MaxWidth(120)))
                {
                    targetSH.RemoveBoxCollider();
                }
                targetSH.BoxColliderIsTrigger = EditorGUILayout.Toggle("Is Trigger", (target as SimpleHelvetica).BoxColliderIsTrigger);
                //if(GUILayout.Button("Update Box Collider", GUILayout.MaxWidth(120))) {
                targetSH.SetBoxColliderVariables();
                //}
            }

            EditorGUILayout.Space();

            if (!targetSH.RigidbodyAdded)
            {
                if (GUILayout.Button("+ Rigidbody", GUILayout.MaxWidth(120)))
                {
                    targetSH.AddRigidbody();
                }
            }

            if (targetSH.RigidbodyAdded)
            {
                if (GUILayout.Button("- Rigidbody", GUILayout.MaxWidth(120)))
                {
                    targetSH.RemoveRigidbody();
                }
                EditorGUILayout.HelpBox("Press \"Update Rigidbody\" to apply changes\nPress \"Reset Rigidbody\" to revert to default values", MessageType.None);

                DrawDefaultInspector();

                if (GUILayout.Button("Update Rigidbody", GUILayout.MaxWidth(120)))
                {
                    targetSH.SetRigidbodyVariables();
                }

                if (GUILayout.Button("Reset Rigidbody", GUILayout.MaxWidth(120)))
                {
                    targetSH.ResetRigidbodyVariables();
                }
            }


            EditorGUILayout.Space();
            if (GUILayout.Button("Apply\nMesh Renderer\nSettings", GUILayout.MaxWidth(120)))
            {
                targetSH.ApplyMeshRenderer();
            }
            EditorGUILayout.HelpBox("Cannot Undo when Applying Mesh Renderer Settings", MessageType.None);
        }
                #endif
    }