コード例 #1
0
        protected override void RefreshFields()
        {
            if (kelvinTexture != null)
            {
                kelvinTexture = CreateKelvinGradientTexture("KelvinGradientTexture", 300, 16, 1000f, 20000f);
            }

            Type gameView = TypeUtility.GetTypeByName("GameView");

            repaintAll = gameView.GetMethod("RepaintAll", BindingFlags.Static | BindingFlags.Public);

            Type type = typeof(Light);

            if (Instances == null || Instances.Length == 0)
            {
                return;
            }

            SerializedObject so = new SerializedObject(Instances.Cast <UnityEngine.Object>().ToArray());

            lightType = new InspectorField(type, Instances, type.GetProperty("type"),
                                           new DescriptorAttribute("Type", "The type of the light.", "http://docs.unity3d.com/ScriptReference/Light-type.html"));

            Fields.Add(lightType);

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("range"),
                                          new ReadOnlyAttribute(new ReadOnlyAttribute.ReadOnlyDelegate(IsArea)),
                                          new InspectAttribute(new InspectAttribute.InspectDelegate(IsDirectional), false),
                                          new DescriptorAttribute("Range", "The range of the light.", "http://docs.unity3d.com/ScriptReference/Light-range.html")));

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("spotAngle"),
                                          new InspectAttribute(new InspectAttribute.InspectDelegate(IsSpot)),
                                          new DescriptorAttribute("Spot Angle", "The angle of the light's spotlight cone in degrees.", "http://docs.unity3d.com/ScriptReference/Light-spotAngle.html")));

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("areaSize"),
                                          new InspectAttribute(new InspectAttribute.InspectDelegate(IsArea)),
                                          new DescriptorAttribute("Area Size", "The size of the area light. Editor only.", "http://docs.unity3d.com/ScriptReference/Light-areaSize.html")));

            Fields.Add(new InspectorField(type, Instances, so.FindProperty("m_UseColorTemperature"),
                                          new InspectAttribute(new InspectAttribute.InspectDelegate(AllowTemperature)),
                                          new DescriptorAttribute("Use Temperature", "Allow this light to use Kelvin Temperature.", "https://docs.unity3d.com/ScriptReference/Light-colorTemperature.html")));

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("color"),
                                          new MenuAttribute("Temperature Lighting", new MenuAttribute.MenuDelegate(ToggleTemperatureLighting), null, AllowTemperature),
                                          new DescriptorAttribute("Color", "The color of the light.", "http://docs.unity3d.com/ScriptReference/Light-color.html")));

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("colorTemperature"),
                                          new InspectAttribute(new InspectAttribute.InspectDelegate(ShowTemperature)),
                                          new DescriptorAttribute("Temperature", "Also known as CCT (Correlated color temperature).The color temperature of the electromagnetic radiation emitted from an ideal black body is defined as its surface temperature in Kelvin.White is 6500K", "https://docs.unity3d.com/ScriptReference/Light-colorTemperature.html")));

            lightBaking = new InspectorField(type, Instances, type.GetProperty("lightmapBakeType"),
                                             new InspectAttribute(new InspectAttribute.InspectDelegate(IsArea), false),
                                             new HelpAttribute(new HelpAttribute.HelpDelegate(LightmapModeWarning)),
                                             new DescriptorAttribute("Mode", "This property describes what part of a light's contribution can be baked.", "http://docs.unity3d.com/ScriptReference/Light-type.html"));

            Fields.Add(lightBaking);

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("intensity"),
                                          new RangeValueAttribute(0f, 8f),
                                          new DescriptorAttribute("Intensity", "The Intensity of a light is multiplied with the Light color.", "http://docs.unity3d.com/ScriptReference/Light-intensity.html")));
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("bounceIntensity"),
                                          new RangeValueAttribute(0f, 8f), new HelpAttribute(new HelpAttribute.HelpDelegate(HelpBouncedGI)),
                                          new DescriptorAttribute("Bounce Intensity", "The multiplier that defines the strength of the bounce lighting.", "http://docs.unity3d.com/ScriptReference/Light-bounceIntensity.html")));

            //Acts like a group
            lightShadows = new InspectorField(type, Instances, type.GetProperty("shadows"),
                                              new InspectAttribute(new InspectAttribute.InspectDelegate(IsArea), false),
                                              new DescriptorAttribute("Shadow Type", "How this light casts shadows", "http://docs.unity3d.com/ScriptReference/Light-shadows.html"));

            Fields.Add(lightShadows);

            Fields.Add(new InspectorField(type, Instances, so.FindProperty("m_ShadowAngle"),
                                          new ReadOnlyAttribute(new ReadOnlyAttribute.ReadOnlyDelegate(IsSoft), false),
                                          new RangeAttribute(0, 90),
                                          new InspectAttribute(new InspectAttribute.InspectDelegate(ShowShadowAngle)),
                                          new DescriptorAttribute("Baked Shadow Angle", "", "")));

            Fields.Add(new InspectorField(type, Instances, so.FindProperty("m_ShadowRadius"),
                                          new ReadOnlyAttribute(new ReadOnlyAttribute.ReadOnlyDelegate(IsSoft), false),
                                          new InspectAttribute(new InspectAttribute.InspectDelegate(ShowShadowRadius)),
                                          new DescriptorAttribute("Baked Shadow Radius", "", "")));

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("shadowStrength"),
                                          new InspectAttribute(new InspectAttribute.InspectDelegate(HasRealimeShadow)),
                                          new RangeValueAttribute(0f, 1f),
                                          new DescriptorAttribute("Strength", "How this light casts shadows.", "http://docs.unity3d.com/ScriptReference/Light-shadowStrength.html")));
            Fields.Add(new InspectorField(type, Instances, so.FindProperty("m_Shadows.m_Resolution"),
                                          new InspectAttribute(new InspectAttribute.InspectDelegate(HasRealimeShadow)),
                                          new DescriptorAttribute("Resolution", "The shadow's resolution.")));
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("shadowBias"),
                                          new InspectAttribute(new InspectAttribute.InspectDelegate(HasRealimeShadow)),
                                          new RangeValueAttribute(0f, 2f),
                                          new DescriptorAttribute("Bias", "Shadow mapping bias.", "http://docs.unity3d.com/ScriptReference/Light-shadowBias.html")));
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("shadowNormalBias"),
                                          new InspectAttribute(new InspectAttribute.InspectDelegate(HasRealimeShadow)),
                                          new RangeValueAttribute(0f, 3f),
                                          new DescriptorAttribute("Normal Bias", "Shadow mapping normal-based bias.", "http://docs.unity3d.com/ScriptReference/Light-shadowNormalBias.html")));
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("shadowNearPlane"),
                                          new InspectAttribute(new InspectAttribute.InspectDelegate(HasRealimeShadow)),
                                          new RangeValueAttribute(0.1f, 10f),
                                          new DescriptorAttribute("Near Plane", "Near plane value to use for shadow frustums.", "https://docs.unity3d.com/ScriptReference/Light-shadowNearPlane.html")));

            Fields.Add(new InspectorField(type, Instances, so.FindProperty("m_DrawHalo"),
                                          new DescriptorAttribute("Draw Halo", "Draw a halo around the light. Now work with the Halo class.")));

            lightCookie = new InspectorField(type, Instances, type.GetProperty("cookie"),
                                             new InspectAttribute(new InspectAttribute.InspectDelegate(CanCookie)),
                                             new DescriptorAttribute("Cookie", "The cookie texture projected by the light.", "http://docs.unity3d.com/ScriptReference/Light-cookie.html"));

            Fields.Add(lightCookie);

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("cookieSize"),
                                          new InspectAttribute(new InspectAttribute.InspectDelegate(CanCookieSize)),
                                          new DescriptorAttribute("Cookie Size", "The size of a directional light's cookie.", "http://docs.unity3d.com/ScriptReference/Light-cookieSize.html")));

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("flare"),
                                          new DescriptorAttribute("Flare", "The flare asset to use for this light.", "http://docs.unity3d.com/ScriptReference/Light-flare.html")));


            Fields.Add(new InspectorField(type, Instances, so.FindProperty("m_RenderMode"),
                                          new DescriptorAttribute("Render Mode", "The rendering path for the lights.")));

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("cullingMask"), new FieldEditorAttribute("LayerMaskEditor"),
                                          new HelpAttribute(new HelpAttribute.HelpDelegate(HelpSceneLighting)),
                                          new DescriptorAttribute("Culling Mask", "The object that are affected or ignored by the light.")));
        }
