블로그 이미지
Every unexpected event is a path to learning for you. blueasa

카테고리

분류 전체보기 (2835)
Unity3D (883)
Script (93)
Extensions (16)
Effect (3)
NGUI (81)
UGUI (9)
Physics (2)
Shader (39)
Math (1)
Design Pattern (2)
Xml (1)
Tips (203)
Link (26)
World (1)
AssetBundle (25)
Mecanim (2)
Plugins (85)
Trouble Shooting (71)
Encrypt (7)
LightMap (4)
Shadow (4)
Editor (12)
Crash Report (3)
Utility (9)
UnityVS (2)
Facebook SDK (2)
iTween (3)
Font (18)
Ad (14)
Photon (2)
IAP (1)
Google (11)
URP (4)
Android (51)
iOS (46)
Programming (479)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (188)
협업 (64)
3DS Max (3)
Game (12)
Utility (140)
Etc (99)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (52)
Android (16)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (19)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday

[펌] Unity Timers

Unity3D/Plugins / 2021. 10. 20. 14:23

 

 

 

We may decide to execute a function not right now, but at a certain time later. That’s called “scheduling a call”. The Timers class helps you to do so with a clean and short syntax without having to worry about enumerators.

Installation · Documentation · License

Made with ♥ by Jeffrey Lanters

 

Installation

Using the Unity Package Manager

Install the latest stable release using the Unity Package Manager by adding the following line to your manifest.json file located within your project's Packages directory, or by adding the Git URL to the Package Manager Window inside of Unity.

"nl.elraccoone.timers": "git+https://github.com/jeffreylanters/unity-timers"

Using OpenUPM

The module is availble on the OpenUPM package registry, you can install the latest stable release using the OpenUPM Package manager's Command Line Tool using the following command.

openupm add nl.elraccoone.timers

Documentation

Syntax

using ElRaccoone.Timers;
Timers.SetTimeout(/* miliseconds */ 1000, /* callback */ () => { /* ... */ });
Timers.SetInterval(/* miliseconds */ 1000, /* callback */ () => { /* ... */ });

Description

We may decide to execute a function not right now, but at a certain time later. That’s called “scheduling a call”. Note that the timers are using unscaled time.

There are two methods for it:

  • setTimeout allows to run a function once after the interval of time.
  • setInterval allows to run a function regularly with the interval between the runs.

Examples

public class MyClass {
  private void Awake () {
    Timers.SetTimeout(1000, () => {
      Debug.Log("A second has passed!");
    });
    Timers.SetTimeout(1000, Notifiy);
    Timers.SetInterval(2500, Notifiy);
  }
  private void Notify () {
    Debug.Log("Notify!!");
  }
}

 

 

[출처] https://openupm.com/packages/nl.elraccoone.timers/#installation

 

📦 Timers - nl.elraccoone.timers

 

openupm.com

 

반응형

'Unity3D > Plugins' 카테고리의 다른 글

[Package] Unity Quick Search  (0) 2022.02.18
[링크] UniTask  (0) 2022.01.11
[펌] Unity Bezier Solution  (0) 2021.10.12
[에셋] I2 Localization(Android/iOS app_name Localization)  (0) 2021.02.25
[링크] 유니티 Easy Save 정리  (2) 2020.04.03
Posted by blueasa
, |

Unity Bezier Solution

Available on Asset Store: https://assetstore.unity.com/packages/tools/level-design/bezier-solution-113074

Forum Thread: https://forum.unity.com/threads/bezier-solution-open-source.440742/

Video: https://www.youtube.com/watch?v=OpniwcFwSY8

Support the Developer ☕

ABOUT

This asset is a means to create bezier splines in editor and/or during runtime: splines can be created and edited visually in the editor, or by code during runtime. It is built upon Catlike Coding's spline tutorial: https://catlikecoding.com/unity/tutorials/curves-and-splines/

INSTALLATION

There are 5 ways to install this plugin:

