当前位置:网站首页>Unity skframework framework (XXIII), minimap small map tool

Unity skframework framework (XXIII), minimap small map tool

2022-07-05 09:24:00 CoderZ1010

Catalog

brief introduction

Realization principle

Instructions


brief introduction

MiniMap It can help us quickly realize the function of small map , The tool has been uploaded to my development framework SKFramework Medium Package Manager In the development kit manager , As shown in the figure , Click on the bottom right corner Install Button to download and install .

SKFramework Framework open source address :

https://github.com/136512892/SKFramework

Realization principle

1. Take... In the scene z The positive direction of the axis is up 、 With x The positive direction of the axis is right ;

2. Take the lower left corner and the upper right corner of the scene as two benchmarks , Record as leftBottom、rightTop;

3. Put the... Of the target object in the scene Transform Record as target3d;

4. Will represent the target object in the interface Icon Icon's RectTransform Record as target2d;

5. Put the small map RectTransform Component record is mapRt;

6. Divide the length of the mini map by the length of the scene to get the proportion in the horizontal direction ;

(mapRt.rect.width / (rightTop.position.x - leftBottom.position.x))

7. Divide the width of the mini map by the width of the scene to get the proportion in the vertical direction ;

(mapRt.rect.height / (rightTop.position.z - leftBottom.position.z))

8. Calculate the length and width of the three-dimensional target object from the base point of the lower left corner , Record as horizontal、vertical;

(horizontal = target3d.position.x - leftBottom.position.x)

(vertical = target3d.position.z - leftBottom.position.z)

9. Calculate in the small map Icon The length and width of the icon from the lower left corner , Record as x、y;

(x = horizontal * Proportion in horizontal direction )

(y = vertical * Scale in the vertical direction )

10.Icon Icon sets the anchor to the lower left corner , Set its position .

(target2d.anchoredPosition = new Vector(x, y))

Instructions

isEnableRot:Icon Whether the icon rotates with the rotation of the 3D target

isEnableRotLerp: Whether to use interpolation operation when calculating rotation value

rotationLerpTime: The time required to interpolate to the target angle

原网站

版权声明
本文为[CoderZ1010]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207050920537097.html