You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.7 KiB
62 lines
1.7 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using SimplexNoise;
|
|
using System;
|
|
namespace UnityEngine.UCMobile
|
|
{
|
|
[Serializable]
|
|
public class UCNoise : UCMobileModel
|
|
{
|
|
[Serializable]
|
|
public struct Settings
|
|
{
|
|
[Tooltip("pos scale with noise")]
|
|
public float pos_scale;
|
|
[Tooltip("time scale with noise")]
|
|
public float time_scale;
|
|
|
|
public static Settings defaultSettings
|
|
{
|
|
get
|
|
{
|
|
return new Settings
|
|
{
|
|
pos_scale = 1,
|
|
time_scale = 1
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
[SerializeField]
|
|
Settings m_Settings = Settings.defaultSettings;
|
|
public Settings settings
|
|
{
|
|
get { return m_Settings; }
|
|
set { m_Settings = value; }
|
|
}
|
|
|
|
public Vector3 _calc_perlin_dir(Vector3 _position)
|
|
{
|
|
Vector3 noise_pos = _position * m_Settings.pos_scale;
|
|
float noise_time = Time.time * m_Settings.time_scale;
|
|
float vx = Noise.Generate(noise_pos.x + noise_time, noise_pos.y, noise_pos.z);
|
|
float vy = Noise.Generate(noise_pos.x, noise_pos.y + noise_time, noise_pos.z);
|
|
float vz = Noise.Generate(noise_pos.x, noise_pos.y, noise_pos.z + noise_time);
|
|
return new Vector3(vx, vy, vz);
|
|
}
|
|
|
|
public override void Reset()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public override void DoBehavier(GameObject obj)
|
|
{
|
|
obj.transform.position += _calc_perlin_dir(obj.transform.position);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|