Gameplay Ingredients是一组用于 Unity 游戏的运行时和编辑器工具:一组脚本的集合,可在制作游戏和原型时简化简单的任务。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

34 行
1.0 KiB

using NaughtyAttributes;
using System;
using UnityEngine;
namespace GameplayIngredients.Actions
{
[Callable("Game", "Actions/ic-action-randomseed.png")]
public class SetRandomSeedAction : ActionBase
{
[Tooltip("Whether to set a new random seed, or a fixed seed")]
public bool newRandomSeed;
[DisableIf("newRandomSeed")]
[Tooltip("If New Random Seed is False. the new Random seed to apply")]
public int newSeed;
public override void Execute(GameObject instigator = null)
{
if(Manager.TryGet(out RandomManager randomManager))
{
if (newRandomSeed)
randomManager.SetRandomSeed(new System.Random((int)(DateTime.Now.Ticks - new DateTime(2021,1,1).Ticks)).Next());
else
randomManager.SetRandomSeed(newSeed);
}
}
public override string GetDefaultName()
{
return $"Set Random Seed :'{(newRandomSeed ? "New Seed at Random":newSeed.ToString())}'";
}
}
}