public override void OnInspectorGUI()
        {
            EditorGUI.indentLevel = 0;
            serializedObject.Update();
            fader = (FadeObstructors)target;
            Commons.DrawTexture(ResourceHelper.LogoFadeObstructors);
            backColorOriginal  = GUI.backgroundColor;
            labelColorOriginal = GUI.contentColor;
            EditorGUILayout.Separator();
            Commons.SetColors(backColor, labelColor);

            EditorGUILayout.BeginVertical(EditorStyles.objectFieldThumb);
            // Transparent Material
            Material tmpMat = EditorGUILayout.ObjectField(new GUIContent("Transparent material", "The transparent material to use for the fading"), fader.transparentMaterial, typeof(Material), false) as Material;

            if (tmpMat != fader.transparentMaterial)
            {
                isDirty = true;
                Undo.RecordObject(fader, "Transparent material");
                fader.transparentMaterial = tmpMat;
            }
            // Replicate texture
            bool tmpBool = EditorGUILayout.Toggle(new GUIContent("Replicate texture", "Do we replicate the original texture on the transparent material?"), fader.replicateTexture);

            if (tmpBool != fader.replicateTexture)
            {
                isDirty = true;
                Undo.RecordObject(fader, "Replicate texture");
                fader.replicateTexture = tmpBool;
            }
            // Fading time
            float tmpFloat = EditorGUILayout.Slider(new GUIContent("Fading out time", "The time for fading out the material"), fader.fadingTime, 0.05f, 2f);

            if (tmpFloat != fader.fadingTime)
            {
                isDirty = true;
                Undo.RecordObject(fader, "Fading out time");
                fader.fadingTime = tmpFloat;
            }
            // Fading amount
            tmpFloat = EditorGUILayout.Slider(new GUIContent("Fading amount", "The fading amount"), fader.transparenceValue, 0f, 1f);
            if (tmpFloat != fader.transparenceValue)
            {
                isDirty = true;
                Undo.RecordObject(fader, "Fading amount");
                fader.transparenceValue = tmpFloat;
            }
            tmpBool = EditorGUILayout.Toggle(new GUIContent("Ignore Triggers", "Do not take into account any trigger"), fader.ignoreTriggers);
            if (tmpBool != fader.ignoreTriggers)
            {
                isDirty = true;
                Undo.RecordObject(fader, "Ignore triggers");
                fader.ignoreTriggers = tmpBool;
            }
            tmpBool = EditorGUILayout.Toggle(new GUIContent("Use SphereCast", "Cast a sphere instead of a ray"), fader.useSpherecast);
            if (tmpBool != fader.useSpherecast)
            {
                isDirty = true;
                Undo.RecordObject(fader, "Use SphereCast");
                fader.useSpherecast = tmpBool;
            }
            if (fader.useSpherecast)
            {
                float tmpRadius = EditorGUILayout.FloatField(new GUIContent("Sphere radius", "The radius of the sphere to cast"), fader.spherecastRadius);
                if (tmpRadius != fader.spherecastRadius)
                {
                    isDirty = true;
                    Undo.RecordObject(fader, "Sphere radius");
                    fader.spherecastRadius = tmpRadius;
                }
            }
            Commons.SetColors(backColorOriginal, labelColor);
            Color tmpColor = EditorGUILayout.ColorField(new GUIContent("Fade Color", "Color shade and alpha to use during the fading"), fader.fadingColorToUse);

            if (tmpColor != fader.fadingColorToUse)
            {
                isDirty = true;
                Undo.RecordObject(fader, "Fading Color");
                fader.fadingColorToUse = tmpColor;
            }
            Commons.SetColors(backColor, labelColor);
            LayerMask tmpMask = Commons.LayerMaskField(new GUIContent("Layers to fade", "The layers we want to fade. The layers we want to fade. IF YOU USE MULTIPLE INSTANCES OF THIS SCRIPT ON THE SASME CAMERA MAKE SURE THAT EACH INSTANCE MANAGES ONLY ITS OWN LAYERS!"), fader.layersToFade);

            if (tmpMask != fader.layersToFade)
            {
                isDirty = true;
                Undo.RecordObject(fader, "Layers to fade");
                fader.layersToFade = tmpMask;
            }
            SerializedProperty playerT = serializedObject.FindProperty("playerTransform");

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(playerT, new GUIContent("Player Transform", "The Transform of the Player"), true);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(target, "Player Transform");
                serializedObject.ApplyModifiedProperties();
            }
            tmpFloat = EditorGUILayout.Slider(new GUIContent("Raycast offset", "The distance off the target to avoid fading too much"), fader.offset, -2f, 0f);
            if (tmpFloat != fader.offset)
            {
                isDirty = true;
                Undo.RecordObject(fader, "Raycast offset");
                fader.offset = tmpFloat;
            }
            string tmpString = EditorGUILayout.TagField(new GUIContent("Player Tag", "Select the player's tag"), fader.playerTag);

            if (tmpString != fader.playerTag)
            {
                isDirty = true;
                Undo.RecordObject(fader, "Player Tag");
                fader.playerTag = tmpString;
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Separator();

            if (GUI.changed || isDirty)
            {
                EditorUtility.SetDirty(target); // or it won't save the data!!
            }
        }
