-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
com.unity.render-pipelines.core@4.2.0-preview
## [4.2.0-preview] - 2018-11-16 ### Added - Added a define for determining if any instancing path is taken.
- Loading branch information
Unity Technologies
committed
Nov 15, 2018
1 parent
4f9f203
commit a8b88ee
Showing
24 changed files
with
1,221 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System; | ||
using UnityEditor; | ||
|
||
namespace UnityEditor.Experimental.Rendering | ||
{ | ||
/// <summary>Used in editor drawer part to store the state of expendable areas.</summary> | ||
/// <typeparam name="TState">An enum to use to describe the state.</typeparam> | ||
/// <typeparam name="TTarget">A type given to automatically compute the key.</typeparam> | ||
public struct ExpandedState<TState, TTarget> | ||
where TState : struct, IConvertible | ||
{ | ||
/// <summary>Key is automatically computed regarding the target type given</summary> | ||
public readonly string stateKey; | ||
|
||
/// <summary>Constructor will create the key to store in the EditorPref the state given generic type passed.</summary> | ||
/// <param name="defaultValue">If key did not exist, it will be created with this value for initialization.</param> | ||
public ExpandedState(TState defaultValue, string prefix = "CoreRP") | ||
{ | ||
stateKey = string.Format("{0}:{1}:UI_State", prefix, typeof(TTarget).Name); | ||
|
||
//register key if not already there | ||
if (!EditorPrefs.HasKey(stateKey)) | ||
{ | ||
EditorPrefs.SetInt(stateKey, (int)(object)defaultValue); | ||
} | ||
} | ||
|
||
uint expandedState { get { return (uint)EditorPrefs.GetInt(stateKey); } set { EditorPrefs.SetInt(stateKey, (int)value); } } | ||
|
||
/// <summary>Get or set the state given the mask.</summary> | ||
public bool this[TState mask] | ||
{ | ||
get { return GetExpandedAreas(mask); } | ||
set { SetExpandedAreas(mask, value); } | ||
} | ||
|
||
/// <summary>Accessor to the expended state of this specific mask.</summary> | ||
public bool GetExpandedAreas(TState mask) | ||
{ | ||
// note on cast: | ||
// - to object always ok | ||
// - to int ok because of IConvertible. Cannot directly go to uint | ||
return (expandedState & (uint)(int)(object)mask) > 0; | ||
} | ||
|
||
/// <summary>Setter to the expended state.</summary> | ||
public void SetExpandedAreas(TState mask, bool value) | ||
{ | ||
uint state = expandedState; | ||
// note on cast: | ||
// - to object always ok | ||
// - to int ok because of IConvertible. Cannot directly go to uint | ||
uint workMask = (uint)(int)(object)mask; | ||
|
||
if (value) | ||
{ | ||
state |= workMask; | ||
} | ||
else | ||
{ | ||
workMask = ~workMask; | ||
state &= workMask; | ||
} | ||
|
||
expandedState = state; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.