Example #1
0
    //增加位置节点
    void AddNodeObj(ItemInfo info, ItemPosInfo posInfo, EditorSceneObj sceneObj, bool isNew)
    {
        BaseItem baseItem = getBaseItemByID(info.itemID);

        if (baseItem == null)
        {
            return;
        }
        //加载资源
        GameObject obj = AssetDatabase.LoadAssetAtPath <GameObject>("Assets/" + baseItem.model + ".prefab");

        obj      = Instantiate(obj) as GameObject;
        obj.name = info.itemName;
        obj.transform.SetParent(sceneObj.rootObj.transform);
        obj.isStatic = true;
        if (posInfo != null)
        {
            obj.transform.position    = posInfo.pos;
            obj.transform.eulerAngles = posInfo.rotate;
            obj.transform.localScale  = (posInfo.scale == Vector3.zero)? Vector3.one:posInfo.scale;
        }
        else
        {
            obj.transform.position    = Vector3.zero;
            obj.transform.eulerAngles = Vector3.zero;
        }
        sceneObj.itemObj.Add(obj);
        if (isNew)
        {
            UserLog.AddNodeSceneLog(m_allAssetName[selectDataIndex], info.itemID, sceneObj.itemObj.Count - 1);
        }
    }