Ejemplo n.º 1
0
        void ExportRoomPieces(GameObject g)
        {
            var saveData = new GameObject("RoomPieces_data");

            saveData.AddComponent <RoomData>();
            saveData.transform.parent = g.transform;
            Util.InitGameObject(saveData);

            var resPath = Path.Combine(Application.dataPath, "prefabs");
            var dir     = new DirectoryInfo(resPath);
            var prefabs = dir.GetFiles("*.prefab", SearchOption.TopDirectoryOnly);

            resPath = Path.Combine(Application.dataPath, "prefabs/props");
            dir     = new DirectoryInfo(resPath);
            var propsPrefab = dir.GetFiles("*.prefab", SearchOption.TopDirectoryOnly);


            GameObjectDelegate gg = delegate(string name)
            {
                return(GetPrefab(name, new List <FileInfo[]>()
                {
                    prefabs,
                    propsPrefab
                }));
            };

            TranverseTree(transform.Find("RoomPieces_data").gameObject, saveData, gg);
        }
Ejemplo n.º 2
0
    void CallForEach(GameObject obj, GameObjectDelegate func)
    {
        if (null == obj)
            return;

        func(obj);

        foreach (Transform child in obj.transform)
        {
            if (null == child)
                continue;

            CallForEach(child.gameObject, func);
        }
    }
Ejemplo n.º 3
0
        void TranverseSingleTree(GameObject root, GameObject saveData, GameObjectDelegate del)
        {
            var sd = saveData.GetComponent <RoomData>();

            foreach (Transform child in root.transform)
            {
                var pb = new RoomData.RoomPosRot();
                pb.prefab = del(child.name);
                pb.pos    = child.localPosition;
                pb.rot    = child.localRotation;
                pb.scale  = child.localScale;

                sd.Prefabs.Add(pb);
            }
        }
Ejemplo n.º 4
0
    void announceElementAddedToStage(StageElementCreationTemplate template)
    {
        onElementAddedToStage?.Invoke(template.Prefab);

        GameObjectDelegate eventChannel = null;

        switch (template.ElementType)
        {
        case StageElementType.ONSTAGE_ACTOR:
            eventChannel = onActorAddedToStage;
            break;
        }

        if (eventChannel != null)
        {
            eventChannel?.Invoke(template.Prefab);
        }
    }