Example #1
0
    override public void OnInspectorGUI()
    {
        DayLightTilemapCollider2D script = target as DayLightTilemapCollider2D;

        script.tilemapType = (MapType)EditorGUILayout.EnumPopup("Tilemap Type", script.tilemapType);

        EditorGUILayout.Space();

        switch (script.tilemapType)
        {
        case MapType.UnityRectangle:
            script.rectangle.shadowType = (LightTilemapCollider.ShadowType)EditorGUILayout.EnumPopup("Shadow Type", script.rectangle.shadowType);

            EditorGUI.BeginDisabledGroup(script.rectangle.shadowType == LightTilemapCollider.ShadowType.None);

            script.shadowLayer = EditorGUILayout.Popup("Shadow Layer (Day)", script.shadowLayer, Lighting2D.Profile.layers.lightLayers.GetNames());

            switch (script.rectangle.shadowType)
            {
            case LightTilemapCollider.ShadowType.Grid:
            case LightTilemapCollider.ShadowType.SpritePhysicsShape:
                script.shadowTileType = (ShadowTileType)EditorGUILayout.EnumPopup("Shadow Tile Type", script.shadowTileType);
                break;
            }

            script.height = EditorGUILayout.FloatField("Shadow Distance", script.height);

            if (script.height < 0.1f)
            {
                script.height = 0.1f;
            }


            EditorGUI.EndDisabledGroup();

            EditorGUILayout.Space();

            script.rectangle.maskType = (LightTilemapCollider.MaskType)EditorGUILayout.EnumPopup("Mask Type", script.rectangle.maskType);



            EditorGUI.BeginDisabledGroup(script.rectangle.maskType == LightTilemapCollider.MaskType.None);

            //if (script.rectangle.maskType == LightTilemapCollider.Rectangle.MaskType.BumpedSprite) {
            //	GUIBumpMapMode.Draw(script.bumpMapMode);
            //}

            EditorGUI.EndDisabledGroup();

            break;

        case MapType.UnityIsometric:
            break;


        case MapType.UnityHexagon:
            break;

        case MapType.SuperTilemapEditor:
            script.superTilemapEditor.shadowTypeSTE = (SuperTilemapEditorSupport.TilemapCollider2D.ShadowType)EditorGUILayout.EnumPopup("Shadow Type", script.superTilemapEditor.shadowTypeSTE);

            script.shadowLayer = EditorGUILayout.Popup("Shadow Layer (Day)", script.shadowLayer, Lighting2D.Profile.layers.lightLayers.GetNames());

            EditorGUILayout.Space();

            script.superTilemapEditor.maskTypeSTE = (SuperTilemapEditorSupport.TilemapCollider2D.MaskType)EditorGUILayout.EnumPopup("Mask Type", script.superTilemapEditor.maskTypeSTE);

            EditorGUI.BeginDisabledGroup(script.superTilemapEditor.maskTypeSTE == SuperTilemapEditorSupport.TilemapCollider2D.MaskType.None);

            script.maskLayer = EditorGUILayout.Popup("Mask Layer (Day)", script.maskLayer, Lighting2D.Profile.layers.lightLayers.GetNames());

            if (script.superTilemapEditor.maskTypeSTE == SuperTilemapEditorSupport.TilemapCollider2D.MaskType.BumpedSprite)
            {
                GUIBumpMapMode.Draw(serializedObject, script);
            }


            EditorGUI.EndDisabledGroup();
            break;
        }

        EditorGUILayout.Space();

        UpdateCollisions(script);

        if (GUI.changed)
        {
            script.Initialize();

            if (EditorApplication.isPlaying == false)
            {
                EditorUtility.SetDirty(target);
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
            }
        }
    }
