public void GetTransparencySortingMode(Camera camera, ref SortingSettings sortingSettings)
        {
            TransparencySortMode mode = camera.transparencySortMode;

            if (mode == TransparencySortMode.Default)
            {
                mode = m_Renderer2DData.transparencySortMode;
                if (mode == TransparencySortMode.Default)
                {
                    mode = camera.orthographic ? TransparencySortMode.Orthographic : TransparencySortMode.Perspective;
                }
            }

            if (mode == TransparencySortMode.Perspective)
            {
                sortingSettings.distanceMetric = DistanceMetric.Perspective;
            }
            else if (mode == TransparencySortMode.Orthographic)
            {
                sortingSettings.distanceMetric = DistanceMetric.Orthographic;
            }
            else
            {
                sortingSettings.distanceMetric = DistanceMetric.CustomAxis;
                sortingSettings.customAxis     = m_Renderer2DData.transparencySortAxis;
            }
        }
Example #2
0
        /// <summary>
        /// Creates a Palette Asset at the given folder path.
        /// </summary>
        /// <param name="folderPath">Folder Path of the Palette Asset.</param>
        /// <param name="name">Name of the Palette Asset.</param>
        /// <param name="layout">Grid Layout of the Palette Asset.</param>
        /// <param name="cellSizing">Cell Sizing of the Palette Asset.</param>
        /// <param name="cellSize">Cell Size of the Palette Asset.</param>
        /// <param name="swizzle">Cell Swizzle of the Palette.</param>
        /// <param name="sortMode">Transparency Sort Mode for the Palette</param>
        /// <param name="sortAxis">Transparency Sort Axis for the Palette</param>
        /// <returns>The created Palette Asset if successful.</returns>
        public static GameObject CreateNewPalette(string folderPath
                                                  , string name
                                                  , GridLayout.CellLayout layout
                                                  , GridPalette.CellSizing cellSizing
                                                  , Vector3 cellSize
                                                  , GridLayout.CellSwizzle swizzle
                                                  , TransparencySortMode sortMode
                                                  , Vector3 sortAxis)
        {
            GameObject temporaryGO = new GameObject(name);
            Grid       grid        = temporaryGO.AddComponent <Grid>();

            // We set size to kEpsilon to mark this as new uninitialized palette
            // Nice default size can be decided when first asset is dragged in
            grid.cellSize    = cellSize;
            grid.cellLayout  = layout;
            grid.cellSwizzle = swizzle;
            CreateNewLayer(temporaryGO, "Layer1", layout);

            string path = AssetDatabase.GenerateUniqueAssetPath(folderPath + "/" + name + ".prefab");

            Object      prefab  = PrefabUtility.SaveAsPrefabAssetAndConnect(temporaryGO, path, InteractionMode.AutomatedAction);
            GridPalette palette = CreateGridPalette(cellSizing, sortMode, sortAxis);

            AssetDatabase.AddObjectToAsset(palette, prefab);
            PrefabUtility.ApplyPrefabInstance(temporaryGO, InteractionMode.AutomatedAction);
            AssetDatabase.Refresh();

            Object.DestroyImmediate(temporaryGO);
            return(AssetDatabase.LoadAssetAtPath <GameObject>(path));
        }
    static int IntToEnum(IntPtr L)
    {
        int arg0 = (int)LuaDLL.lua_tonumber(L, 1);
        TransparencySortMode o = (TransparencySortMode)arg0;

        LuaScriptMgr.PushEnum(L, o);
        return(1);
    }
Example #4
0
        internal static GridPalette CreateGridPalette(GridPalette.CellSizing cellSizing
                                                      , TransparencySortMode sortMode
                                                      , Vector3 sortAxis
                                                      )
        {
            var palette = ScriptableObject.CreateInstance <GridPalette>();

            palette.name                 = "Palette Settings";
            palette.cellSizing           = cellSizing;
            palette.transparencySortMode = sortMode;
            palette.transparencySortAxis = sortAxis;
            return(palette);
        }