コード例 #2
0
        protected override void RefreshFields()
        {
            Type editorGraphicsSettings = typeof(EditorGraphicsSettings);

            getCurrentTierSettings = editorGraphicsSettings.GetMethod("GetCurrentTierSettings", BindingFlags.Static | BindingFlags.NonPublic);

            Type displayUtility = TypeUtility.GetTypeByName("DisplayUtility");

            getDisplayNames   = displayUtility.GetMethod("GetDisplayNames", BindingFlags.Static | BindingFlags.Public);
            getDisplayIndices = displayUtility.GetMethod("GetDisplayIndices", BindingFlags.Static | BindingFlags.Public);

            Type moduleManager = TypeUtility.GetTypeByName("ModuleManager");

            shouldShowMultiDisplayOption = moduleManager.GetMethod("ShouldShowMultiDisplayOption", BindingFlags.Static | BindingFlags.NonPublic);

            Type gameView = TypeUtility.GetTypeByName("GameView");

            repaintAll                = gameView.GetMethod("RepaintAll", BindingFlags.Static | BindingFlags.Public);
            getSizeOfMainGameView     = gameView.GetMethod("GetSizeOfMainGameView", BindingFlags.Static | BindingFlags.NonPublic);
            getMainGameViewTargetSize = gameView.GetMethod("GetMainGameViewTargetSize", BindingFlags.Static | BindingFlags.NonPublic);

            Type type = typeof(Camera);

            getCameraBufferWarnings = type.GetMethod("GetCameraBufferWarnings", BindingFlags.Instance | BindingFlags.NonPublic);

            clearFlags = new InspectorField(type, Instances, type.GetProperty("clearFlags"),
                                            new DescriptorAttribute("Clear Flag", "HWhat to display in empty areas of this Camera's view.\n\nChoose Skybox to display a skybox in empty areas, defaulting to a background color if no skybox is found.\n\nChoose Solid Color to display a background color in empty areas.\n\nChoose Depth Only to display nothing in empty areas.\n\nChoose Don't Clear to display whatever was displayed in the previous frame in empty areas.", "http://docs.unity3d.com/ScriptReference/Camera-clearFlags.html"));

            Fields.Add(clearFlags);

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("backgroundColor"), new InspectAttribute(new InspectAttribute.InspectDelegate(ShowBackground)),
                                          new DescriptorAttribute("Background Color", "The Camera clears the screen to this color before rendering.", "http://docs.unity3d.com/ScriptReference/Camera-backgroundColor.html")));

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("cullingMask"), new FieldEditorAttribute("LayerMaskEditor"),
                                          new DescriptorAttribute("Culling Mask", "This is used to render parts of the scene selectively.", "http://docs.unity3d.com/ScriptReference/Camera-cullingMask.html")));

            orthographic = new InspectorField(type, Instances, type.GetProperty("orthographic"), new RestrictAttribute(new RestrictAttribute.RestrictDelegate(Projection)),
                                              new DescriptorAttribute("Projection", "How the Camera renders perspective.\n\nChoose Perspective to render objects with perspective.\n\nChoose Orthographic to render objects uniformly, with no sense of perspective.", "http://docs.unity3d.com/ScriptReference/Camera-orthographic.html"));

            Fields.Add(orthographic);

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("orthographicSize"), new InspectAttribute(new InspectAttribute.InspectDelegate(IsOrthographic)),
                                          new DescriptorAttribute("Size", "The width of the Camera’s view angle, measured in degrees along the local Z axis.", "http://docs.unity3d.com/ScriptReference/Camera-orthographicSize.html")));
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("fieldOfView"), new InspectAttribute(new InspectAttribute.InspectDelegate(IsOrthographic), false),
                                          new RangeValueAttribute(1, 179), new DescriptorAttribute("Field Of View", "The field of view of the camera in degrees.", "http://docs.unity3d.com/ScriptReference/Camera-fieldOfView.html")));

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("nearClipPlane"),
                                          new DescriptorAttribute("Near Clip", "The near clipping plane distance.", "http://docs.unity3d.com/ScriptReference/Camera-nearClipPlane.html")));
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("farClipPlane"),
                                          new DescriptorAttribute("Far Clip", "The far clipping plane distance.", "http://docs.unity3d.com/ScriptReference/Camera-farClipPlane.html")));

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("rect"),
                                          new DescriptorAttribute("Viewport Rect", "Where on the screen is the camera rendered in normalized coordinates.", "http://docs.unity3d.com/ScriptReference/Camera-rect.html")));
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("depth"),
                                          new DescriptorAttribute("Depth", "Camera's depth in the camera rendering order.", "http://docs.unity3d.com/ScriptReference/Camera-depth.html")));
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("renderingPath"), new HelpAttribute(new HelpAttribute.HelpDelegate(RenderingHelp)),
                                          new DescriptorAttribute("Rendering Path", "Rendering path.", "http://docs.unity3d.com/ScriptReference/Camera-renderingPath.html")));

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("targetTexture"), new HelpAttribute(new HelpAttribute.HelpDelegate(TargetTextureHelp)),
                                          new DescriptorAttribute("Target Texture", "Destination render texture (Unity Pro only).", "http://docs.unity3d.com/ScriptReference/Camera-targetTexture.html")));
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("useOcclusionCulling"),
                                          new DescriptorAttribute("Occlusion Culling", "Whether or not the Camera will use occlusion culling during rendering.", "http://docs.unity3d.com/ScriptReference/Camera-useOcclusionCulling.html")));

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("allowHDR"),
                                          new DescriptorAttribute("Allow HDR", "High dynamic range rendering.", "https://docs.unity3d.com/ScriptReference/Camera-allowHDR.html")));
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("allowMSAA"),
                                          new DescriptorAttribute("Allow MSAA", "MSAA rendering.", "https://docs.unity3d.com/ScriptReference/Camera-allowMSAA.html")));
