`
sooxin
  • 浏览: 257685 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Unity3D常用代码总结

 
阅读更多

 

1 GUI汇总

 

function OnGUI() {

  GUI.Label(Rect(1,1,100,20),"I'm a Label"); //1

  GUI.Box(Rect(1,21,100,20),"I'm a Box"); //2

  GUI.Button(Rect(1,41,100,20),"I'm a Button"); //3

  GUI.RepeatButton(Rect(1,61,120,20),"I'm a RepeatButton"); //4

  GUI.TextField(Rect(1,81,100,20),"I'm a TextFielld"); //5

  GUI.TextArea(Rect(1,101,100,40),"I'm a TextArea,\nMultiline"); //6

  GUI.Toggle(Rect(1,141,120,20),true,"I'm a Toggle true"); //7

  GUI.Toggle(Rect(1,161,120,20),false,"I'm a Toggle false"); //8

  GUI.Toolbar(Rect(1,181,160,20),-1,["Toolbar","Tool2","Tool3"); //9

  GUI.SelectionGrid(Rect(1,201,190,20),2,["Selection","Grid","select3"],3); //10

  GUI.HorizontalSlider(Rect(1,221,180,20),3.0,0,10.0); //11

  GUI.VerticalScrollbar(Rect(1,241,20,100),3.0,1,0.0,10.0); //12

 

  //13

  GUI.BeginScrollView (Rect (200,10,100,100),Vector2.zero, Rect (0, 0, 220, 200));

  GUI.Label(Rect(0,0,100,20),"I'm a Label");

  GUI.EndScrollView();

  //14

    GUI.Window(0,Rect(200,129,100,100),funcwin,"window");

}

 

function funcwin(windowID:int)

 {

  GUI.DragWindow(Rect(0,0,10000,2000));

 }

 

 

 

2 JS调用DLL

 

import System;

import System.Runtime.InteropServices;

@DllImport("user32.dll")

public static function MessageBox(Hwnd : int,text : String,Caption : String,iType : int) : int {};

 

function Start()

{

        MessageBox(0, "API Message Box", "Win32 API", 64) ;

}

function Update () {

}



3 物体标签

var target : Transform;  // Object that this label should follow

var offset = Vector3.up;    // Units in world space to offset; 1 unit above object by default
var clampToScreen = false;  // If true, label will be visible even if object is off screen
var clampBorderSize = .05;  // How much viewport space to leave at the borders when a label is being clamped
var useMainCamera = true;   // Use the camera tagged MainCamera
var cameraToUse : Camera;   // Only use this if useMainCamera is false
private var cam : Camera;
private var thisTransform : Transform;
private var camTransform : Transform;

function Start () {
    thisTransform = transform;
    if (useMainCamera)
        cam = Camera.main;
    else
        cam = cameraToUse;
    camTransform = cam.transform;
}

function Update () {
    if (clampToScreen) {
        var relativePosition = camTransform.InverseTransformPoint(target.position);
        relativePosition.z = Mathf.Max(relativePosition.z, 1.0);
        thisTransform.position = cam.WorldToViewportPoint(camTransform.TransformPoint(relativePosition + offset));
        thisTransform.position = Vector3(Mathf.Clamp(thisTransform.position.x, clampBorderSize, 1.0-clampBorderSize),
                                         Mathf.Clamp(thisTransform.position.y, clampBorderSize, 1.0-clampBorderSize),
                                         thisTransform.position.z);
    }
    else {
        thisTransform.position = cam.WorldToViewportPoint(target.position + offset);
    }
}
@script RequireComponent(GUIText)


4 unity3d读取保存xml文件


  
        import System;
  import System.Xml;
  import System.Xml.Serialization;
  import System.IO;
  import System.Text;
  
  class CeshiData{
   var Ceshi1 : String;
   var Ceshi2 : String;
   var Ceshi3 : float;
   var Ceshi4 : int;
  }
  
   class UserData
  {
   public var _iUser : CeshiData = new CeshiData();
   function UserData() { }
  }
  
  private var c1 : String;
  private var c2 : String;
  private var c3 : float;
  private var c4 : int;
  private var _FileLocation : String;
  private var _FileName : String = "CeshiData.xml";
  
  var myData : UserData[];
  private var tempData : UserData = new UserData();
  
  var i : int = 0;
var GUISkin1 : GUISkin;
  var ShowData : int = 0;
  function Awake(){
   _Filelocation=Application.dataPath;
  }
  
  function Start(){
   FirstSave();
  }
  
  function FirstSave(){//初始化XML
   tempData._iUser.Ceshi1 = "?";
   tempData._iUser.Ceshi2 = "?";
   tempData._iUser.Ceshi3 = 0;
   tempData._iUser.Ceshi4 = 0;
   var writer : StreamWriter;
   var t : FileInfo = new FileInfo(_FileLocation+"/"+ _FileName);
   if(!t.Exists)
   {
   writer = t.CreateText();
   _data = SerializeObject(tempData);
   for(i=0;i<10;i++){
   writer.WriteLine(_data);
   }
   writer.Close();
   }
  
  }
function Save(sc1 : String,sc2 : String,sc3 : float,sc4 : int){//保存数据到指定的XMl里
  
   tempData._iUser.Ceshi1 = sc1;
   tempData._iUser.Ceshi2 = sc2;
   tempData._iUser.Ceshi3 = sc3;
   tempData._iUser.Ceshi4 = sc4;
  
   var writer : StreamWriter;
   var t : FileInfo = new FileInfo(_FileLocation+"/"+ _FileName);
   t.Delete();
   writer = t.CreateText();
   _data = SerializeObject(tempData);
   for(i=0;i<10;i++){
   writer.WriteLine(_data);
   }
   writer.Close();
  
  }
  
  function Load(){//读取保存在XML里的数据
   var r : StreamReader = File.OpenText(_FileLocation+"/"+ _FileName);
   var _info : String ;
   for(i=0;i<10;i++){
   _info = r.ReadLine();
   _data=_info;
   myData[i] = DeserializeObject(_data);
   }
   r.Close();
  }
function OnGUI() {
   GUI.skin = GUISkin1;
   if(GUI.Button(Rect(0,0,100,40),"save")){
   Save("ceshi1","ceshi2",1.23,50);//要显示中文需设定中文字体
   }
   if(GUI.Button(Rect(200,0,100,40),"load")){
   Load();
   ShowData = 1;
   }
   if(ShowData == 1){
   GUI.Label(Rect(170,170+53*0,150,50),myData[0]._iUser.Ceshi1);
   GUI.Label(Rect(370,170+53*0,150,50),myData[0]._iUser.Ceshi2);
   GUI.Label(Rect(550,170+53*0,150,50),myData[0]._iUser.Ceshi3 + "");
   GUI.Label(Rect(760,170+53*0,150,50),myData[0]._iUser.Ceshi4 + "");
  
   GUI.Label(Rect(170,170+53*1,150,50),myData[1]._iUser.Ceshi1);
  
   GUI.Label(Rect(370,170+53*2,150,50),myData[2]._iUser.Ceshi2);
  
   GUI.Label(Rect(550,170+53*3,150,50),myData[3]._iUser.Ceshi3 + "");
  
   GUI.Label(Rect(760,170+53*4,150,50),myData[4]._iUser.Ceshi4 + "");
   }
  }
  
  //================================================================================
function UTF8ByteArrayToString(characters : byte[] )
  {
   var encoding : UTF8Encoding = new UTF8Encoding();
   var constructedString : String = encoding.GetString(characters);
   return (constructedString);
  }
  
  //byte[] StringToUTF8ByteArray(string pXmlString)
  function StringToUTF8ByteArray(pXmlString : String)
  {
   var encoding : UTF8Encoding = new UTF8Encoding();
   var byteArray : byte[] = encoding.GetBytes(pXmlString);
   return byteArray;
  }
  
   // Here we serialize our UserData object of myData
   //string SerializeObject(object pObject)
  function SerializeObject(pObject : Object)
  {
   var XmlizedString : String = null;
   var memoryStream : MemoryStream = new MemoryStream();
   var xs : XmlSerializer = new XmlSerializer(typeof(UserData));
   var xmlTextWriter : XmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
   xs.Serialize(xmlTextWriter, pObject);
   memoryStream = xmlTextWriter.BaseStream; // (MemoryStream)
   XmlizedString = UTF8ByteArrayToString(memoryStream.ToArray());
   return XmlizedString;
  }
// Here we deserialize it back into its original form
   //object DeserializeObject(string pXmlizedString)
  function DeserializeObject(pXmlizedString : String)
  {
   var xs : XmlSerializer = new XmlSerializer(typeof(UserData));
   var memoryStream : MemoryStream = new MemoryStream(StringToUTF8ByteArray(pXmlizedString));
   var xmlTextWriter : XmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
   return xs.Deserialize(memoryStream);
  }


5 单击物体弹出对话框

 

    static var WindowSwitch : boolean = false; 
    var mySkin : GUISkin; 
    var windowRect = Rect (200, 80, 240, 100); 
    function OnGUI () 
    { 
       if(WindowSwitch ==  true) 
       { 
          GUI.skin = mySkin; 
            windowRect = GUI.Window (0, windowRect, WindowContain, "测试视窗"); 
      } 
   } 
   function WindowContain (windowID : int) 
   { 
       if (GUI.Button (Rect (70,40,100,20), "关闭视窗")) 
      { 
         WindowSwitch = false; 
      } 
   } 
function OnMouseEnter () 
   { 
       renderer.material.color = Color.red; 
   } 
   function OnMouseDown () 
   { 
      Func_GUIWindow.WindowSwitch = true; 
   } 
   function OnMouseExit () 
   { 
      renderer.material.color = Color.white; 
   } 


6 读取txt文本

using UnityEngine;
using System.Collections;
using System.IO;
using System.Text;

public class ReadTxt : MonoBehaviour {
string path = "D:\\txtName.txt";
StreamReader smRead = new StreamReader(path,
Encoding.Default); //设置路径

string line;

void Update () {

if ((line = smRead.ReadLine()) != null) {
string[] arrStr = line.Split('|'); //分割符 “|”
id1 = arrStr[0].ToString();
name = arrStr[1].ToString();
sfz = arrStr[2].ToString();
}
}
}


7 截屏

  function OnMouseDown() { 
   Application.CaptureScreenshot("Screenshot.png"); 
 }

8 下拉菜单

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
public class DropDownList : MonoBehaviour
{
    private Rect DropDownRect;          // Size and Location for drop down
    private Transform currentRoot;      // selected object transform
    private Vector2 ListScrollPos;      // scroll list position
    public string selectedItemCaption;  // name of selected item
    private string lastCaption;         // last selected item
    private int guiWidth;               // width of drop list
    private int guiHight;               // hight of drop list
    private bool textChanged;           // if text in text box has changed look for item
    private bool clearDropList;         // clear text box
    public bool DropdownVisible;        // show drop down list
    public bool updateInfo;             // update info window
   
    public Transform root;              // top of the Hierarchy
    public GUISkin dropSkin;            // GUISkin for drop down list
    public int itemtSelected;           // index of selected item
    public bool targetChange;           // text in text box was changed, update list

    public class GuiListItem        //The class that contains our list items
    {
        public string Name;         // name of the item
        public int GuiStyle;        // current style to use
        public int UnSelectedStyle; // unselected GUI style
        public int SelectedStyle;   // selected GUI style
        public int Depth;           // depth in the Hierarchy
        public bool Selected;       // if the item is selected
        public bool ToggleChildren; // show child objects in list

       // constructors
        public GuiListItem(bool mSelected, string mName, int iGuiStyle, bool childrenOn, int depth)
        {
            Selected = mSelected;
            Name = mName;
            GuiStyle = iGuiStyle;
            ToggleChildren = childrenOn;
            Depth = depth;
            UnSelectedStyle = 0;
            SelectedStyle = 0;

        }
        public GuiListItem(bool mSelected, string mName)
        {
            Selected = mSelected;
            Name = mName;
            GuiStyle = 0;
            ToggleChildren = true;
            Depth = 0;
            UnSelectedStyle = 0;
            SelectedStyle = 0;
        }
        public GuiListItem(string mName)
        {
            Selected = false;
            Name = mName;
            GuiStyle = 0;
            ToggleChildren = true;
            Depth = 0;
            UnSelectedStyle = 0;
            SelectedStyle = 0;
        }
// Accessors
        public void enable()// don't show in list
        {
            Selected = true;
        }
        public void disable()// show in list
        {
            Selected = false;
        }
        public void setStlye(int stlye)
        {
            GuiStyle = stlye;
        }
        public void setToggleChildren(bool childrenOn)
        {
            ToggleChildren = childrenOn;
        }
        public void setDepth(int depth)
        {
            Depth = depth;
        }
        public void SetStyles(int unSelected, int selected)
        {
            UnSelectedStyle = unSelected;
            SelectedStyle = selected;
        }
    }

//Declare our list of stuff

    public List<GuiListItem> MyListOfStuff;

 

    // Initialization

    void Start()

    {

        guiWidth = 400;

        guiHight = 28;

        // Manually position our list, because the dropdown will appear over other controls

        DropDownRect = new Rect(10, 10, guiWidth, guiHight);

        DropdownVisible = false;

        itemtSelected = -1;

        targetChange = false;

        lastCaption = selectedItemCaption = "Select a Part...";

 

        if (!root)

            root = gameObject.transform;

 

        MyListOfStuff = new List<GuiListItem>(); //Initialize our list of stuff

        // fill the list

        BuildList(root);

        // set GUI for each item in list

        SetupGUISetting();

        // fill the list

        FillList(root);

    }

 void OnGUI()

    {

        //Show the dropdown list if required (make sure any controls that should appear behind the list are before this block)

        if (DropdownVisible)

        {

            GUI.SetNextControlName("ScrollView");

            GUILayout.BeginArea(new Rect(DropDownRect.xMin, DropDownRect.yMin + DropDownRect.height, guiWidth, Screen.height * .25f), "", "box");

            ListScrollPos = GUILayout.BeginScrollView(ListScrollPos, dropSkin.scrollView);

            GUILayout.BeginVertical(GUILayout.Width(120));

 

            for (int i = 0; i < MyListOfStuff.Count; i++)

            {

                if (MyListOfStuff[i].Selected && GUILayout.Button(MyListOfStuff[i].Name, dropSkin.customStyles[MyListOfStuff[i].GuiStyle]))

                {

                    HandleSelectedButton(i);

                }

            }

            GUILayout.EndVertical();

            GUILayout.EndScrollView();

            GUILayout.EndArea();

        }

        //Draw the dropdown control

        GUILayout.BeginArea(DropDownRect, "", "box");

        GUILayout.BeginHorizontal();

        string ButtonText = (DropdownVisible) ? "<<" : ">>";

        DropdownVisible = GUILayout.Toggle(DropdownVisible, ButtonText, "button", GUILayout.Width(32), GUILayout.Height(20));

        GUI.SetNextControlName("PartSelect");

        selectedItemCaption = GUILayout.TextField(selectedItemCaption);

        clearDropList = GUILayout.Toggle(clearDropList, "Clear", "button", GUILayout.Width(40), GUILayout.Height(20));

        GUILayout.EndHorizontal();

        GUILayout.EndArea();

    }

 void Update()

    {

        //check if text box info changed

        if (selectedItemCaption != lastCaption)

        {

            textChanged = true;

        }

 

        // if text box info changed look for part matching text

        if (textChanged)

        {

            lastCaption = selectedItemCaption;

            textChanged = false;

            // go though list to find item

            for (int i = 0; i < MyListOfStuff.Count; ++i)

            {

                if (MyListOfStuff[i].Name.StartsWith(selectedItemCaption, System.StringComparison.CurrentCultureIgnoreCase))

                {

 

                    MyListOfStuff[i].enable();

                    MyListOfStuff[i].ToggleChildren = false;

                    MyListOfStuff[i].GuiStyle = MyListOfStuff[i].UnSelectedStyle;

                }

                else

                {

                    MyListOfStuff[i].disable();

                    MyListOfStuff[i].ToggleChildren = false;

                    MyListOfStuff[i].GuiStyle = MyListOfStuff[i].UnSelectedStyle;

                }

            }

 for (int i = 0; i < MyListOfStuff.Count; ++i)

            {

                // check list for item

                int test = string.Compare(selectedItemCaption, MyListOfStuff[i].Name, true);

                if (test == 0)

                {

                    itemtSelected = i;

                    targetChange = true;

                    break; // stop looking when found

                }

            }

        }

 

        // reset message if list closed and text box is empty

        if (selectedItemCaption == "" && !DropdownVisible)

        {

            lastCaption = selectedItemCaption = "Select a Part...";

            ClearList(root);

            FillList(root);

        }

 

        // if Clear button pushed

        if (clearDropList)

        {

            clearDropList = false;

            selectedItemCaption = "";

        }

    }

public void HandleSelectedButton(int selection)

    {

        // do the stuff, camera etc

        itemtSelected = selection;//Set the index for our currently selected item

        updateInfo = true;

        selectedItemCaption = MyListOfStuff[selection].Name;

        currentRoot = GameObject.Find(MyListOfStuff[itemtSelected].Name).transform;

 

        // toggle item show child

        MyListOfStuff[selection].ToggleChildren = !MyListOfStuff[selection].ToggleChildren;

 

        lastCaption = selectedItemCaption;

        // fill my drop down list with the children of the current selected object

        if (!MyListOfStuff[selection].ToggleChildren)

        {

            if (currentRoot.childCount > 0)

            {

                MyListOfStuff[selection].GuiStyle = MyListOfStuff[selection].SelectedStyle;

            }

            FillList(currentRoot);

        }

        else

        {

            if (currentRoot.childCount > 0)

            {

                MyListOfStuff[selection].GuiStyle = MyListOfStuff[selection].UnSelectedStyle;

            }

            ClearList(currentRoot);

        }

        targetChange = true;

 

 

    }

// show only items that are the root and its children

    public void FillList(Transform root)

    {

        foreach (Transform child in root)

        {

            for (int i = 0; i < MyListOfStuff.Count; ++i)

            {

                if (MyListOfStuff[i].Name == child.name)

                {

                    MyListOfStuff[i].enable();

                    MyListOfStuff[i].ToggleChildren = false;

                    MyListOfStuff[i].GuiStyle = MyListOfStuff[i].UnSelectedStyle;

                }

            }

        }

    }

    // turn off children objects

    public void ClearList(Transform root)

    {

        //Debug.Log(root.name);

        Transform[] childs = root.GetComponentsInChildren<Transform>();

        foreach (Transform child in childs)

        {

            for (int i = 0; i < MyListOfStuff.Count; ++i)

            {

                if (MyListOfStuff[i].Name == child.name && MyListOfStuff[i].Name != root.name)

                {

                    MyListOfStuff[i].disable();

                    MyListOfStuff[i].ToggleChildren = false;

                    MyListOfStuff[i].GuiStyle = MyListOfStuff[i].UnSelectedStyle;

                }

            }

        }

    }

 // recursively build the list so the hierarchy is in tact

    void BuildList(Transform root)

    {

        // for every object in the thing we are viewing

        foreach (Transform child in root)

        {

            // add the item

            MyListOfStuff.Add(new GuiListItem(false, child.name));

            // if it has children add the children

            if (child.childCount > 0)

            {

                BuildList(child);

            }

        }

    }

 

    public void ResetDropDownList()

    {

        selectedItemCaption = "";

        ClearList(root);

        FillList(root);

    }

 

    public string RemoveNumbers(string key)

    {

        return Regex.Replace(key, @"\d", "");

    }

 // sets the drop list elements to use the correct GUI skin custom style

    private void SetupGUISetting()

    {

        // set drop down list gui

        int depth = 0;

        // check all the parts for hierarchy depth

        for (int i = 0; i < MyListOfStuff.Count; ++i)

        {

            GameObject currentObject = GameObject.Find(MyListOfStuff[i].Name);

            Transform currentTransform = currentObject.transform;

            depth = 0;

 

            if (currentObject.transform.parent == root) // if under root

            {

                if (currentObject.transform.childCount > 0)

                {

                    MyListOfStuff[i].GuiStyle = depth;

                    MyListOfStuff[i].UnSelectedStyle = depth;

                    MyListOfStuff[i].SelectedStyle = depth + 2;

                }

                else

                {

                    MyListOfStuff[i].GuiStyle = depth + 1;

                    MyListOfStuff[i].UnSelectedStyle = depth + 1;

                    MyListOfStuff[i].SelectedStyle = depth + 1;

                }

 

                MyListOfStuff[i].Depth = depth;

 

            }

 else // if not under root find depth

            {

                while (currentTransform.parent != root)

                {

                    ++depth;

                    currentTransform = currentTransform.parent;

                }

                MyListOfStuff[i].Depth = depth;

                // set gui basied on depth

                if (currentObject.transform.childCount > 0)

                {

                    MyListOfStuff[i].GuiStyle = depth * 3;

                    MyListOfStuff[i].UnSelectedStyle = depth * 3;

                    MyListOfStuff[i].SelectedStyle = (depth * 3) + 2;

                }

                else

                {

                    MyListOfStuff[i].GuiStyle = depth * 3 + 1;

                    MyListOfStuff[i].UnSelectedStyle = depth * 3 + 1;

                    MyListOfStuff[i].SelectedStyle = depth * 3 + 1;

                }

            }

        }

    }

}


分享到:
评论

相关推荐

    Unity3D常用代码集合1

    本文将对 Unity3D 中的一些常用代码进行总结和解释,帮助开发者更好地理解和应用这些代码。 1. 基本碰撞检测代码 碰撞检测是 Unity3D 中的一个基本概念,在游戏开发中经常需要检测物体之间的碰撞。在这个代码中,...

    unity3d常用开发代码总结

    总结大部分unity3d的脚本常用代码,方便理解大部分脚本用法。

    UNITY3D常用代码

    标题《UNITY3D常用代码》总结了多个在Unity3D游戏开发中常用的基础功能代码示例。以下详细说明了各个代码的功能和使用场景: 1、基本碰撞检测代码 在Unity3D中,碰撞检测是游戏逻辑编程中不可或缺的部分。基本碰撞...

    贝塞尔曲线的unity3d实现

    贝塞尔曲线是计算机图形学中常用的一种平滑曲线表示法,尤其在Unity3D这样的游戏引擎中,它常被用来创建动画路径、游戏物体的运动轨迹等。本教程将深入探讨贝塞尔曲线的原理,以及如何在Unity3D中实现这一功能。 ...

    unity3d 使用SQLite数据库源代码

    总结来说,这个"unity3d 使用SQLite数据库源代码"压缩包提供了Unity3D中使用SQLite数据库的完整解决方案,包括源代码、测试脚本和详细注释,可以帮助开发者快速理解和实现游戏数据的存储和管理。对于希望在Unity项目...

    Unity3d面试题总结

    ### Unity3d面试题总结及解析 #### 一、渲染管道 **定义**: 渲染管道(Rendering Pipeline)指的是在计算机图形学中,从原始3D模型数据转换为最终显示在屏幕上的2D图像的过程。这个过程涉及多个步骤,每个步骤负责...

    unity3d角色移动2

    教程中提到了如何在脚本初始化阶段(`Start()`方法中)通过`FindWithTag`函数获取带有特定标签(tag)的对象,这是Unity3D中一种常用的物体检索方式,它允许开发者根据预定义的标签来查找和引用游戏物体。...

    Unity 3D 萌萌哒三消游戏《宝石消消乐》源码

    Unity 3D是一种跨平台的游戏开发工具,支持多种编程语言,包括C#、JavaScript和Boo等,其中C#是最常用的编程语言之一。Unity 3D引擎的强大之处在于其对各种平台的支持,包括iOS、Android、Windows Phone等移动设备...

    unity3d面试题复习资料

    - Unity3D使用Mono作为其内部的虚拟机来运行.NET代码,这意味着开发者可以在任何支持.NET的环境中编写代码,并在Unity中运行。 #### 五、Unity3D提供的光源类型 Unity提供了多种光源类型供开发者选择: 1. **方向光...

    中文Unity3D脚本参考.doc

    ### Unity3D脚本知识点详解 #### 一、脚本概览 Unity3D脚本是一种用于游戏开发的重要工具,其主要功能在于控制游戏中的逻辑和行为。在Unity3D中,脚本通常是通过附加自定义脚本对象到游戏物体上来实现的。脚本对象...

    unity3d中连接数据库

    Unity3D是一个功能强大的跨平台游戏引擎,它支持多种编程语言,其中C#是最常用的一种。当开发者需要在游戏中集成用户数据管理、高分榜、在线排行榜等功能时,连接并操作数据库就变得至关重要。在Unity中,可以通过...

    Unity3D鼠标拖拽绕任意轴旋转的实现

    Unity3D提供了多种方式来旋转物体,其中`GameObject.transform.Rotate()`是最常用的方法之一,它允许开发者以不同的空间基准来旋转物体。 - **知识点详解**: - `transform.Rotate(Vector3 axis, float angle, ...

    的Unity3D认证级游戏开发核心训练视频教程

    ### Unity3D认证级游戏开发核心训练视频教程知识点解析 #### 一、Unity3D概述与环境搭建 **1.1 Unity3D简介** Unity3D是一款由Unity ...希望本篇总结能够帮助您快速入门并掌握Unity3D游戏开发的基本技能。

    unity3d资源包海海教程

    总结,海海的Unity3D资源包教程旨在帮助开发者掌握有效的资源管理技巧,提高项目的开发效率和性能表现。通过对Assets文件夹的合理组织、Library的正确理解和Asset Bundle的灵活运用,可以打造更高效、更流畅的游戏...

    unity3d脚本中文基础 javascapt语法基础

    在Unity中,脚本是实现交互性和逻辑控制的核心部分,而JavaScript是Unity3D早期常用的脚本语言之一。本教程将针对Unity3D中的JavaScript语法基础进行详细讲解,适合初学者入门学习。 一、变量与数据类型 在...

    Unity3D内部!编程入门脚本编程入门.pdf

    Unity3D 脚本编程入门 本文档将指导您入门 Unity3D 脚本编程,了解 Unity3D 脚本的基本概念和使用方法。 脚本对象 在 Unity3D 中,脚本对象是游戏物体的组成部分,可以附加到游戏物体上。脚本对象内部有不同的...

    Unity3D iTween插件

    Unity3D iTween插件是Unity3D游戏开发中常用的一个动画库,它极大地简化了在游戏场景中创建平滑过渡和复杂动画的过程。通过使用iTween,开发者无需编写复杂的Lerp(线性插值)代码,即可实现物体的位置、旋转、缩放...

    unity3d的 GUI开发

    ### Unity3D中的GUI开发详解 #### 一、引言 在Unity3D游戏中,图形用户界面(Graphical User Interface, GUI)是与玩家互动的重要环节之一。良好的GUI设计不仅可以提升用户体验,还能帮助开发者更高效地管理和调整...

    unity3d中文脚本使用手册

    ### Unity3D中文脚本使用手册知识点解析 #### 一、脚本概览 Unity3D中的脚本机制是其核心功能之一,主要用于控制游戏逻辑和实现交互效果。脚本可以通过附加到游戏对象上来实现对游戏对象的行为控制。在Unity3D中,...

Global site tag (gtag.js) - Google Analytics