Example #5
0
 public void OnValidate()
 {
     this.target.projectionMatrix = this.projectionMatrix;
     //this.target.worldToCameraMatrix = this.worldToCameraMatrix;
     //this.target.stereoEnabled = this.stereoEnabled;
     //this.target.stereoSeparation = this.stereoSeparation;
     //this.target.stereoConvergence = this.stereoConvergence;
     this.target.eventMask            = this.eventMask.value;
     this.target.depthTextureMode     = this.depthTextureMode;
     this.target.transparencySortMode = this.transparencySortMode;
     this.target.aspect             = this.aspect;
     this.target.layerCullDistances = this.layerCullDistances.values;
     this.target.layerCullSpherical = this.layerCullSpherical;
 }
Example #6
0
        protected override void ReadFromImpl(object obj)
        {
            base.ReadFromImpl(obj);
            Camera uo = (Camera)obj;

            nearClipPlane          = uo.nearClipPlane;
            farClipPlane           = uo.farClipPlane;
            fieldOfView            = uo.fieldOfView;
            renderingPath          = uo.renderingPath;
            allowHDR               = uo.allowHDR;
            allowMSAA              = uo.allowMSAA;
            allowDynamicResolution = uo.allowDynamicResolution;
            forceIntoRenderTexture = uo.forceIntoRenderTexture;
            orthographicSize       = uo.orthographicSize;
            orthographic           = uo.orthographic;
            opaqueSortMode         = uo.opaqueSortMode;
            transparencySortMode   = uo.transparencySortMode;
            transparencySortAxis   = uo.transparencySortAxis;
            depth                         = uo.depth;
            aspect                        = uo.aspect;
            cullingMask                   = uo.cullingMask;
            eventMask                     = uo.eventMask;
            layerCullSpherical            = uo.layerCullSpherical;
            cameraType                    = uo.cameraType;
            layerCullDistances            = uo.layerCullDistances;
            useOcclusionCulling           = uo.useOcclusionCulling;
            cullingMatrix                 = uo.cullingMatrix;
            backgroundColor               = uo.backgroundColor;
            clearFlags                    = uo.clearFlags;
            depthTextureMode              = uo.depthTextureMode;
            clearStencilAfterLightingPass = uo.clearStencilAfterLightingPass;
            usePhysicalProperties         = uo.usePhysicalProperties;
            sensorSize                    = uo.sensorSize;
            lensShift                     = uo.lensShift;
            focalLength                   = uo.focalLength;
            rect                        = uo.rect;
            pixelRect                   = uo.pixelRect;
            targetTexture               = ToID(uo.targetTexture);
            targetDisplay               = uo.targetDisplay;
            worldToCameraMatrix         = uo.worldToCameraMatrix;
            projectionMatrix            = uo.projectionMatrix;
            nonJitteredProjectionMatrix = uo.nonJitteredProjectionMatrix;
            useJitteredProjectionMatrixForTransparentRendering = uo.useJitteredProjectionMatrixForTransparentRendering;
            scene             = uo.scene;
            stereoSeparation  = uo.stereoSeparation;
            stereoConvergence = uo.stereoConvergence;
            stereoTargetEye   = uo.stereoTargetEye;
        }
Example #7
0
 public void Reset()
 {
     this.target              = this.GetComponent <Camera>();
     this.velocity            = this.target.velocity;
     this.projectionMatrix    = this.target.projectionMatrix;
     this.worldToCameraMatrix = this.target.worldToCameraMatrix;
     //this.stereoEnabled = this.target.stereoEnabled;
     //this.stereoSeparation = this.target.stereoSeparation;
     //this.stereoConvergence = this.target.stereoConvergence;
     this.eventMask            = (LayerMask)this.target.eventMask;
     this.depthTextureMode     = this.target.depthTextureMode;
     this.transparencySortMode = this.target.transparencySortMode;
     this.aspect = this.target.aspect;
     this.layerCullDistances.values = this.target.layerCullDistances;
     this.layerCullSpherical        = this.target.layerCullSpherical;
 }
