Exemple #1
0
        public override void OnInspectorGUI()
        {
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("VRSF Parameters", EditorStyles.boldLabel);
            EditorGUILayout.Space();

            Undo.RecordObject(button.gameObject, "Add BoxCollider");

            if (button.gameObject.GetComponent <BoxCollider>() != null)
            {
                button.SetColliderAuto = EditorGUILayout.ToggleLeft("Set Box Collider Automatically", button.SetColliderAuto);
            }
            else
            {
                EditorGUILayout.LabelField("This option required a BoxCollider Component.", EditorStyles.miniLabel);
                button.SetColliderAuto = false;
                button.SetColliderAuto = EditorGUILayout.ToggleLeft("Set Box Collider Automatically", false);

                // Add a button to replace the collider by a BoxCollider2D
                if (GUILayout.Button("Add BoxCollider"))
                {
                    button.gameObject.AddComponent <BoxCollider>();
                    DestroyImmediate(button.GetComponent <Collider>());
                    button.SetColliderAuto = true;
                }
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Basic Button Parameters", EditorStyles.boldLabel);

            EditorGUILayout.Space();

            base.OnInspectorGUI();

            serializedObject.ApplyModifiedProperties();
            serializedObject.Update();
        }
Exemple #2
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("VRDF Parameters", EditorStyles.boldLabel);
            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();
            Undo.RecordObject(_button.gameObject, "Add BoxCollider");

            if (_button.gameObject.GetComponent <BoxCollider>() != null)
            {
                EditorGUILayout.LabelField("Set Box Collider Automatically", EditorStyles.miniBoldLabel);
                EditorGUILayout.PropertyField(_setColliderAuto);
                CheckEndChanges();
            }
            else
            {
                EditorGUILayout.LabelField("This option required a BoxCollider Component.", EditorStyles.miniLabel);
                _button.SetColliderAuto = false;
                _button.SetColliderAuto = EditorGUILayout.ToggleLeft("Set Box Collider Automatically", false);

                // Add a button to replace the collider by a BoxCollider2D
                if (GUILayout.Button("Add BoxCollider"))
                {
                    DestroyImmediate(_button.GetComponent <Collider>());
                    _button.gameObject.AddComponent <BoxCollider>();
                    _button.SetColliderAuto = true;
                }
            }

            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();
            Undo.RecordObject(_button, "LaserClickable");
            EditorGUILayout.LabelField("Clickable using Laser Pointer with Click", EditorStyles.miniBoldLabel);
            EditorGUILayout.PropertyField(_clickableWithRaycast);
            CheckEndChanges();

            EditorGUI.BeginChangeCheck();
            Undo.RecordObject(_button, "MeshClickable");
            EditorGUILayout.LabelField("Clickable using Controllers' meshes", EditorStyles.miniBoldLabel);
            EditorGUILayout.PropertyField(_clickableUsingControllers);
            CheckEndChanges();

            EditorGUILayout.Space();

            // Add a button to call the OnClick Event if the application is playing
            if (Application.isPlaying && GUILayout.Button("Invoke OnClick Event"))
            {
                _button.onClick.Invoke();
            }

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Basic Button Parameters", EditorStyles.boldLabel);

            EditorGUILayout.Space();

            base.OnInspectorGUI();

            EditorGUI.BeginChangeCheck();
            Undo.RecordObject(_button, "OnHoverEvent");
            EditorGUILayout.PropertyField(_onHoverEvent);
            CheckEndChanges();

            EditorGUI.BeginChangeCheck();
            Undo.RecordObject(_button, "OnStopHoverEvent");
            EditorGUILayout.PropertyField(_onStopHoverEvent);
            CheckEndChanges();
        }