CREATING & EDITING A NEW SPLINE IN EDITOR

To create a new spline in the editor, click GameObject - Bezier Spline.

Now you can select the end points of the spline in the Scene view and translate/rotate/scale or delete/duplicate them as you wish (each end point has 2 control points, which can also be translated):

The user interface for the spline editor should be pretty self-explanatory with most variables having explanatory tooltips.

When Quick Edit Mode is enabled, new points can quickly be added/inserted to the spline and the existing points can be dragged around/snapped to the scene geometry.

To reverse the order of the end points in a spline, you can right click the BezierSpline component and click the Invert Spline button.

You can tweak the Scene view gizmos via Project Settings/yasirkula/Bezier Solution page (on older versions, this menu is located at Preferences window).

CREATING & EDITING A NEW SPLINE BY CODE

  • Create a new bezier spline

Simply create a new GameObject, attach a BezierSpline component to it (BezierSpline uses BezierSolution namespace) and initialize the spline with a minimum of two end points:

BezierSpline spline = new GameObject().AddComponent<BezierSpline>(); spline.Initialize( 2 );

  • Populate the spline

BezierPoint InsertNewPointAt( int index ): adds a new end point to the spline and returns it

BezierPoint DuplicatePointAt( int index ): duplicates an existing end point and returns it

void RemovePointAt( int index ): removes an end point from the spline

void SwapPointsAt( int index1, int index2 ): swaps indices of two end points

void ChangePointIndex( int previousIndex, int newIndex ): changes an end point's index

  • Shape the spline

You can change the position, rotation, scale and normal values of the end points, as well as the positions of their control points to reshape the spline.

End points have the following properties to store their transformational data: position, localPosition, rotation, localRotation, eulerAngles, localEulerAngles, localScale, normal and autoCalculatedNormalAngleOffset.

Positions of control points can be tweaked using the following properties in BezierPoint: precedingControlPointPosition, precedingControlPointLocalPosition, followingControlPointPosition and followingControlPointLocalPosition. The local positions are relative to their corresponding end points.

End points also have read-only spline and index properties.

// Set first end point's (world) position to 2,3,5 spline[0].position = new Vector3( 2, 3, 5 ); // Set second end point's local position to 7,11,13 spline[1].localPosition = new Vector3( 7, 11, 13 ); // Set handle mode of first end point to Free to independently adjust each control point spline[0].handleMode = BezierPoint.HandleMode.Free; // Reposition the control points of the first end point spline[0].precedingControlPointLocalPosition = new Vector3( 0, 0, 1 ); spline[0].followingControlPointPosition = spline[1].position;

  • Auto construct the spline

If you don't want to position all the control points manually, but rather generate a nice-looking "continuous" spline that goes through the end points you have created, you can call either AutoConstructSpline() or AutoConstructSpline2(). These methods are implementations of some algorithms found on the internet (and credited in the source code). If you want these functions to be called automatically when spline's end points are modified, simply change the spline's autoConstructMode property.

  • Convert spline to a linear path

If you want to create a linear path between the end points of the spline, you can call the ConstructLinearPath() function. Or, if you want this function to be called automatically when spline's end points are modified, simply set the spline's autoConstructMode property to SplineAutoConstructMode.Linear.

  • Auto calculate the normals

If you want to calculate the spline's normal vectors automatically, you can call the AutoCalculateNormals( float normalAngle = 0f, int smoothness = 10 ) function (or, to call this function automatically when spline's end points are modified, simply change the spline's autoCalculateNormals and autoCalculatedNormalsAngle properties). All resulting normal vectors will be rotated around their Z axis by "normalAngle" degrees. Additionally, each end point's normal vector will be rotated by that end point's "autoCalculatedNormalAngleOffset" degrees. "smoothness" determines how many intermediate steps are taken between each consecutive end point to calculate those end points' normal vectors. More intermediate steps is better but also slower to calculate.

