Skip to content
Navigation Menu
Toggle navigation
Sign in
Product
Actions
Automate any workflow
Packages
Host and manage packages
Security
Find and fix vulnerabilities
Codespaces
Instant dev environments
GitHub Copilot
Write better code with AI
Code review
Manage code changes
Issues
Plan and track work
Discussions
Collaborate outside of code
Explore
All features
Documentation
GitHub Skills
Blog
Solutions
By size
Enterprise
Teams
Startups
By industry
Healthcare
Financial services
Manufacturing
By use case
CI/CD & Automation
DevOps
DevSecOps
Resources
Resources
Learning Pathways
White papers, Ebooks, Webinars
Customer Stories
Partners
Open Source
GitHub Sponsors
Fund open source developers
The ReadME Project
GitHub community articles
Repositories
Topics
Trending
Collections
Enterprise
Enterprise platform
AI-powered developer platform
Available add-ons
Advanced Security
Enterprise-grade security features
GitHub Copilot
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search or jump to...
Search code, repositories, users, issues, pull requests...
Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Saved searches
Use saved searches to filter your results more quickly
Sign in
Sign up
{{ message }}
Laateu
/
tarthechie
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
Pull requests
Actions
Projects
Security
Insights
Additional navigation options
Files
main
C#
BlackOut.cs
CSS
Images
JavaScript
Musics
README.md
antipodes.html
checkpoint.html
chill.html
game.html
games.html
index.html
introduction.html
js.html
kadai.html
musics.html
studies.html
studies_list.html
tex_fix.html
yakitori.css
yakitori.html
Breadcrumbs
tarthechie
/
C#
/
BlackOut.cs
Blame
Blame
Latest commit
Laateu
Update BlackOut.cs
Jun 26, 2024
d41fd92
·
Jun 26, 2024
History
History
33 lines (29 loc) · 851 Bytes
Breadcrumbs
tarthechie
/
C#
/
BlackOut.cs
Top
File metadata and controls
Code
Blame
33 lines (29 loc) · 851 Bytes
Raw
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class BlackOut : MonoBehaviour { private Image image; void Start() { image = GetComponent<Image>(); image.color= new Color32(0,0,0,0); } void Update() { if(Input.GetKeyDown(KeyCode.A)){ StartCoroutine(Black_Out(5.0f,100)); } } IEnumerator Black_Out(float time,int N){ int alpha = 0; //アルファ値 float step = time / N; //1ループでのアルファ値の変化幅 /* ループ */ for (int i = 0;i < N;i++){ alpha = 255 * (i + 1) / N; image.color = new Color32(0, 0, 0, (byte)alpha); yield return new WaitForSeconds(step); //ウェイト } } }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using
System
.
Collections
;
using
System
.
Collections
.
Generic
;
using
UnityEngine
;
using
UnityEngine
.
UI
;
public
class
BlackOut
:
MonoBehaviour
{
private
Image
image
;
void
Start
(
)
{
image
=
GetComponent
<
Image
>
(
)
;
image
.
color
=
new
Color32
(
0
,
0
,
0
,
0
)
;
}
void
Update
(
)
{
if
(
Input
.
GetKeyDown
(
KeyCode
.
A
)
)
{
StartCoroutine
(
Black_Out
(
5.0f
,
100
)
)
;
}
}
IEnumerator
Black_Out
(
float
time
,
int
N
)
{
int
alpha
=
0
;
//アルファ値
float
step
=
time
/
N
;
//1ループでのアルファ値の変化幅
/* ループ */
for
(
int
i
=
0
;
i
<
N
;
i
++
)
{
alpha
=
255
*
(
i
+
1
)
/
N
;
image
.
color
=
new
Color32
(
0
,
0
,
0
,
(
byte
)
alpha
)
;
yield
return
new
WaitForSeconds
(
step
)
;
//ウェイト
}
}
}
While the code is focused, press Alt+F1 for a menu of operations.