using UnityEngine;
public class AddGameObject : MonoBehaviour { public GameObject prefab;//被克隆的对象 private void Start() { //第一种创建物体的方式 new GameObject(); GameObject go= new GameObject(“Cube”);//第一个参数是创建物体的名字(可填可不填) //第二种创建物体的方式(克隆) //根据prefab或者另外一个游戏物体进行克隆 GameObject .Instantiate(prefab); //第三种创建物体的方式 GameObject .CreatePrimitive(PrimitiveType.Cube);//用来创建基本模型 如 正方体 胶囊体等等 GameObject .CreatePrimitive(PrimitiveType.Plane); }
}
#mermaid-svg-vHPvcAJceZT6D7cJ .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-vHPvcAJceZT6D7cJ .label text{fill:#333}#mermaid-svg-vHPvcAJceZT6D7cJ .node rect,#mermaid-svg-vHPvcAJceZT6D7cJ .node circle,#mermaid-svg-vHPvcAJceZT6D7cJ .node ellipse,#mermaid-svg-vHPvcAJceZT6D7cJ .node polygon,#mermaid-svg-vHPvcAJceZT6D7cJ .node path{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-vHPvcAJceZT6D7cJ .node .label{text-align:center;fill:#333}#mermaid-svg-vHPvcAJceZT6D7cJ .node.clickable{cursor:pointer}#mermaid-svg-vHPvcAJceZT6D7cJ .arrowheadPath{fill:#333}#mermaid-svg-vHPvcAJceZT6D7cJ .edgePath .path{stroke:#333;stroke-width:1.5px}#mermaid-svg-vHPvcAJceZT6D7cJ .flowchart-link{stroke:#333;fill:none}#mermaid-svg-vHPvcAJceZT6D7cJ .edgeLabel{background-color:#e8e8e8;text-align:center}#mermaid-svg-vHPvcAJceZT6D7cJ .edgeLabel rect{opacity:0.9}#mermaid-svg-vHPvcAJceZT6D7cJ .edgeLabel span{color:#333}#mermaid-svg-vHPvcAJceZT6D7cJ .cluster rect{fill:#ffffde;stroke:#aa3;stroke-width:1px}#mermaid-svg-vHPvcAJceZT6D7cJ .cluster text{fill:#333}#mermaid-svg-vHPvcAJceZT6D7cJ div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:12px;background:#ffffde;border:1px solid #aa3;border-radius:2px;pointer-events:none;z-index:100}#mermaid-svg-vHPvcAJceZT6D7cJ .actor{stroke:#ccf;fill:#ECECFF}#mermaid-svg-vHPvcAJceZT6D7cJ text.actor>tspan{fill:#000;stroke:none}#mermaid-svg-vHPvcAJceZT6D7cJ .actor-line{stroke:grey}#mermaid-svg-vHPvcAJceZT6D7cJ .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333}#mermaid-svg-vHPvcAJceZT6D7cJ .messageLine1{stroke-width:1.5;stroke-dasharray:2, 2;stroke:#333}#mermaid-svg-vHPvcAJceZT6D7cJ #arrowhead path{fill:#333;stroke:#333}#mermaid-svg-vHPvcAJceZT6D7cJ .sequenceNumber{fill:#fff}#mermaid-svg-vHPvcAJceZT6D7cJ #sequencenumber{fill:#333}#mermaid-svg-vHPvcAJceZT6D7cJ #crosshead path{fill:#333;stroke:#333}#mermaid-svg-vHPvcAJceZT6D7cJ .messageText{fill:#333;stroke:#333}#mermaid-svg-vHPvcAJceZT6D7cJ .labelBox{stroke:#ccf;fill:#ECECFF}#mermaid-svg-vHPvcAJceZT6D7cJ .labelText,#mermaid-svg-vHPvcAJceZT6D7cJ .labelText>tspan{fill:#000;stroke:none}#mermaid-svg-vHPvcAJceZT6D7cJ .loopText,#mermaid-svg-vHPvcAJceZT6D7cJ .loopText>tspan{fill:#000;stroke:none}#mermaid-svg-vHPvcAJceZT6D7cJ .loopLine{stroke-width:2px;stroke-dasharray:2, 2;stroke:#ccf;fill:#ccf}#mermaid-svg-vHPvcAJceZT6D7cJ .note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-vHPvcAJceZT6D7cJ .noteText,#mermaid-svg-vHPvcAJceZT6D7cJ .noteText>tspan{fill:#000;stroke:none}#mermaid-svg-vHPvcAJceZT6D7cJ .activation0{fill:#f4f4f4;stroke:#666}#mermaid-svg-vHPvcAJceZT6D7cJ .activation1{fill:#f4f4f4;stroke:#666}#mermaid-svg-v