Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Project2ProceduralGeneration-Ryan-Chang
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MI431-s23-Ryan-Chang
Project2ProceduralGeneration-Ryan-Chang
Commits
87df7099
Commit
87df7099
authored
1 year ago
by
Ryan Chang
Browse files
Options
Downloads
Patches
Plain Diff
Updates to fade in out.
parent
4fa1c451
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Assets/Scripts/StandAlone/UI/FadeInOut.cs
+50
-20
50 additions, 20 deletions
Assets/Scripts/StandAlone/UI/FadeInOut.cs
with
50 additions
and
20 deletions
Assets/Scripts/StandAlone/UI/FadeInOut.cs
+
50
−
20
View file @
87df7099
using
System.Collections
;
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.Linq
;
using
UnityEngine
;
using
UnityEngine.UI
;
...
...
@@ -12,11 +14,32 @@ public class FadeInOut : MonoBehaviour
public
bool
startHidden
;
[
Header
(
"Autogenerated values"
)]
public
Image
[]
imageTarget
s
;
public
Dictionary
<
Image
,
AlphaData
>
imageAlpha
s
;
public
TMP_Text
[]
textTarget
s
;
public
Dictionary
<
TMP_Text
,
AlphaData
>
textAlpha
s
;
public
MeshRenderer
[]
meshTargets
;
public
Dictionary
<
MeshRenderer
,
AlphaData
>
meshAlphas
;
[
System
.
Serializable
]
public
class
AlphaData
{
public
float
baseValue
;
public
float
percent
;
public
float
AdjValue
=>
baseValue
*
percent
;
public
AlphaData
(
float
baseValue
,
float
percent
)
{
this
.
baseValue
=
baseValue
;
this
.
percent
=
percent
;
}
public
Color
CalculateColor
(
Color
input
)
{
input
.
a
=
AdjValue
;
return
input
;
}
}
public
enum
State
{
...
...
@@ -32,9 +55,13 @@ public class FadeInOut : MonoBehaviour
private
void
Start
()
{
imageTargets
=
GetComponentsInChildren
<
Image
>(
true
);
textTargets
=
GetComponentsInChildren
<
TMP_Text
>(
true
);
meshTargets
=
GetComponentsInChildren
<
MeshRenderer
>(
true
);
var
imageTargets
=
GetComponentsInChildren
<
Image
>(
true
);
var
textTargets
=
GetComponentsInChildren
<
TMP_Text
>(
true
);
var
meshTargets
=
GetComponentsInChildren
<
MeshRenderer
>(
true
);
imageAlphas
=
imageTargets
.
ToDictionary
(
i
=>
i
,
i
=>
new
AlphaData
(
i
.
color
.
a
,
0
));
textAlphas
=
textTargets
.
ToDictionary
(
t
=>
t
,
t
=>
new
AlphaData
(
t
.
color
.
a
,
0
));
meshAlphas
=
meshTargets
.
ToDictionary
(
m
=>
m
,
m
=>
new
AlphaData
(
m
.
material
.
color
.
a
,
0
));
SetTargetsAlpha
(
startHidden
?
0
:
1
);
FadeState
=
startHidden
?
State
.
FadedOut
:
State
.
FadedIn
;
...
...
@@ -80,27 +107,30 @@ public class FadeInOut : MonoBehaviour
}
}
private
void
SetTargetsAlpha
(
float
alpha
)
private
void
SetTargetsAlpha
(
float
percent
)
{
foreach
(
var
target
in
image
Target
s
)
foreach
(
var
pair
in
image
Alpha
s
)
{
Color
targetColor
=
target
.
color
;
targetColor
.
a
=
alpha
;
target
.
color
=
targetColor
;
var
a
=
pair
.
Value
;
var
i
=
pair
.
Key
;
a
.
percent
=
percent
;
i
.
color
=
a
.
CalculateColor
(
i
.
color
);
}
foreach
(
var
target
in
text
Target
s
)
foreach
(
var
pair
in
text
Alpha
s
)
{
Color
targetColor
=
target
.
color
;
targetColor
.
a
=
alpha
;
target
.
color
=
targetColor
;
var
a
=
pair
.
Value
;
var
t
=
pair
.
Key
;
a
.
percent
=
percent
;
t
.
color
=
a
.
CalculateColor
(
t
.
color
);
}
foreach
(
var
target
in
mesh
Target
s
)
foreach
(
var
pair
in
mesh
Alpha
s
)
{
Color
targetColor
=
target
.
material
.
color
;
targetColor
.
a
=
alpha
;
target
.
material
.
color
=
targetColor
;
var
a
=
pair
.
Value
;
var
m
=
pair
.
Key
;
a
.
percent
=
percent
;
m
.
material
.
color
=
a
.
CalculateColor
(
m
.
material
.
color
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment