Page 2 of 2
Re: Executing from script
Posted: Wed Jul 18, 2018 1:35 am
by OldNoob
Awesome.
I'll try today.
Also
I start try to learn Unity probably six months ago. Last six month was constat uphill battle which I begin to tire out.
Thanks for support.
My humble regards.
Re: Executing from script
Posted: Wed Jul 18, 2018 9:17 am
by Tony Li
Sounds good. If you have any questions, just let me know. Unity is a big system. It takes a while to learn, especially the programming side.
Re: Executing from script
Posted: Wed Jul 18, 2018 12:53 pm
by OldNoob
Okay I do the camera change.
It works with camera and empty game object.
Create a camera. name CamA
Create a empty GameObject name CamA_Start
While you selected the CamA_Start on hieracy On scene move to your view to your desired camera position then hit ctrl + shift + f
then use in your sequence like
CameraCrossfade(CamA,CamA_Start);
Code: Select all
using UnityEngine;
using System.Collections;
using PixelCrushers.DialogueSystem;
namespace PixelCrushers.DialogueSystem.SequencerCommands
{
public class SequencerCommandCameraCrossfade : SequencerCommand
{
public void Start()
{
string targetCamera = GetParameter(0);
string targetMark = GetParameter(1);
if (string.IsNullOrEmpty(targetCamera)) {
Debug.LogError("target camera is null");
Stop();
}
if (string.IsNullOrEmpty(targetMark)) {
Debug.LogError("target mark is null");
Stop();
}
Camera tCam = GameObject.Find(targetCamera).GetComponent<Camera>();
GameObject tMark = GameObject.Find(targetMark);
tCam.transform.position = tMark.transform.position;
tCam.transform.rotation = tMark.transform.rotation;
DialogueManager.DisplaySettings.cameraSettings.sequencerCamera = tCam;
Stop();
}
public void OnDestroy()
{
// Add your finalization code here. This is critical. If the sequence is cancelled and this
// command is marked as "required", then only Start() and OnDestroy() will be called.
// Use it to clean up whatever needs cleaning at the end of the sequencer command.
// If you don't need to do anything at the end, you can delete this method.
}
}
}
And I did not found any info about where to put this script ? And I put in Menu Framework Sequence Commands dir.
My Best Regards
Re: Executing from script
Posted: Wed Jul 18, 2018 1:25 pm
by Tony Li
Hi,
The script can be anywhere in your project, except don't put it inside a folder named 'Editor'. (Scripts inside 'Editor' folders are not included in builds.)
If you want to avoid the overhead of GameObject.Find(), you can change this:
Code: Select all
string targetCamera = GetParameter(0);
string targetMark = GetParameter(1);
to:
Code: Select all
Transform targetCamera = GetSubject(0);
Transform targetMark = GetSubject(1);
Then you can work with the transform without having to find it. The full API reference for SequencerCommand is
here.
You don't need this line:
Code: Select all
DialogueManager.DisplaySettings.cameraSettings.sequencerCamera = tCam;
It may cause problems. Your command should bypass the Dialogue System's camera controls entirely, so you don't need to set sequencerCamera.