Example #2
0
    override public void OnInspectorGUI()
    {
        LightTilemapCollider2D script = target as LightTilemapCollider2D;

        script.mapType = (MapType)EditorGUILayout.EnumPopup("Tilemap Type", script.mapType);

        EditorGUILayout.Space();

        switch (script.mapType)
        {
        case MapType.UnityRectangle:
            script.rectangle.shadowType = (ShadowType)EditorGUILayout.EnumPopup("Shadow Type", script.rectangle.shadowType);

            EditorGUI.BeginDisabledGroup(script.rectangle.shadowType == ShadowType.None);

            script.shadowLayer = EditorGUILayout.Popup("Shadow Layer (Light)", script.shadowLayer, Lighting2D.Profile.layers.lightLayers.GetNames());

            switch (script.rectangle.shadowType)
            {
            case ShadowType.Grid:
            case ShadowType.SpritePhysicsShape:
                script.shadowTileType = (ShadowTileType)EditorGUILayout.EnumPopup("Shadow Tile Type", script.shadowTileType);
                break;
            }


            script.rectangle.shadowOptimization = EditorGUILayout.Toggle("Shadow Optimization", script.rectangle.shadowOptimization);


            EditorGUI.EndDisabledGroup();

            EditorGUILayout.Space();

            script.rectangle.maskType = (MaskType)EditorGUILayout.EnumPopup("Mask Type", script.rectangle.maskType);

            EditorGUI.BeginDisabledGroup(script.rectangle.maskType == MaskType.None);

            script.maskLayer = EditorGUILayout.Popup("Mask Layer (Light)", script.maskLayer, Lighting2D.Profile.layers.lightLayers.GetNames());

            if (script.rectangle.maskType == MaskType.BumpedSprite)
            {
                GUIBumpMapMode.Draw(serializedObject, script);
            }

            EditorGUI.EndDisabledGroup();

            break;

        case MapType.UnityIsometric:

            script.isometric.shadowType = (ShadowType)EditorGUILayout.EnumPopup("Shadow Type", script.isometric.shadowType);

            EditorGUI.BeginDisabledGroup(script.isometric.shadowType == ShadowType.None);

            script.shadowLayer    = EditorGUILayout.Popup("Shadow Layer (Light)", script.shadowLayer, Lighting2D.Profile.layers.lightLayers.GetNames());
            script.shadowTileType = (ShadowTileType)EditorGUILayout.EnumPopup("Shadow Tile Type", script.shadowTileType);

            EditorGUI.EndDisabledGroup();

            EditorGUILayout.Space();

            script.isometric.maskType = (MaskType)EditorGUILayout.EnumPopup("Mask Type", script.isometric.maskType);

            EditorGUI.BeginDisabledGroup(script.isometric.maskType == MaskType.None);

            script.maskLayer = EditorGUILayout.Popup("Mask Layer (Light)", script.maskLayer, Lighting2D.Profile.layers.lightLayers.GetNames());

            EditorGUILayout.Space();

            script.isometric.ZasY = EditorGUILayout.Toggle("Z as Y", script.isometric.ZasY);

            EditorGUI.EndDisabledGroup();

            break;


        case MapType.UnityHexagon:

            script.hexagon.shadowType = (ShadowType)EditorGUILayout.EnumPopup("Shadow Type", script.hexagon.shadowType);

            EditorGUI.BeginDisabledGroup(script.hexagon.shadowType == ShadowType.None);

            script.shadowLayer    = EditorGUILayout.Popup("Shadow Layer (Light)", script.shadowLayer, Lighting2D.Profile.layers.lightLayers.GetNames());
            script.shadowTileType = (ShadowTileType)EditorGUILayout.EnumPopup("Shadow Tile Type", script.shadowTileType);

            EditorGUI.EndDisabledGroup();

            EditorGUILayout.Space();

            script.hexagon.maskType = (MaskType)EditorGUILayout.EnumPopup("Mask Type", script.hexagon.maskType);

            EditorGUI.BeginDisabledGroup(script.hexagon.maskType == MaskType.None);

            script.maskLayer = EditorGUILayout.Popup("Mask Layer (Light)", script.maskLayer, Lighting2D.Profile.layers.lightLayers.GetNames());

            EditorGUI.EndDisabledGroup();
            break;

        case MapType.SuperTilemapEditor:
            script.superTilemapEditor.shadowTypeSTE = (SuperTilemapEditorSupport.TilemapCollider2D.ShadowType)EditorGUILayout.EnumPopup("Shadow Type", script.superTilemapEditor.shadowTypeSTE);

            script.shadowLayer = EditorGUILayout.Popup("Shadow Layer (Light)", script.shadowLayer, Lighting2D.Profile.layers.lightLayers.GetNames());

            EditorGUILayout.Space();

            script.superTilemapEditor.maskTypeSTE = (SuperTilemapEditorSupport.TilemapCollider2D.MaskType)EditorGUILayout.EnumPopup("Mask Type", script.superTilemapEditor.maskTypeSTE);

            EditorGUI.BeginDisabledGroup(script.superTilemapEditor.maskTypeSTE == SuperTilemapEditorSupport.TilemapCollider2D.MaskType.None);

            script.maskLayer = EditorGUILayout.Popup("Mask Layer (Light)", script.maskLayer, Lighting2D.Profile.layers.lightLayers.GetNames());

            if (script.superTilemapEditor.maskTypeSTE == SuperTilemapEditorSupport.TilemapCollider2D.MaskType.BumpedSprite)
            {
                GUIBumpMapMode.Draw(serializedObject, script);
            }

            EditorGUI.EndDisabledGroup();
            break;
        }

        EditorGUILayout.Space();

        Update(script);

        serializedObject.ApplyModifiedProperties();

        if (GUI.changed)
        {
            script.Initialize();

            Light2D.ForceUpdateAll();
            LightingManager2D.ForceUpdate();

            if (EditorApplication.isPlaying == false)
            {
                EditorUtility.SetDirty(target);
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
            }
        }
    }
    override public void OnInspectorGUI()
    {
        if (lightCollider2D == null)
        {
            return;
        }

        // Warning
        // Debug.Log(lightCollider2D.mainShape.spriteShape.GetOriginalSprite().packingMode);

        // Shadow Properties

        EditorGUILayout.PropertyField(shadowType, new GUIContent("Shadow Type"));

        EditorGUI.BeginDisabledGroup(shadowType.intValue == (int)LightCollider2D.ShadowType.None);

        shadowLayer.intValue = EditorGUILayout.Popup("Shadow Layer (Light)", shadowLayer.intValue, Lighting2D.Profile.layers.lightLayers.GetNames());

        string shadowDistanceName = "Shadow Distance";

        if (shadowDistance.floatValue == 0)
        {
            shadowDistanceName = "Shadow Distance (infinite)";
        }

        EditorGUILayout.PropertyField(shadowDistance, new GUIContent(shadowDistanceName));

        EditorGUILayout.PropertyField(shadowTranslucency, new GUIContent("Shadow Translucency"));

        EditorGUI.EndDisabledGroup();

        EditorGUILayout.Space();

        // Mask Properties

        EditorGUILayout.PropertyField(maskType, new GUIContent("Mask Type"));

        EditorGUI.BeginDisabledGroup(maskType.intValue == (int)LightCollider2D.MaskType.None);

        maskLayer.intValue = EditorGUILayout.Popup("Mask Layer (Light)", maskLayer.intValue, Lighting2D.Profile.layers.lightLayers.GetNames());

        EditorGUILayout.PropertyField(maskEffect, new GUIContent("Mask Effect"));

        EditorGUILayout.PropertyField(maskPivot, new GUIContent("Mask Pivot"));

        EditorGUILayout.PropertyField(maskTranslucency, new GUIContent("Mask Translucency"));

        EditorGUI.EndDisabledGroup();

        if (lightCollider2D.maskType == LightCollider2D.MaskType.BumpedSprite || lightCollider2D.maskType == LightCollider2D.MaskType.BumpedMeshRenderer)
        {
            GUIBumpMapMode.Draw(serializedObject, lightCollider2D);
        }

        EditorGUILayout.Space();

        // Apply to Children

        EditorGUILayout.PropertyField(applyToChildren, new GUIContent("Apply to Children"));

        serializedObject.ApplyModifiedProperties();


        EditorGUILayout.Space();

        // Update

        if (GUILayout.Button("Update"))
        {
            SpriteExtension.PhysicsShapeManager.Clear();

            foreach (Object target in targets)
            {
                LightCollider2D lightCollider2D = target as LightCollider2D;
                lightCollider2D.Initialize();
            }

            LightingManager2D.ForceUpdate();
        }

        if (GUI.changed)
        {
            foreach (Object target in targets)
            {
                LightCollider2D lightCollider2D = target as LightCollider2D;
                lightCollider2D.Initialize();
                lightCollider2D.UpdateNearbyLights();

                if (EditorApplication.isPlaying == false)
                {
                    EditorUtility.SetDirty(target);
                }
            }

            if (EditorApplication.isPlaying == false)
            {
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
            }

            LightingManager2D.ForceUpdate();
        }
    }
