Exemplo n.º 1
0
    public static void ProcessCutscene(string sceneName)
    {
        CutsceneCast cc = GameObject.FindObjectOfType <CutsceneCast>();
        Cutscene     cs = GameObject.FindObjectOfType <Cutscene>();

        _DoProcessCS(cc, cs, sceneName);
    }
Exemplo n.º 2
0
    public static void FixNextedPrefabsByGO(GameObject go)
    {
        CutsceneCast cc = go.GetComponentInChildren <CutsceneCast>();

        Cutscene[] css = go.GetComponentsInChildren <Cutscene>(true);
        _DoFixNextedPrefabs(cc, css);
    }
Exemplo n.º 3
0
    public static void FixNestedPrefabs()
    {
        CutsceneCast cc = GameObject.FindObjectOfType <CutsceneCast>();

        Cutscene[] css = GameObject.FindObjectsOfType <Cutscene>();
        _DoFixNextedPrefabs(cc, css);
    }
Exemplo n.º 4
0
    //    public static string[] OnWillSaveAssets(string[] paths)
    //    {
    //        // Get the name of the scene to save.
    //        string scenePath = string.Empty;
    //        string sceneName = string.Empty;
    //
    //        foreach (string path in paths)
    //        {
    //            if (path.Contains(".unity"))
    //            {
    //                scenePath = Path.GetDirectoryName(path);
    //                sceneName = Path.GetFileNameWithoutExtension(path);
    //            }
    //        }
    //
    //        if (sceneName.Length == 0)
    //        {
    //            return paths;
    //        }
    //
    //        //ProcessCutscene(sceneName);
    //
    //        return paths;
    //    }


    public static void ProcessCSGO(GameObject go)
    {
        string       sceneName = go.name;
        CutsceneCast cc        = go.GetComponentInChildren <CutsceneCast>();
        Cutscene     cs        = go.GetComponentInChildren <Cutscene>();

        _DoProcessCS(cc, cs, sceneName);
    }
