-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
Assets/JCSUnity/Scripts/Actions/Texture/JCS_RandomTextureAction.cs
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,55 @@ | ||
/** | ||
* $File: JCS_RandomTextureAction.cs $ | ||
* $Date: 2023-08-19 06:10:05 $ | ||
* $Revision: $ | ||
* $Creator: Jen-Chieh Shen $ | ||
* $Notice: See LICENSE.txt for modification and distribution information | ||
* Copyright (c) 2023 by Shen, Jen-Chieh $ | ||
*/ | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using MyBox; | ||
|
||
namespace JCSUnity | ||
{ | ||
public class JCS_RandomTextureAction : MonoBehaviour | ||
{ | ||
/* Variables */ | ||
|
||
private Renderer mRenderer = null; | ||
|
||
[Separator("Initialize Variables (JCS_RandomTextureAction)")] | ||
|
||
[Tooltip("List of textures to use.")] | ||
[SerializeField] | ||
public List<Texture> textures = null; | ||
|
||
/* Setter & Getter */ | ||
|
||
/* Functions */ | ||
|
||
private void Awake() | ||
{ | ||
this.mRenderer = this.GetComponent<Renderer>(); | ||
|
||
UpdateTexture(); | ||
} | ||
|
||
/// <summary> | ||
/// Randomly update the texture once. | ||
/// </summary> | ||
public void UpdateTexture() | ||
{ | ||
SetTexture(textures); | ||
} | ||
|
||
/// <summary> | ||
/// Update current texture with list of textures. | ||
/// </summary> | ||
public void SetTexture(List<Texture> textures) | ||
{ | ||
Texture tex = JCS_Random.ChooseOne(textures); | ||
mRenderer.material.SetTexture("_MainTex", tex); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/JCSUnity/Scripts/Actions/Texture/JCS_RandomTextureAction.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
docs/ScriptReference/Actions/Texture/JCS_RandomTextureAction.md
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,16 @@ | ||
# JCS_RandomTextureAction | ||
|
||
Trigger an event while the time is reached. | ||
|
||
## Variables | ||
|
||
| Name | Description | | ||
|:---------|:-------------------------| | ||
| textures | List of textures to use. | | ||
|
||
## Functions | ||
|
||
| Name | Description | | ||
|:--------------|:----------------------------------------------| | ||
| UpdateTexture | Randomly update the texture once. | | ||
| SetTexture | Update current texture with list of textures. | |