Example #4
0
    override public void OnInspectorGUI()
    {
        DayLightCollider2D script = target as DayLightCollider2D;

        // Shadow Properties
        EditorGUILayout.PropertyField(shadowType, new GUIContent("Shadow Type"));

        EditorGUI.BeginDisabledGroup(script.mainShape.shadowType == DayLightCollider2D.ShadowType.None);

        shadowLayer.intValue = EditorGUILayout.Popup("Shadow Layer (Day)", shadowLayer.intValue, Lighting2D.Profile.layers.dayLayers.GetNames());

        EditorGUILayout.PropertyField(shadowDistance, new GUIContent("Shadow Distance"));

        if (script.mainShape.shadowType == DayLightCollider2D.ShadowType.SpriteProjection)
        {
            EditorGUILayout.PropertyField(shadowThickness, new GUIContent("Shadow Thickness"));
        }

        EditorGUILayout.PropertyField(shadowTranslucency, new GUIContent("Shadow Translucency"));

        EditorGUI.EndDisabledGroup();

        EditorGUILayout.Space();

        // Mask Properties

        EditorGUILayout.PropertyField(maskType, new GUIContent("Mask Type"));

        EditorGUI.BeginDisabledGroup(script.mainShape.maskType == DayLightCollider2D.MaskType.None);

        maskLayer.intValue = EditorGUILayout.Popup("Mask Layer (Day)", maskLayer.intValue, Lighting2D.Profile.layers.dayLayers.GetNames());

        if (script.mainShape.maskType == DayLightCollider2D.MaskType.BumpedSprite)
        {
            GUIBumpMapMode.DrawDay(script.normalMapMode);
        }

        EditorGUI.EndDisabledGroup();

        EditorGUILayout.Space();

        // Other Properties

        EditorGUILayout.PropertyField(applyToChildren, new GUIContent("Apply To Children"));

        EditorGUILayout.Space();

        serializedObject.ApplyModifiedProperties();

        if (GUILayout.Button("Update"))
        {
            SpriteExtension.PhysicsShapeManager.Clear();

            foreach (Object target in targets)
            {
                DayLightCollider2D daylightCollider2D = target as DayLightCollider2D;

                daylightCollider2D.mainShape.ResetLocal();

                daylightCollider2D.Initialize();
            }
        }

        if (GUI.changed)
        {
            foreach (Object target in targets)
            {
                DayLightCollider2D daylightCollider2D = target as DayLightCollider2D;
                daylightCollider2D.Initialize();

                if (EditorApplication.isPlaying == false)
                {
                    EditorUtility.SetDirty(target);
                }
            }

            if (EditorApplication.isPlaying == false)
            {
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
            }
        }
    }