Exemplo n.º 5
0
 static public int get_AllTexts(IntPtr l)
 {
     try {
         CutsceneCast self = (CutsceneCast)checkSelf(l);
         pushValue(l, self.AllTexts);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 6
0
 static public int RefreshData(IntPtr l)
 {
     try {
         CutsceneCast self = (CutsceneCast)checkSelf(l);
         self.RefreshData();
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 7
0
 static public int set_Cutscene(IntPtr l)
 {
     try {
         CutsceneCast            self = (CutsceneCast)checkSelf(l);
         CinemaDirector.Cutscene v;
         checkType(l, 2, out v);
         self.Cutscene = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 8
0
 static public int getAllBillboards_s(IntPtr l)
 {
     try {
         UnityEngine.GameObject a1;
         checkType(l, 1, out a1);
         var ret = CutsceneCast.getAllBillboards(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 9
0
    private static void _DoFixNextedPrefabs(CutsceneCast cc, Cutscene[] css)
    {
        GameObject root = null;

        if (cc == null)
        {
            return;
        }

        foreach (var cs in css)
        {
            root = cs.gameObject.transform.parent.gameObject;
            RefreshCutscenePrefabActors(root);
            ReplaceCutscenePrefabActors(root);
        }
    }
Exemplo n.º 10
0
    public void RefreshData()
    {
        allRigidBodies = this.gameObject.GetComponentsInChildren <Rigidbody>(true);
        allAtgs        = this.gameObject.GetComponentsInChildren <ActorTrackGroup>(true);
        allTexts       = this.gameObject.GetComponentsInChildren <UnityEngine.UI.Text>(true);
        allCams        = this.gameObject.GetComponentsInChildren <UnityEngine.Camera>(true);

        allBillboards = CutsceneCast.getAllBillboards(this.gameObject);

        Transform actorRoot = this.transform.Find("Actors");

        allActors = new GameObject[actorRoot.childCount];
        for (int i = 0; i < actorRoot.childCount; ++i)
        {
            allActors[i] = actorRoot.GetChild(i).gameObject;
        }
    }
Exemplo n.º 11
0
    public void CheckPrefab()
    {
        CutsceneCast cc = this.gameObject.GetComponentInParent <CutsceneCast>();

        if (cc == null)
        {
            return;
        }

        var ccPrefabObj = PrefabUtility.GetPrefabParent(cc.gameObject);
        var prefabObj   = PrefabUtility.GetPrefabParent(this.gameObject);

        if (prefabObj != null && ccPrefabObj != null)
        {
            var pp   = AssetDatabase.GetAssetPath(prefabObj);
            var ccpp = AssetDatabase.GetAssetPath(ccPrefabObj);
            if (pp != ccpp)
            {
                prefabPath = pp;
            }
        }
    }
        public void RefreshCutsceneHandlers()
        {
#if PROFILE_FILE
            Profiler.BeginSample("LuaCutsceneEventBehaviour.RefreshCutsceneHandlers");
#endif
            CutsceneCast cc = this.gameObject.GetComponent <CutsceneCast>();
            if (cc == null)
            {
                return;
            }
            Cutscene cs = cc.Cutscene;
            if (cs == null)
            {
                return;
            }

            cs.CutsceneFinished += new CutsceneHandler(CutsceneFinished);
            cs.CutscenePaused   += new CutsceneHandler(CutscenePaused);

#if PROFILE_FILE
            Profiler.EndSample();
#endif
        }
Exemplo n.º 13
0
    public void RefreshPrefab()
    {
        if (prefabPath == null || prefabPath == "")
        {
            return;
        }

        var prefabc = AssetDatabase.LoadAssetAtPath <GameObject>(prefabPath);

        Debug.Log("before check refresh prefab " + prefabPath.ToString());

        if (prefabc == null)
        {
            Debug.Log("prefabc is null " + prefabPath.ToString());

            string path = CommonUtils.findPrefabPath(prefabPath);
            if (path != null)
            {
                prefabPath = path;
                prefabc    = AssetDatabase.LoadAssetAtPath <GameObject>(path);
            }
            if (prefabc == null)
            {
                return;
            }
        }

        if (prefabc.GetComponentInChildren <CutsceneCast>(true) != null)
        {
            Debug.LogError("CutscenePrefabActor.RefreshPrefab: Error prefabPath=" + prefabPath);
            return;
        }

        Debug.Log("do refresh prefab " + prefabPath.ToString());

        var pgo = PrefabUtility.InstantiatePrefab(prefabc) as GameObject;

        pgo.name = this.gameObject.name;

        pgo      = PrefabUtility.ConnectGameObjectToPrefab(pgo, prefabc);
        pgo.name = this.gameObject.name;
        pgo.transform.SetParent(this.transform.parent, false);
        pgo.transform.localPosition = this.transform.localPosition;
        pgo.transform.localRotation = this.transform.localRotation;
        pgo.transform.localScale    = this.transform.localScale;

        CutscenePrefabActor cpa = pgo.GetComponent <CutscenePrefabActor>();

        if (cpa == null)
        {
            cpa = pgo.AddComponent <CutscenePrefabActor>();
        }
        cpa.CheckPrefab();

        CutsceneCast cc = this.gameObject.GetComponentInParent <CutsceneCast>();

        if (cc == null)
        {
            return;
        }

        // move all billboards
        GameObject[] allBillboards = CutsceneCast.getAllBillboards(this.gameObject);
        foreach (GameObject bb in allBillboards)
        {
            bb.transform.SetParent(pgo.transform, false);
        }

        // re-target all enable-disable gameobjects global
        EnableGameObjectGlobal[] allEGOGs = cc.transform.GetComponentsInChildren <EnableGameObjectGlobal>();
        for (int i = 0; i < allEGOGs.Length; i++)
        {
            var tc = allEGOGs[i];
            if (tc.target == this.gameObject)
            {
                tc.target = pgo.gameObject;
            }
        }

        DisableGameObjectGlobal[] allDGOGs = cc.transform.GetComponentsInChildren <DisableGameObjectGlobal>();
        for (int i = 0; i < allDGOGs.Length; i++)
        {
            var tc = allDGOGs[i];
            if (tc.target == this.gameObject)
            {
                tc.target = pgo.gameObject;
            }
        }

        TransformLookAtAction[] allTLAAs = cc.transform.GetComponentsInChildren <TransformLookAtAction>();
        for (int i = 0; i < allTLAAs.Length; i++)
        {
            var tc = allTLAAs[i];
            if (tc.LookAtTarget == this.gameObject)
            {
                tc.LookAtTarget = pgo.gameObject;
            }
        }


        SetTransformEvent[] allSTFs = cc.transform.GetComponentsInChildren <SetTransformEvent>();
        for (int i = 0; i < allSTFs.Length; i++)
        {
            var tc = allSTFs[i];
            if (tc.Transform == null)
            {
                continue;
            }

            if (tc.Transform == this.gameObject.transform)
            {
                tc.Transform = pgo.transform;
            }
            else if (tc.Transform.IsChildOf(this.gameObject.transform))
            {
                tc.Transform = pgo.transform.FindByName(tc.Transform.name);
            }
        }


        SetParent[] allSPs = cc.transform.GetComponentsInChildren <SetParent>();
        for (int i = 0; i < allSPs.Length; i++)
        {
            var tc = allSPs[i];
            if (tc.parent == null)
            {
                continue;
            }

            if (tc.parent == this.gameObject)
            {
                tc.parent = pgo;
            }
            else if (tc.parent.transform.IsChildOf(this.gameObject.transform))
            {
                var ttrans = pgo.transform.FindByName(tc.parent.name);
                if (ttrans != null)
                {
                    tc.parent = pgo.transform.FindByName(tc.parent.name).gameObject;
                }
                else
                {
                    Debug.LogError(tc.parent.name + " not found on " + pgo.name);
                }
            }
        }

        // re-target all actor groups
        foreach (ActorTrackGroup atg in cc.AllAtgs)
        {
            if (atg.Actor == this.transform)
            {
                atg.Actor = pgo.transform;
            }
        }

        var prefabActors = this.gameObject.GetComponentsInChildren <CutscenePrefabActor>(true);

        foreach (var actor in prefabActors)
        {
            if (actor.gameObject == this.gameObject)
            {
                continue;
            }
            if (this.gameObject.transform.parent.name != "Actors")
            {
                continue;
            }

            actor.transform.SetParent(this.gameObject.transform.parent);
        }

        pgo.gameObject.SetActive(this.gameObject.activeSelf);

        GameObject.DestroyImmediate(this.gameObject);
    }
Exemplo n.º 14
0
    private static void _DoProcessCS(CutsceneCast cc, Cutscene cs, string sceneName)
    {
        GameObject root = null;

        if (cc == null)
        {
            if (cs == null)
            {
                return;
            }
            if (cs.gameObject.transform.parent == null)
            {
                root      = new GameObject();
                root.name = "CutsceneAnchor";

                cs.gameObject.transform.parent = root.transform;

                GameObject actors = new GameObject();
                actors.name             = "Actors";
                actors.transform.parent = root.transform;

                GameObject cameras = new GameObject();
                cameras.name             = "Cameras";
                cameras.transform.parent = root.transform;

                var prefabc = AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Prefab/cutscenes/Canvas.prefab");
                var pgo     = GameObject.Instantiate(prefabc);
                pgo.name             = "Canvas";
                pgo.transform.parent = root.transform;

                var prefabes = AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Prefab/cutscenes/EventSystem.prefab");
                var pgoes    = GameObject.Instantiate(prefabes);
                pgoes.name = "EventSystem";
            }
            else
            {
                root = cs.gameObject.transform.parent.gameObject;
            }
            cc = root.AddComponent <CutsceneCast>();
        }

        cs.Stop();

        if (root == null)
        {
            root = cs.gameObject.transform.parent.gameObject;
        }

        RemoveGuiTextureForTransitionComp <ColorTransition>(root);
        RemoveGuiTextureForTransitionComp <FadeFromBlack>(root);
        RemoveGuiTextureForTransitionComp <FadeFromWhite>(root);
        RemoveGuiTextureForTransitionComp <FadeToBlack>(root);
        RemoveGuiTextureForTransitionComp <FadeToWhite>(root);

        if (sceneName != null && root.name != sceneName)
        {
            root.name = sceneName;
        }

        cc.RefreshData();
        cc.Cutscene = cs;

        RefreshCutscenePrefabActors(root);

        // remove all audio listeners
        RemoveAllComponents <AudioListener>(root);
        RemoveAllComponents <MeshCollider>(root);

        if (sceneName != null)
        {
            UpdatePrefab(root, sceneName);
        }
    }