当前位置:网站首页>Project records

Project records

2022-06-11 02:18:00 Xia 78

1、 Set lens rotation and limit

    void RotateCamera()
    {
        transform.RotateAround(CenObj.position, Vector3.up, Input.GetAxis("Mouse X") * 5);

        transform.RotateAround(CenObj.position, transform.right, -Input.GetAxis("Mouse Y") * 5);
        //  Affected position and rotation

        // Limit the range of the viewing angle moving up and down 
        float x = transform.eulerAngles.x;
        if (x < 0 || x > 85)
        {

            transform.position = originalPos;
            transform.rotation = originalRotation;
        }
    }

2、Do Tween Multiple rotations occur when the closing lens is pulled closer to the characteristic angle :
The lens z Axis settings 0

3、 Set up UI Occlusion :
if (EventSystem.current.IsPointerOverGameObject()) return;

4、 Get the current time :
System.DateTime.Now

5、text Write read

using UnityEngine;
using System.IO;

public class Error : MonoBehaviour
{

    string comduankou;

    void Start()
    {
        comduankou = Application.streamingAssetsPath + "/error.txt";

        Write();
        Read();

    }

    /// <summary>
    ///  Write data 
    /// </summary>
    void Write() 
    {
        StreamWriter textWriter = new StreamWriter(comduankou, true);
        string test2 = "\n" + System.DateTime.Now + " write in ";
        textWriter.Write(test2);
        textWriter.Close();
        textWriter.Dispose();
    }

    /// <summary>
    ///  Reading data 
    /// </summary>
    void Read() 
    {
        TextReader textReader1 = new StreamReader(comduankou);
        string test1 = textReader1.ReadToEnd();
        print(test1);
    }

}

6、 Set sub object index

    int count = parentTransform.childCount;
    // The parameter is the order of the object in the current sub object list 
    //count-1 To point to child The order of objects in the current sub object list is set to the last ,0 For the first time 
    childTransform.SetSiblingIndex(count - 1);

7、 Set scene sharpness

XRSettings.eyeTextureResolutionScale = 1f;// The standard value is 1

8、Physics.IgnoreCollision Ignore collisions

Physics.IgnoreCollision(Collider A,Collider B)

Ignore Colliders A and B The collision between (start/Update Fine )

9、 Get the current scene name

 sceneName = SceneManager.GetActiveScene().name;

10、C# String ------string Of IsNullOrEmpty Method
@ Be careful ,IsNullOrEmpty The judgment object cannot be empty , Not for "". If the object is empty or "“ All back to true.
string.IsNullOrEmpty(null)— return true
string.IsNullOrEmpty(”")— return true
string.IsNullOrEmpty(“sss”)— return false
— Be careful , When judging , return false, It means that the object is neither empty nor "".

原网站

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