If auto calculated normals don't look quite right despite modifying the "normalAngle" (Auto Calculated Normals Angle in the Inspector) and "autoCalculatedNormalAngleOffset" (Normal Angle in the Inspector) variables, you can either consider inserting new end points to the sections of the spline that normals don't behave correctly, or setting the normals manually.

  • Get notified when spline is modified

You can register to the spline's onSplineChanged event to get notified when some of its properties have changed. This event has the following signature: delegate void SplineChangeDelegate( BezierSpline spline, DirtyFlags dirtyFlags ). DirtyFlags is an enum flag, meaning that it can have one or more of these values: SplineShapeChanged, NormalsChanged and/or ExtraDataChanged. SplineShapeChanged flag means that either the spline's Transform values have changed or some of its end points' Transform values have changed (changing control points may also trigger this flag). NormalsChanged flag means that normals of some of the end points have changed and ExtraDataChanged flag means that extraDatas of some of the end points have changed.

BezierSpline also has a version property which is automatically increased whenever the spline's properties change.

NOTE: onSplineChanged event is usually invoked in LateUpdate. Before it is invoked, autoConstructMode and autoCalculateNormals properties' values are checked and the relevant auto construction/calculation functions are executed if necessary.

UTILITY FUNCTIONS

The framework comes with some utility functions. These functions are not necessarily perfect but most of the time, they get the job done. Though, if you want, you can use this framework to just create splines and then apply your own logic to them.

  • Vector3 GetPoint( float normalizedT )

A spline is essentially a mathematical formula with a [0,1] clamped input (usually called t), which generates a point on the spline. As the name suggests, this function returns a point on the spline. As t goes from 0 to 1, the point moves from the first end point to the last end point (or goes back to first end point, if spline is looping).

  • Vector3 GetTangent( float normalizedT )

Tangent is calculated using the first derivative of the spline formula and gives the direction of the movement at a given point on the spline. Can be used to determine which direction an object on the spline should look at at a given point.

  • Vector3 GetNormal( float normalizedT )

Interpolates between the end points' normal vectors. Note that this plugin doesn't store any intermediate data between end point pairs, so if two consecutive end points have almost the opposite tangents, then their interpolated normal vector may not be correct at some parts of the spline. Inserting a new end point between these two end points could resolve this issue. By default, all normal vectors have value (0,1,0).

  • BezierPoint.ExtraData GetExtraData( float normalizedT )

Interpolates between the extra data provided at each end point. This data has 4 float components and can implicitly be converted to Vector2, Vector3, Vector4, Quaternion, Rect, Vector2Int, Vector3Int and RectInt.

  • BezierPoint.ExtraData GetExtraData( float normalizedT, ExtraDataLerpFunction lerpFunction )

Uses a custom function to interpolate between the end points' extra data. For example, BezierWalker components use this function to interpolate the extra data with Quaternion.Lerp.

  • float GetLengthApproximately( float startNormalizedT, float endNormalizedT, float accuracy = 50f )

Calculates the approximate length of a segment of the spline. To calculate the length, the spline is divided into "accuracy" points and the Euclidean distances between these points are summed up.

Food For Thought: BezierSpline has a length property which is a shorthand for GetLengthApproximately( 0f, 1f ). Its value is cached and won't be recalculated unless the spline is modified.

  • Segment GetSegmentAt( float normalizedT )

Returns the two end points that are closest to normalizedT. The Segment struct also holds a localT value in range [0,1], which can be used to interpolate between the properties of these two end points. You can also call the GetPoint(), GetTangent(), GetNormal() and GetExtraData() functions of this struct and the returned values will be calculated as if the spline consisted of only these two end points.

  • Vector3 FindNearestPointTo( Vector3 worldPos, out float normalizedT, float accuracy = 100f, int secondPassIterations = 7, float secondPassExtents = 0.025f )