예제 #2
0
        public override void OnInspectorGUI()
        {
            EditorGUI.indentLevel = 0;
            serializedObject.Update();
            fader = (FadeObstructorsVolumetric)target;
            Commons.DrawTexture(ResourceHelper.LogoFadeObstructorsVolumetric);
            backColorOriginal  = GUI.backgroundColor;
            labelColorOriginal = GUI.contentColor;
            EditorGUILayout.Separator();
            Commons.SetColors(backColor, labelColor);

            EditorGUILayout.BeginVertical(EditorStyles.objectFieldThumb);
            bool tmpBool = EditorGUILayout.Toggle(new GUIContent("Ignore Triggers", "Do not take into account any trigger"), fader.ignoreTriggers);

            if (tmpBool != fader.ignoreTriggers)
            {
                isDirty = true;
                Undo.RecordObject(fader, "Ignore triggers");
                fader.ignoreTriggers = tmpBool;
            }
            Commons.SetColors(backColorOriginal, labelColor);
            Color tmpColor = EditorGUILayout.ColorField(new GUIContent("Fade Color", "Color shade and alpha to use during the fading"), fader.fadingColorToUse);

            if (tmpColor != fader.fadingColorToUse)
            {
                isDirty = true;
                Undo.RecordObject(fader, "Fading Color");
                fader.fadingColorToUse = tmpColor;
            }
            Commons.SetColors(backColor, labelColor);
            LayerMask tmpMask = Commons.LayerMaskField(new GUIContent("Layers to fade", "The layers we want to fade. IF YOU USE MULTIPLE INSTANCES OF THIS SCRIPT ON THE SASME CAMERA MAKE SURE THAT EACH INSTANCE MANAGES ONLY ITS OWN LAYERS!"), fader.layersToFade);

            if (tmpMask != fader.layersToFade)
            {
                isDirty = true;
                Undo.RecordObject(fader, "Layers to fade");
                fader.layersToFade = tmpMask;
            }
            SerializedProperty playerT = serializedObject.FindProperty("playerTransform");

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(playerT, new GUIContent("Player Transform", "The Transform of the Player"), true);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(target, "Player Transform");
                serializedObject.ApplyModifiedProperties();
            }
            float tmpFloat = EditorGUILayout.Slider(new GUIContent("Volume offset", "The distance off the target to avoid fading too much"), fader.offset, -2f, 0f);

            if (tmpFloat != fader.offset)
            {
                isDirty = true;
                Undo.RecordObject(fader, "Volume offset");
                fader.offset = tmpFloat;
            }
            string tmpString = EditorGUILayout.TagField(new GUIContent("Player Tag", "Select the player's tag"), fader.playerTag);

            if (tmpString != fader.playerTag)
            {
                isDirty = true;
                Undo.RecordObject(fader, "Player Tag");
                fader.playerTag = tmpString;
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Separator();

            EditorGUILayout.BeginVertical(EditorStyles.objectFieldThumb);
            EditorGUILayout.Separator();
            tmpBool = EditorGUILayout.Toggle(new GUIContent("Common Volume", "Use the same volume for all instances of this script on this camera"), FadeObstructorsVolumetric.commonVolume);
            if (tmpBool != fader._commonVolume)
            {
                isDirty = true;
                Undo.RecordObject(fader, "Common Volume");
                fader._commonVolume = tmpBool;
                FadeObstructorsVolumetric.commonVolume = tmpBool;
            }
            EditorGUILayout.Separator();
            if (FadeObstructorsVolumetric.commonVolume)
            {
                tmpFloat = EditorGUILayout.Slider(new GUIContent("Common radius", "The radius of the unique capsule used as volume casting for all the instances if Common Volume is active. This should be fairly small"), FadeObstructorsVolumetric.commonRadius, 0.01f, 1f);
                if (tmpFloat != fader._commonRadius)
                {
                    isDirty = true;
                    Undo.RecordObject(fader, "Raycast offset");
                    fader._commonRadius = tmpFloat;
                    FadeObstructorsVolumetric.commonRadius = tmpFloat;
                }
                EditorGUILayout.Separator();
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.Separator();

            if (!FadeObstructorsVolumetric.commonVolume)
            {
                EditorGUILayout.BeginVertical(EditorStyles.objectFieldThumb);
                EditorGUILayout.Separator();
                tmpFloat = EditorGUILayout.Slider(new GUIContent("Volume radius", "The radius of the capsule used as volume casting. This should be fairly small"), fader.capsuleRadius, 0.01f, 1f);
                if (tmpFloat != fader.capsuleRadius)
                {
                    isDirty = true;
                    Undo.RecordObject(fader, "Raycast offset");
                    fader.capsuleRadius = tmpFloat;
                }
                EditorGUILayout.Separator();
                EditorGUILayout.EndVertical();
            }
            if (GUI.changed || isDirty)
            {
                EditorUtility.SetDirty(target); // or it won't save the data!!
            }
        }