#if !UNITY_2017_1 && !UNITY_2017_2
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("allowDynamicResolution"),
                                          new DescriptorAttribute("Allow Dynamic Resolution", "Dynamic Resolution Scaling.", "https://docs.unity3d.com/ScriptReference/Camera-allowDynamicResolution.html")));
#endif

            if (PlayerSettings.virtualRealitySupported)
            {
                Fields.Add(new InspectorField(type, Instances, type.GetProperty("stereoSeparation"),
                                              new DescriptorAttribute("Stereo Separation", "The distance between the virtual eyes.", "https://docs.unity3d.com/ScriptReference/Camera-stereoSeparation.html")));
                Fields.Add(new InspectorField(type, Instances, type.GetProperty("stereoConvergence"),
                                              new DescriptorAttribute("Stereo Convergence", "Distance to a point where virtual eyes converge.", "https://docs.unity3d.com/ScriptReference/Camera-stereoConvergence.html")));
                Fields.Add(new InspectorField(type, Instances, type.GetProperty("stereoTargetEye"),
                                              new DescriptorAttribute("Target Eye", "Defines which eye of a VR display the Camera renders into.", "https://docs.unity3d.com/ScriptReference/Camera-stereoTargetEye.html")));
            }

            if ((bool)shouldShowMultiDisplayOption.Invoke(null, null))
            {
                Fields.Add(new InspectorField(type, Instances, type.GetProperty("targetDisplay"), new RestrictAttribute(new RestrictAttribute.RestrictDelegate(TargetDisplay)),
                                              new DescriptorAttribute("Target Display", "Set the target display for this Camera.", "https://docs.unity3d.com/ScriptReference/Camera-targetDisplay.html")));
            }

            Fields.Add(new InspectorField(null, new UnityEngine.Object[] { this }, new object[] { this }, this.GetType().GetMethod("TakeScreenshot"),
                                          new Attribute[] { new InspectAttribute(InspectorLevel.Advanced) }));
            Fields.Add(new InspectorField(null, new UnityEngine.Object[] { this }, new object[] { this }, null, this.GetType().GetField("screenshotResolution"), false,
                                          new Attribute[] { new InspectAttribute(InspectorLevel.Advanced) }));

            // Debug
            InspectorField debug = new InspectorField("Debug");
            Fields.Add(debug);

            debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("aspect"), new InspectAttribute(InspectorLevel.Debug), new ReadOnlyAttribute(),
                                                new DescriptorAttribute("Aspect Ratio", "The aspect ratio (width divided by height).", "http://docs.unity3d.com/ScriptReference/Camera-aspect.html")));
            debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("clearStencilAfterLightingPass"), new InspectAttribute(InspectorLevel.Debug),
                                                new DescriptorAttribute("Clear Stencil After Lighting", "Clear Stencil After Lighting Pass.")));
            debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("depthTextureMode"), new InspectAttribute(InspectorLevel.Debug),
                                                new DescriptorAttribute("Depth Texture Mode", "How and if camera generates a depth texture.", "http://docs.unity3d.com/ScriptReference/Camera-depthTextureMode.html")));
            debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("eventMask"), new InspectAttribute(InspectorLevel.Debug),
                                                new DescriptorAttribute("Event Mask", "Mask to select which layers can trigger events on the camera.", "http://docs.unity3d.com/ScriptReference/Camera-eventMask.html")));
            debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("layerCullDistances"), new InspectAttribute(InspectorLevel.Debug), new CollectionAttribute(0),
                                                new DescriptorAttribute("Layer Cull Distances", "Per-layer culling distances.", "http://docs.unity3d.com/ScriptReference/Camera-layerCullDistances.html")));
            debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("layerCullSpherical"), new InspectAttribute(InspectorLevel.Debug),
                                                new DescriptorAttribute("Layer Cull Spherical", "How to perform per-layer culling for a Camera.", "http://docs.unity3d.com/ScriptReference/Camera-layerCullSpherical.html")));
            debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("pixelRect"), new InspectAttribute(InspectorLevel.Debug),
                                                new DescriptorAttribute("Pixel Rect", "Where on the screen is the camera rendered in pixel coordinates.", "http://docs.unity3d.com/ScriptReference/Camera-pixelRect.html")));
            debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("transparencySortMode"), new InspectAttribute(InspectorLevel.Debug),
                                                new DescriptorAttribute("Transparency Sort Mode", "Transparent object sorting mode.", "http://docs.unity3d.com/ScriptReference/Camera-transparencySortMode.html")));

            if (camera == null)
            {
                camera         = EditorUtility.CreateGameObjectWithHideFlags("Preview Camera", HideFlags.HideAndDontSave, new Type[] { typeof(Camera) }).GetComponent <Camera>();
                camera.enabled = false;
            }

            rects = new Rect[Instances.Length];

            for (int i = 0; i < Instances.Length; i++)
            {
                rects[i] = new Rect(25, 25, 0, 0);
            }
        }