Finds the nearest point on the spline to any given point in 3D space. The normalizedT parameter is optional and it returns the parameter t corresponding to the resulting point. To find the nearest point, the spline is divided into "accuracy" points and the nearest point is selected. Then, a binary search is performed in "secondPassIterations" steps in range [normalizedT-secondPassExtents, normalizedT+secondPassExtents] to fine-tune the result.

  • Vector3 FindNearestPointToLine( Vector3 lineStart, Vector3 lineEnd, out Vector3 pointOnLine, out float normalizedT, float accuracy = 100f, int secondPassIterations = 7, float secondPassExtents = 0.025f )

Finds the nearest point on the spline to the given line in 3D space. The pointOnLine and normalizedT parameters are optional.

  • Vector3 MoveAlongSpline( ref float normalizedT, float deltaMovement, int accuracy = 3 )

Moves a point (normalizedT) on the spline deltaMovement units ahead and returns the resulting point. The normalizedT parameter is passed by reference to keep track of the new t parameter.

  • EvenlySpacedPointsHolder CalculateEvenlySpacedPoints( float resolution = 10f, float accuracy = 3f )

Finds uniformly distributed points along the spline and returns a lookup table. The lookup table isn't refreshed automatically, so it may be invalidated when the spline is modified. This function's resolution parameter determines approximately how many points will be calculated per each segment of the spline and accuracy determines how accurate the uniform spacing will be. The default values should work well in most cases.

Food For Thought: BezierSpline has an evenlySpacedPoints property which is a shorthand for CalculateEvenlySpacedPoints(). Its value is cached and won't be recalculated unless the spline is modified.

EvenlySpacedPointsHolder class has spline, splineLength and uniformNormalizedTs variables. In addition, it has the following convenience functions:

GetNormalizedTAtPercentage: converts a percentage to normalizedT value, i.e. if you enter 0.5f as parameter, it will return the normalizedT value of the spline that corresponds to its actual middle point.

GetNormalizedTAtDistance: finds the normalizedT value that is specified units away from the spline's starting point.

GetPercentageAtNormalizedT: inverse of GetNormalizedTAtPercentage.

  • PointCache GeneratePointCache( EvenlySpacedPointsHolder lookupTable, ExtraDataLerpFunction extraDataLerpFunction, PointCacheFlags cachedData = PointCacheFlags.All, int resolution = 100 )

Returns a cache of data for uniformly distributed points along the spline. The cache isn't refreshed automatically, so it may be invalidated when the spline is modified. This function's resolution parameter determines how many uniformly distributed points the cache will have. To determine which data should be cached, cachedData parameter is used. PointCacheFlags is an enum flag, meaning that it can have one or more of these values: Positions, Normals, Tangents, Bitangents and/or ExtraDatas. lookupTable is an optional parameter and, by default, spline's evenlySpacedPoints is used. extraDataLerpFunction is also an optional parameter and is used only when PointCacheFlags.ExtraDatas is included in cachedData.

Food For Thought: BezierSpline has a pointCache property which is a shorthand for GeneratePointCache(). Its value is cached and won't be recalculated unless the spline is modified.