Example #8
0
        /// <summary>
        /// Creates a Palette Asset at the current selected folder path. This will show a popup allowing you to choose
        /// a different folder path for saving the Palette Asset if required.
        /// </summary>
        /// <param name="name">Name of the Palette Asset.</param>
        /// <param name="layout">Grid Layout of the Palette Asset.</param>
        /// <param name="cellSizing">Cell Sizing of the Palette Asset.</param>
        /// <param name="cellSize">Cell Size of the Palette Asset.</param>
        /// <param name="swizzle">Cell Swizzle of the Palette.</param>
        /// <param name="sortMode">Transparency Sort Mode for the Palette</param>
        /// <param name="sortAxis">Transparency Sort Axis for the Palette</param>
        /// <returns>The created Palette Asset if successful.</returns>
        public static GameObject CreateNewPaletteAtCurrentFolder(string name
                                                                 , GridLayout.CellLayout layout
                                                                 , GridPalette.CellSizing cellSizing
                                                                 , Vector3 cellSize
                                                                 , GridLayout.CellSwizzle swizzle
                                                                 , TransparencySortMode sortMode
                                                                 , Vector3 sortAxis)
        {
            string defaultPath = ProjectBrowser.s_LastInteractedProjectBrowser ? ProjectBrowser.s_LastInteractedProjectBrowser.GetActiveFolderPath() : "Assets";
            string folderPath  = EditorUtility.SaveFolderPanel("Create palette into folder ", defaultPath, "");

            folderPath = FileUtil.GetProjectRelativePath(folderPath);

            if (string.IsNullOrEmpty(folderPath))
            {
                return(null);
            }

            return(CreateNewPalette(folderPath, name, layout, cellSizing, cellSize, swizzle, sortMode, sortAxis));
        }