PointCache class has positions, normals, tangents, bitangents, extraDatas and loop variables (loop determines whether or not the spline had its loop property set to true while calculating the cache). In addition, it has the following functions: GetPoint, GetNormal, GetTangent, GetBitangent and GetExtraData (if the required data for a function wasn't included in PointCacheFlags, then the function will throw an exception). If a spline is rarely modified at runtime, then point cache can be used to get points, tangents, normals, etc. along the spline in a cheaper and uniform way.

OTHER COMPONENTS

The plugin comes with some additional components that may help you move objects or particles along splines. These components are located in the Utilities folder.

  • BezierWalkerWithSpeed

Moves an object along a spline with constant speed. There are 3 travel modes: Once, Ping Pong and Loop. If Look At is Forward, the object will always face forwards (end points' normal vectors will be used as up vectors). If it is SplineExtraData, the extra data stored in the spline's end points is used to determine the rotation. You can modify this extra data from the points' Inspector. The smoothness of the rotation can be adjusted via Rotation Lerp Modifier. Normalized T determines the starting point. Each time the object completes a lap, its On Path Completed () event is invoked. To see this component in action without entering Play mode, click the Simulate In Editor button.

  • BezierWalkerWithTime

Travels a spline in Travel Time seconds. Movement Lerp Modifier parameter defines the smoothness applied to the position of the object. If High Quality is enabled, the spline will be traversed with constant speed but the calculations can be more expensive.

  • BezierWalkerLocomotion

Allows you to move a number of objects together with this object on a spline. This component must be attached to an object with a BezierWalker component (tail objects don't need a BezierWalker, though). Look At, Movement Lerp Modifier and Rotation Lerp Modifier parameters affect the tail objects. If tail objects jitter too much, enabling High Quality may help greatly but the calculations can be more expensive.

  • ParticlesFollowBezier

Moves particles of a Particle System in the direction of a spline. It is recommended to set the Simulation Space of the Particle System to Local for increased performance. This component affects particles in one of two ways:

Strict: particles will strictly follow the spline. They will always be aligned to the spline and will reach the end of the spline at the end of their lifetime. This mode performs slightly better than Relaxed mode

Relaxed: properties of the particle system like speed, Noise and Shape will affect the movement of the particles. Particles in this mode will usually look more interesting. If you want the particles to stick with the spline, though, set their speed to 0

Note that if the Resimulate tick of the Particle System is selected, particles may move in a chaotic way for a short time while changing the properties of the particle system from the Inspector.

  • BezierAttachment

Snaps an object to the specified point of the spline. You can snap the object's position and/or rotation values, optionally with some offsets. Rotation can be snapped in one of two ways:

Use Spline Normals: spline's normal vectors will be used to determine the object's rotation

Use End Point Rotations: the Transform rotation values of the spline's end points will be used to determine the object's rotation

  • BezierLineRenderer

Automatically positions a Line Renderer's points so that its shape matches the target spline's shape. It is possible to match the shape of only a portion of the spline by tweaking the Spline Sample Range property. If Line Renderer's Use World Space property is enabled, then its points will be placed at the spline's current position. Otherwise, the points will be placed relative to the Line Renderer's position and they will rotate/scale with the Line Renderer.

  • BendMeshAlongBezier

Modifies a MeshFilter's mesh to bend it in the direction of a spline. If High Quality is enabled, evenly spaced bezier points will be used so that the mesh bends uniformly but the calculations will be more expensive. If Auto Refresh is enabled, the mesh will be refreshed automatically when the spline is modified (at runtime, this has the same effect with disabling the component but in edit mode, disabling the component will restore the original mesh instead). Mesh's normal and tangent vectors can optionally be recalculated in one of two ways:

Modify Originals: the original mesh's normal and tangent vectors will be rotated with the spline

Recalculate From Scratch: Unity's RecalculateNormals and/or RecalculateTangents functions will be invoked to recalculate these vectors from scratch

Note that this component doesn't add new vertices to the original mesh, so if the original mesh doesn't have enough vertices in its bend axis, then the bent mesh will have jagged edges on complex splines.

 

 

[출처] https://openupm.com/packages/com.yasirkula.beziersolution/

 

📦 Bezier Solution - com.yasirkula.beziersolution

 

openupm.com

 

반응형
Posted by blueasa
, |

[첨언]

예전에 사놓은건데 Android/iOS app_name Localization(현지화)을 지원한다길래 써보니..편하다!!

 

 

[에셋스토어 링크] assetstore.unity.com/packages/tools/localization/i2-localization-14884

 

I2 Localization | 다국어 지원 | Unity Asset Store

Get the I2 Localization package from Inter Illusion and speed up your game development process. Find this & other 다국어 지원 options on the Unity Asset Store.

assetstore.unity.com

 

반응형
Posted by blueasa
, |

[링크] https://mentum.tistory.com/156

 

유니티 Easy Save 정리

# 20190329 추가 : 개발자는 EasySave 2는 호환성 때문에 남겨놓은 것이기 때문에 EasySave 3를 사용해줄 것을 당부했음. #. EasySave 간단 정리 - Class, Structure 등 어떤 것이든 저장할 수 있습니다! - Save /..

mentum.tistory.com

 

반응형
Posted by blueasa
, |

[링크]

http://blog.naver.com/simtt/220851899973

 

[Unity] 유니티 Local Notification을 활용해보자

iOS의 경우 Unity 자체에서 로컬 알람 기능을 제공해준다. 안드로이드는 직접 구현할 수도 있지만, 그냥...

blog.naver.com

 

반응형
Posted by blueasa
, |

 

[링크]

https://lib.dasony.net/7

 

[NATIVE, ANDROID] Local Notification(로컬 알림) 유니티 플러그인

개요 유니티에서 네이티브 알림 기능을 iOS 만 제공하고 있습니다. 안드로이드에서 로컬 알림을 이용하려면 플러그인을 직접 제작하거나 다른 사람이 만들어 둔 플러그인을 사용해야 합니다. 이번에 다소니닷넷에..

lib.dasony.net

 

반응형
Posted by blueasa
, |

Unity Local Notification (For android)

This repository allows to send local notification from unity project on android devices.

Features

  • you can send local notification in android
  • you can schedule sending notification for some time in future
  • you can send notification having big picture style

Issues

  • not all android notification features are supported

Sample code

Publisher publisher = PublisherManager.Instance.CreatePublisher(channelId, channelName, channelDescription); // put your icon png file in Plugins/Android/UnityLocalNotification/res/drawable Notification notification = new Notification() .SmallIconName("test_icon") .Title("My notif title") .Message("This is a test notification message"); publisher.Publish(notification);

Screenshots

Unity asset

Unity local notification asset

Class diagram

class diagram

 

 

[출처] https://unitylist.com/p/g72/Unity-Local-Notification

 

Unity Local Notification

Send Android local notification from unity project source code

unitylist.com

 

반응형
Posted by blueasa
, |

 

[링크]

https://github.com/setchi/FancyScrollView

 

setchi/FancyScrollView

A scrollview component that can implement highly flexible animation. - setchi/FancyScrollView

github.com

 

FancyScrollView 

English (by Google Translate)

高度に柔軟なアニメーションを実装できる汎用の ScrollView コンポーネントです。 無限スクロールもサポートしています。

 

 

Requirements

Installation

Unity Asset Store

Asset Store からパッケージをプロジェクトにインストールします。

Unity Package Manager (Example scenes not included)

プロジェクトディレクトリの Packages/manifest.json ファイルにリポジトリへの参照を追加します。

{ "dependencies": { "jp.setchi.fancyscrollview": "https://github.com/setchi/FancyScrollView.git#upm" } }

Manual

このリポジトリを Clone または Download します。

Features

自由にスクロールアニメーションを実装できます

FancyScrollView はセルの位置を更新するとき、可視領域の正規化された値を各セルに渡します。セル側では、0.0 ~ 1.0 の値に基づいてスクロールの外観を自由に制御できます。サンプルでは Animator を使用してセルの動きを制御しています。

データ件数が多くても軽快に動作します

表示に必要なセル数のみが生成され、セルは再利用されます。

セルとスクロールビュー間で自由にメッセージのやりとりができます

Context 経由で、セルがクリックされたことをスクロールビューで検知したり、スクロールビューからセルに指示を出す処理がシンプルに実装できます。実装例(Examples/02_FocusOn)が含まれていますので、参考にしてください。

特定のセルにスクロールやジャンプができます

移動にかける秒数や Easing の指定もできます。詳しくは API Reference の Scroller - Methods を参照してください。

スクロールの挙動を細かく設定できます

慣性の有無、減速率などスクロールに関する挙動の設定ができます。詳しくは API Reference の Scroller - Inspector を参照してください。

スナップをサポートしています

スナップを有効にすると、スクロールが止まる直前に最寄りのセルへ移動します。スナップがはじまる速度のしきい値、移動にかける秒数、 Easing を指定できます。

無限スクロールをサポートしています

Inspector で下記の設定をすることで無限スクロールを実装できます。

  1. FancyScrollView  Loop をオンにするとセルが循環し、先頭のセルの前に末尾のセル、末尾のセルの後に先頭のセルが並ぶようになります。
  2. サンプルで使用されている Scroller を使うときは、 Movement Type  Unrestricted に設定することで、スクロール範囲が無制限になります。 1. と組み合わせることで無限スクロールを実現できます。

実装例(Examples/03_InfiniteScroll)が含まれていますので、こちらも参考にしてください。

Examples

FancyScrollView/Examples を参照してください。

NameDescription

01_Basic 最もシンプルな構成の実装例です。
02_FocusOn ボタンで左右のセルにフォーカスする実装例です。
03_InfiniteScroll 無限スクロールの実装例です。

Usage

もっともシンプルな構成では、

  • セルにデータを渡すためのオブジェクト
  • セル
  • スクロールビュー

の実装が必要です。

Implementation

セルにデータを渡すためのオブジェクトを定義します。

public class ItemData { public string Message; }

FancyScrollViewCell<TItemData> を継承して自分のセルを実装します。

using UnityEngine; using UnityEngine.UI; using FancyScrollView; public class MyScrollViewCell : FancyScrollViewCell<ItemData> { [SerializeField] Text message = default; public override void UpdateContent(ItemData itemData) { message.text = itemData.Message; } public override void UpdatePosition(float position) { // position は 0.0 ~ 1.0 の値です // position に基づいてスクロールの外観を自由に制御できます } }

FancyScrollView<TItemData> を継承して自分のスクロールビューを実装します。

using UnityEngine; using System.Linq; using FancyScrollView; public class MyScrollView : FancyScrollView<ItemData> { [SerializeField] Scroller scroller = default; [SerializeField] GameObject cellPrefab = default; protected override GameObject CellPrefab => cellPrefab; void Start() { scroller.OnValueChanged(base.UpdatePosition); } public void UpdateData(IList<ItemData> items) { base.UpdateContents(items); scroller.SetTotalCount(items.Count); } }

スクロールビューにデータを流し込みます。

using UnityEngine; using System.Linq; public class EntryPoint : MonoBehaviour { [SerializeField] MyScrollView myScrollView = default; void Start() { var items = Enumerable.Range(0, 20) .Select(i => new ItemData {Message = $"Cell {i}"}) .ToArray(); myScrollView.UpdateData(items); } }


API Reference

FancyScrollView<TItemData, TContext>

セルを制御するスクロールビューの抽象基底クラスです。

public abstract class FancyScrollView<TItemData, TContext> : MonoBehaviour where TContext : class, new()

Context が不要な場合はこちらを使用します。

public abstract class FancyScrollView<TItemData> : FancyScrollView<TItemData, FancyScrollViewNullContext>

Inspector

TypeNameSummary

float Cell Spacing セル同士の間隔を float.Epsilon ~ 1.0 の間で指定します.
float Scroll Offset スクロールのオフセットを指定します.たとえば、 0.5 を指定してスクロール位置が 0 の場合、最初のセルの位置は 0.5 になります.
bool Loop オンにするとセルが循環し、最初のセルの前に最後のセル、最後のセルの後に最初のセルが並ぶようになります.無限スクロールさせたい場合はオンにします.
Transform Cell Container セルの親要素となる Transform を指定します.

Properties

TypeNameSummary

GameObject CellPrefab Cell prefab.
IList<TItemData> ItemsSource Items source.
TContext Context Context.

Methods

TypeNameSummary

void UpdateContents(IList<TItemData> itemsSource) Updates the contents.
void Refresh() Refreshes the cells.
void UpdatePosition(float position) Updates the scroll position.

FancyScrollViewCell<TItemData, TContext>

セルの抽象基底クラスです。

public abstract class FancyScrollViewCell<TItemData, TContext> : MonoBehaviour where TContext : class, new()

Context が不要な場合はこちらを使用します。

public abstract class FancyScrollViewCell<TItemData> : FancyScrollViewCell<TItemData, FancyScrollViewNullContext>

Properties

TypeNameSummary

int Index Gets or sets the index of the data.
bool IsVisible Gets a value indicating whether this cell is visible.
TContext Context Context.

Methods

TypeNameSummary

void SetupContext(TContext context) Setup the context.
void SetVisible(bool visible) Sets the visible.
void UpdateContent(TItemData itemData) Updates the content.
void UpdatePosition(float position) Updates the position.

Scroller

スクロール位置を制御するコンポーネントです。

public class Scroller : UIBehaviour, IBeginDragHandler, IEndDragHandler, IDragHandler

Inspector

TypeNameSummary

RectTransform Viewport ビューポートとなる RectTransform を指定します.ここで指定された RectTransform の範囲内でジェスチャーの検出を行います.
ScrollDirection Direction Of Recognize ジェスチャーを認識する方向を Vertical か Horizontal で指定します.
MovementType Movement Type コンテンツがスクロール範囲を越えて移動するときに使用する挙動を指定します.
float Elasticity コンテンツがスクロール範囲を越えて移動するときに使用する弾力性の量を指定します.
float Scroll Sensitivity スクロールの感度を指定します.
bool Inertia 慣性のオン/オフを指定します.
float Deceleration Rate Inertia がオンの場合のみ有効です.減速率を指定します.
bool Snap.Enable Snap を有効にする場合オンにします.
float Snap.Velocity Threshold Snap がはじまる閾値となる速度を指定します.
float Snap.Duration Snap 時の移動時間を秒数で指定します.
Ease Snap.Easing Snap 時の Easing を指定します.

Methods

TypeNameSummary

void OnValueChanged(Action<float> callback) スクロール位置が変化したときのコールバックを設定します.
void OnSelectionChanged(Action<int> callback) 選択セルが変化したときのコールバックを設定します.
void JumpTo(int index) 指定したセルまでジャンプします.
void ScrollTo(int index, float duration) 指定したセルまでスクロールします.
void ScrollTo(int index, float duration, Ease easing) 指定したセルまでスクロールします.
void ScrollTo(int index, float duration, Func<float, float> easingFunction) 指定したセルまでスクロールします.
void SetTotalCount(int totalCount) アイテムの総数を設定します. ( index: 0 ~ totalCount - 1 )

Author

setchi

License

MIT

반응형
Posted by blueasa
, |

[링크] https://bitbucket.org/vitaly_chashin/simpleunitybrowser

반응형
Posted by blueasa
, |


[링크]

https://themangs.tistory.com/entry/%EC%9C%A0%EB%8B%88%ED%8B%B0%EB%9E%91-nodejs-%EA%B0%84%EB%8B%A8-%EC%97%B0%EB%8F%99-%ED%85%8C%EC%8A%A4%ED%8A%B8-%ED%95%B4%EB%B3%B4%EA%B8%B0


[링크2]

https://github.com/NetEase/UnitySocketIO

반응형

'Unity3D > Plugins' 카테고리의 다른 글

[링크] FancyScrollView (CoverFlow)  (0) 2019.04.24
[링크] Simple Unity browser  (0) 2019.03.28
[펌] Socket.io-Client for Unity3D 소개  (0) 2019.03.08
[링크] iOSPlugin Sample  (0) 2019.01.29
[펌] Unity Excel Importer  (0) 2019.01.03
Posted by blueasa
, |