Example #9
0
    void DrawCameraGUI(tk2dCamera target, bool complete)
    {
        bool allowProjectionParameters = target.SettingsRoot == target;
        bool oldGuiEnabled             = GUI.enabled;

        SerializedObject so  = this.serializedObject;
        SerializedObject cam = new SerializedObject(target.camera);

        SerializedProperty   m_ClearFlags         = cam.FindProperty("m_ClearFlags");
        SerializedProperty   m_BackGroundColor    = cam.FindProperty("m_BackGroundColor");
        SerializedProperty   m_CullingMask        = cam.FindProperty("m_CullingMask");
        SerializedProperty   m_TargetTexture      = cam.FindProperty("m_TargetTexture");
        SerializedProperty   m_Near               = cam.FindProperty("near clip plane");
        SerializedProperty   m_Far                = cam.FindProperty("far clip plane");
        SerializedProperty   m_Depth              = cam.FindProperty("m_Depth");
        SerializedProperty   m_RenderingPath      = cam.FindProperty("m_RenderingPath");
        SerializedProperty   m_HDR                = cam.FindProperty("m_HDR");
        TransparencySortMode transparencySortMode = target.camera.transparencySortMode;

        if (complete)
        {
            EditorGUILayout.PropertyField(m_ClearFlags);
            EditorGUILayout.PropertyField(m_BackGroundColor);
            EditorGUILayout.PropertyField(m_CullingMask);
            EditorGUILayout.Space();
        }

        tk2dCameraSettings cameraSettings    = target.CameraSettings;
        tk2dCameraSettings inheritedSettings = target.SettingsRoot.CameraSettings;

        GUI.enabled &= allowProjectionParameters;
        inheritedSettings.projection = (tk2dCameraSettings.ProjectionType)EditorGUILayout.EnumPopup("Projection", inheritedSettings.projection);
        EditorGUI.indentLevel++;
        if (inheritedSettings.projection == tk2dCameraSettings.ProjectionType.Orthographic)
        {
            inheritedSettings.orthographicType = (tk2dCameraSettings.OrthographicType)EditorGUILayout.EnumPopup("Type", inheritedSettings.orthographicType);
            switch (inheritedSettings.orthographicType)
            {
            case tk2dCameraSettings.OrthographicType.OrthographicSize:
                inheritedSettings.orthographicSize = Mathf.Max(0.001f, EditorGUILayout.FloatField("Orthographic Size", inheritedSettings.orthographicSize));
                break;

            case tk2dCameraSettings.OrthographicType.PixelsPerMeter:
                inheritedSettings.orthographicPixelsPerMeter = Mathf.Max(0.001f, EditorGUILayout.FloatField("Pixels per Meter", inheritedSettings.orthographicPixelsPerMeter));
                break;
            }
            inheritedSettings.orthographicOrigin = (tk2dCameraSettings.OrthographicOrigin)EditorGUILayout.EnumPopup("Origin", inheritedSettings.orthographicOrigin);
        }
        else if (inheritedSettings.projection == tk2dCameraSettings.ProjectionType.Perspective)
        {
            inheritedSettings.fieldOfView = EditorGUILayout.Slider("Field of View", inheritedSettings.fieldOfView, 1, 179);
            transparencySortMode          = (TransparencySortMode)EditorGUILayout.EnumPopup("Sort mode", transparencySortMode);
        }
        EditorGUI.indentLevel--;
        GUI.enabled = oldGuiEnabled;

        if (complete)
        {
            EditorGUILayout.Space();
            GUILayout.Label("Clipping Planes");
            GUILayout.BeginHorizontal();
            GUILayout.Space(14);
            GUILayout.Label("Near");
            if (m_Near != null)
            {
                EditorGUILayout.PropertyField(m_Near, GUIContent.none, GUILayout.Width(60));
            }
            GUILayout.Label("Far");
            if (m_Far != null)
            {
                EditorGUILayout.PropertyField(m_Far, GUIContent.none, GUILayout.Width(60));
            }
            GUILayout.EndHorizontal();
            cameraSettings.rect = EditorGUILayout.RectField("Normalized View Port Rect", cameraSettings.rect);

            EditorGUILayout.Space();
            if (m_Depth != null)
            {
                EditorGUILayout.PropertyField(m_Depth);
            }
            if (m_RenderingPath != null)
            {
                EditorGUILayout.PropertyField(m_RenderingPath);
            }
            if (m_TargetTexture != null)
            {
                EditorGUILayout.PropertyField(m_TargetTexture);
            }
            if (m_HDR != null)
            {
                EditorGUILayout.PropertyField(m_HDR);
            }
        }

        cam.ApplyModifiedProperties();
        so.ApplyModifiedProperties();

        if (transparencySortMode != target.camera.transparencySortMode)
        {
            target.camera.transparencySortMode = transparencySortMode;
            EditorUtility.SetDirty(target.camera);
        }
    }
        internal void OnGUI()
        {
            GUI.Label(new Rect(0, 0, position.width, position.height), GUIContent.none, "grey_border");
            GUILayout.Space(3);

            GUILayout.Label(Styles.header, EditorStyles.boldLabel);
            GUILayout.Space(4);

            GUILayout.BeginHorizontal();
            GUILayout.Label(Styles.nameLabel, GUILayout.Width(90f));
            m_Name = EditorGUILayout.TextField(m_Name);

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label(Styles.gridLabel, GUILayout.Width(90f));
            EditorGUI.BeginChangeCheck();
            var newLayout = (GridLayout.CellLayout)EditorGUILayout.EnumPopup(m_Layout);

            if (EditorGUI.EndChangeCheck())
            {
                // Set useful user settings for certain layouts
                switch (newLayout)
                {
                case GridLayout.CellLayout.Rectangle:
                case GridLayout.CellLayout.Hexagon:
                {
                    m_CellSizing = GridPalette.CellSizing.Automatic;
                    m_CellSize   = new Vector3(1, 1, 0);
                    break;
                }

                case GridLayout.CellLayout.Isometric:
                {
                    m_CellSizing = GridPalette.CellSizing.Manual;
                    m_CellSize   = new Vector3(1, 0.5f, 1);
                    break;
                }

                case GridLayout.CellLayout.IsometricZAsY:
                {
                    m_CellSizing           = GridPalette.CellSizing.Manual;
                    m_CellSize             = new Vector3(1, 0.5f, 1);
                    m_TransparencySortMode = TransparencySortMode.CustomAxis;
                    m_TransparencySortAxis = new Vector3(0f, 1f, -0.25f);
                    break;
                }
                }
                m_Layout = newLayout;
            }
            GUILayout.EndHorizontal();

            if (m_Layout == GridLayout.CellLayout.Hexagon)
            {
                GUILayout.BeginHorizontal();
                float oldLabelWidth = UnityEditor.EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = 94;
                m_HexagonLayout             = EditorGUILayout.Popup(Styles.hexagonLabel, m_HexagonLayout, Styles.hexagonSwizzleTypeLabel);
                EditorGUIUtility.labelWidth = oldLabelWidth;
                GUILayout.EndHorizontal();
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label(Styles.sizeLabel, GUILayout.Width(90f));
            m_CellSizing = (GridPalette.CellSizing)EditorGUILayout.EnumPopup(m_CellSizing);
            GUILayout.EndHorizontal();

            using (new EditorGUI.DisabledScope(m_CellSizing == GridPalette.CellSizing.Automatic))
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(GUIContent.none, GUILayout.Width(90f));
                m_CellSize = EditorGUILayout.Vector3Field(GUIContent.none, m_CellSize);
                GUILayout.EndHorizontal();
            }
            GUILayout.FlexibleSpace();

            GUILayout.BeginHorizontal();
            GUILayout.Label(Styles.transparencySortModeLabel, GUILayout.Width(90f));
            m_TransparencySortMode = (TransparencySortMode)EditorGUILayout.EnumPopup(m_TransparencySortMode);
            GUILayout.EndHorizontal();
            using (new EditorGUI.DisabledScope(m_TransparencySortMode != TransparencySortMode.CustomAxis))
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(Styles.transparencySortAxisLabel, GUILayout.Width(90f));
                m_TransparencySortAxis = EditorGUILayout.Vector3Field("", m_TransparencySortAxis);
                GUILayout.EndHorizontal();
            }

            GUILayout.FlexibleSpace();

            // Cancel, Ok
            GUILayout.BeginHorizontal();
            GUILayout.Space(10);
            if (GUILayout.Button(Styles.cancel))
            {
                Close();
            }

            using (new EditorGUI.DisabledScope(!Utils.Paths.IsValidAssetPath(m_Name)))
            {
                if (GUILayout.Button(Styles.ok))
                {
                    s_LastClosedTime = System.DateTime.Now.Ticks / System.TimeSpan.TicksPerMillisecond;

                    // case 1077362: Close window to prevent overlap with OS folder window when saving new palette asset
                    Close();

                    var swizzle = GridLayout.CellSwizzle.XYZ;
                    if (m_Layout == GridLayout.CellLayout.Hexagon)
                    {
                        swizzle = Styles.hexagonSwizzleTypeValue[m_HexagonLayout];
                    }

                    GameObject go = GridPaletteUtility.CreateNewPaletteAtCurrentFolder(m_Name, m_Layout, m_CellSizing, m_CellSize
                                                                                       , swizzle, m_TransparencySortMode, m_TransparencySortAxis);
                    if (go != null)
                    {
                        m_Owner.palette = go;
                        m_Owner.Repaint();
                    }

                    GUIUtility.ExitGUI();
                }
            }

            GUILayout.Space(10);
            GUILayout.EndHorizontal();
        }