04.07.2022

This commit is contained in:
Plotnikov
2022-07-04 13:15:35 +03:00
parent 5fad2bcf6b
commit 696daa0b2e
7224 changed files with 3814576 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
using UnityEngine;
public class ChangeSkybox : MonoBehaviour
{
public Material ground;
public Material sky;
public void setSkybox(string name)
{
if (name == "ground")
RenderSettings.skybox = ground;
if (name == "sky")
RenderSettings.skybox = sky;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d746b63fe4989c54aa93b3360cb0a3ce
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 216903f2a9c7f8049947ad9067e38c07
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8b9413f20596e474bbaeec52749fa158
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,214 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using UnityEngine.EventSystems;
public class ScrollViewAdapter : MonoBehaviour
{
public RectTransform prefab;
public RectTransform content;
public int curAction;
ScEditor sce;
Scenario sc;
Manager man;
Scrollbar scroll=null;
public void Init()
{
sc = GameObject.Find("ScEditor").GetComponent<ScEditor>().SC;
man = GameObject.Find("Manager").GetComponent<Manager>();
if (sc == null)
{
Debug.Log(" Panel2 Start: sc = null");
return;
}
sce = GameObject.Find("ScEditor").GetComponent<ScEditor>();
sc = sce.SC;
scroll = GameObject.Find("ActionsViewScrollbar").GetComponent<Scrollbar>();
//Debug.Log(" Start: sc.curModeSc.acts.Count = " + sc.curModeSc.acts.Count);
InvokeRepeating("MyFixedUpdate", 0, 0.25f);
}
public void MyFixedUpdate()
{
if (sc == null)
{
//Debug.Log(" Panel2 FixedUpdate: sc == null ");
return;
}
if (sc.curModeSc == null)
{
//Debug.Log(" Panel2 FixedUpdate: sc.curModeSc == null ");
return;
}
if (scroll == null) return;
if (sc.curModeSc.acts.Count == 0) return;
int min;
int cnt = sc.curModeSc.acts.Count;
if (cnt > 16) cnt -= 16;
min = Mathf.FloorToInt((1.0f - scroll.value) * cnt);
for (int i = min; i < min+17; i++) //for (int i = 0; i < sc.curModeSc.acts.Count; i++)
{
GameObject go_ai = GameObject.Find("ActionItem" + i);
if (go_ai == null)
{
//Debug.Log("ActionItem" + i + " not found. curModeActs = " + sc.curModeSc.acts.Count);
continue;
}
Button btn = go_ai.GetComponent<Button>();
ColorBlock colors = btn.colors;
colors.normalColor = Color.white;
if (i == curAction)
{
colors.normalColor = new Color(160f / 255f, 230f / 255f, 160f / 255f);
}
btn.colors = colors;
}
//Debug.Log(" FixedUpdate curAction = " + curAction + " sc.curModeActs.Count = " + sc.curModeSc.acts.Count);
}
public void UpdateItems()
{
sc = GameObject.Find("ScEditor").GetComponent<ScEditor>().SC;
var models = new TestItemModel[sc.curModeSc.acts.Count];
for (int i = 0; i < sc.curModeSc.acts.Count; i++)
{
models[i] = new TestItemModel();
models[i].name = "ActionItem" + i;
models[i].buttonText = (i+1) + ". " + sc.curModeSc.acts[i].title;
models[i].index = i;
}
foreach (Transform child in content)
Destroy(child.gameObject);
foreach (var model in models)
{
var instance = GameObject.Instantiate(prefab.gameObject) as GameObject;
instance.transform.SetParent(content, false);
InitializeItemView(instance, model);
}
if (models.Length == 0)
curAction = -1;
else
onActionViewChange(0);
//Debug.Log("UpdateItems curAction = " + curAction + " sc.curModeActs.Count = " + sc.curModeSc.acts.Count + " model.len = " + models.Length);
}
void InitializeItemView(GameObject viewGameObject, TestItemModel model)
{
TestItemView view = new TestItemView(viewGameObject.transform);
view.clickButton.name = model.name;
view.clickButton.GetComponentInChildren<Text>().text = model.buttonText;
view.clickButton.onClick.AddListener(
() =>
{
onActionViewChange(model.index);
}
);
}
public int tap = 0;
public void onActionViewChange(int index)
{
if(index == -1)
{
sce.SetCurObject(null);
return;
}
curAction = index;
UnityObject uo = man.objects.Find(sc.curModeSc.acts[curAction].objName);
UnityObject tmp_uo = uo;
string panel = "";
if (uo != null && uo.dim == "2D")
{
while (tmp_uo != null)
{
if (tmp_uo.type == "panel2D")
{
panel = tmp_uo.name; break;
}
tmp_uo = tmp_uo.parent;
}
}
tap++;
if (tap == 1)
{
if (curAction >= sc.curModeSc.acts.Count) curAction = sc.curModeSc.acts.Count - 1;
//Debug.Log("changed = " + curAction + ", acts = "+ sc.curModeActs.Count);
for (int i = 0; i < sc.curModeSc.acts.Count; i++)
{
var colors = GameObject.Find("ActionItem" + i).GetComponent<Button>().colors;
colors.normalColor = Color.white;
if (i == index)
colors.normalColor = new Color(160f / 255f, 230f / 255f, 160f / 255f); //Color.yellow;
GameObject.Find("ActionItem" + i).GetComponent<Button>().colors = colors;
}
if (sc.curModeSc.acts[curAction].objName != "" && sc.curModeSc.acts[curAction].type != "switchMFIScreen")
sce.SetCurObject(man.objects.Find(sc.curModeSc.acts[curAction].objName).gameObject);
//else
// sce.SetCurObject(null);
ScAction lastCamAct = null; // переезд камеры в последнее установленное в сценарии положение
for (int i = curAction; i >= 0; i--)
if (sc.curModeSc.acts[i].type == "setCurCameraPos")
{
lastCamAct = sc.curModeSc.acts[i];
break;
}
if (lastCamAct != null && man.player.state != "play" && man.is3D)
{
if(!man.is3D && panel != "" && man.opened2Dpanel != panel)
man.SwitchTo3D();
man.player.isScEditorCameraMoving = true;
man.player.RunAction(lastCamAct);
man.mouseEnterUI();
}
StartCoroutine(DoubleTapInterval());
}
else if (tap == 2 && uo != null) // двойной клик на действии в списке
{
if (uo.dim == "2D" && panel != "") // если объект в действии "2Д" - открываем его панель
{
if (!man.is3D && man.opened2Dpanel != panel)
man.SwitchTo3D();
if (man.is3D)
man.SwitchTo2D(panel);
}
if (uo.dim == "3D") // если "3Д" - просто возвращаемся в 3Д
{
if (!man.is3D) man.SwitchTo3D();
}
tap = 0;
}
}
IEnumerator DoubleTapInterval()
{
yield return new WaitForSeconds(0.5f);
this.tap = 0;
}
public class TestItemView
{
public Button clickButton;
public TestItemView(Transform rootView)
{
clickButton = rootView.Find("ActionClickButton").GetComponent<Button>();
if (clickButton == null) Debug.Log("prefab clickButton = null");
}
}
public class TestItemModel
{
public string name;
public string buttonText;
public int index;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2aa9ae935eabcc64cb6bc657e4810218
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,434 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
public class ScrollViewAdapterPanel1 : MonoBehaviour
{
public RectTransform prefab;
public RectTransform content;
//public int curObjAction;
ScEditor sce;
Manager man;
List<ScAction> actList;
List<GameObject> scrollGO = new List<GameObject>();
GameObject panel1;
int contentH;
private void Update()
{
//content.sizeDelta = new Vector2(content.sizeDelta.x, contentH);
}
public void Init()
{
sce = GameObject.Find("ScEditor").GetComponent<ScEditor>();
man = GameObject.Find("Manager").GetComponent<Manager>();
panel1 = GameObject.Find("Panel1");
if (sce.SC == null) Debug.Log(" Panel1 Start: sc = null");
//Debug.Log(" Start: sc.curModeSc.acts.Count = " + sc.curModeSc.acts.Count);
//Debug.Log(GameObject.Find("PodsvetButton").GetComponent<Button>().interactable);
}
public void UpdateItems()
{
sce = GameObject.Find("ScEditor").GetComponent<ScEditor>();
actList = sce.MakeCurObjectActionsList();
scrollGO.Clear();
foreach (Transform child in content)
Destroy(child.gameObject);
int newActY = -5;
for(int i=0;i<actList.Count;i++)
{
//Debug.Log("Left panel: Add action " + actList[i].type);
GameObject _blockSetState = prefab.Find("ScrollElements/SetState").gameObject;
GameObject _blockSetRangeState = prefab.Find("ScrollElements/SetRangeState").gameObject;
GameObject _blockFreeTextPanel = prefab.Find("ScrollElements/FreeTextPanel").gameObject;
GameObject _blockSetTextField = prefab.Find("ScrollElements/SetTextField").gameObject;
GameObject _blockSetIntField = prefab.Find("ScrollElements/SetIntField").gameObject;
GameObject block = null;
if (actList[i].type == "setState")
{
block = GameObject.Instantiate(_blockSetState);
block.transform.SetPositionAndRotation(new Vector3(-12, newActY, 0), new Quaternion()); newActY -= 25;
block.transform.SetParent(content, false);
block.transform.Find("StateText").GetComponent<Text>().text = actList[i].setState.name;
int actNum = i;
block.transform.Find("BtnSetState").GetComponent<Button>().onClick.AddListener(() => { InsertCurObjAction(actNum); });
}
if (actList[i].type == "setStateInRange")
{
block = GameObject.Instantiate(_blockSetRangeState);
block.transform.SetPositionAndRotation(new Vector3(-12, newActY, 0), new Quaternion()); newActY -= 37;
block.transform.SetParent(content, false);
block.transform.Find("ChangeValText").GetComponent<Text>().text = "Изменить значение состояния " + actList[i].setStateInRange.rangeStr;
block.transform.Find("IFRangeStateVal").GetComponent<TMP_InputField>().text = "";
block.transform.Find("IFRangeTime").GetComponent<TMP_InputField>().text = "0";
int actNum = i;
block.transform.Find("BtnSetRangeState").GetComponent<Button>().onClick.AddListener(() => { InsertCurObjAction(actNum); });
}
if (actList[i].type == "openPanel")
{
block = GameObject.Instantiate(_blockFreeTextPanel);
block.transform.SetPositionAndRotation(new Vector3(-12, newActY, 0), new Quaternion()); newActY -= 18;
block.transform.SetParent(content, false);
block.transform.Find("FreeText").GetComponent<Text>().text = "Открыть 2D-панель";
int actNum = i;
block.transform.Find("BtnFreeTextPanel").GetComponent<Button>().onClick.AddListener(() => { InsertCurObjAction(actNum); });
}
if (actList[i].type == "switchTo3D")
{
block = GameObject.Instantiate(_blockFreeTextPanel);
block.transform.SetPositionAndRotation(new Vector3(-12, newActY, 0), new Quaternion()); newActY -= 18;
block.transform.SetParent(content, false);
block.transform.Find("FreeText").GetComponent<Text>().text = "Закрыть 2D-панель";
int actNum = i;
block.transform.Find("BtnFreeTextPanel").GetComponent<Button>().onClick.AddListener(() => { InsertCurObjAction(actNum); });
}
if (actList[i].type == "setTextField")
{
block = GameObject.Instantiate(_blockSetTextField);
block.transform.SetPositionAndRotation(new Vector3(-12, newActY, 0), new Quaternion()); newActY -= 45;
block.transform.SetParent(content, false);
block.transform.Find("IFStateVal").GetComponent<TMP_InputField>().text = "";
int actNum = i;
block.transform.Find("BtnSetTextField").GetComponent<Button>().onClick.AddListener(() => { InsertCurObjAction(actNum); });
}
if (actList[i].type == "setIntField")
{
block = GameObject.Instantiate(_blockSetIntField);
block.transform.SetPositionAndRotation(new Vector3(-12, newActY, 0), new Quaternion()); newActY -= 48;
block.transform.SetParent(content, false);
block.transform.Find("ChangeIntText").GetComponent<Text>().text = "Изменить целочисленное значение:";
block.transform.Find("IFIntFrom").GetComponent<TMP_InputField>().text = "";
block.transform.Find("IFIntTo").GetComponent<TMP_InputField>().text = "";
block.transform.Find("IFIntTime").GetComponent<TMP_InputField>().text = "0";
int actNum = i;
block.transform.Find("BtnSetIntField").GetComponent<Button>().onClick.AddListener(() => { InsertCurObjAction(actNum); });
}
if (actList[i].type == "setFloatField")
{
block = GameObject.Instantiate(_blockSetIntField);
block.transform.SetPositionAndRotation(new Vector3(-12, newActY, 0), new Quaternion()); newActY -= 48;
block.transform.SetParent(content, false);
block.transform.Find("ChangeIntText").GetComponent<Text>().text = "Изменить дробное значение:";
block.transform.Find("IFIntFrom").GetComponent<TMP_InputField>().text = "0.0";
block.transform.Find("IFIntTo").GetComponent<TMP_InputField>().text = "0.0";
block.transform.Find("IFIntTime").GetComponent<TMP_InputField>().text = "0";
int actNum = i;
block.transform.Find("BtnSetIntField").GetComponent<Button>().onClick.AddListener(() => { InsertCurObjAction(actNum); });
}
scrollGO.Add(block);
if (block != null)
block.name = "curObjAction_" + i;
else
Debug.Log("Unknown action type: " + actList[i].type);
}
contentH = -newActY -195;
content.sizeDelta = new Vector2(content.sizeDelta.x, contentH);
}
public void InsertCurObjAction(int ind)
{
if (scrollGO[ind] == null) return;
GameObject block = scrollGO[ind];
if (actList[ind].type == "setState")
{
actList[ind].title = "[" + sce.curObject.name + "] " + "Установить состояние \"" + actList[ind].setState.name + "\"";
}
if (actList[ind].type == "setStateInRange")
{
int.TryParse(block.transform.Find("IFRangeStateVal").GetComponent<TMP_InputField>().text, out actList[ind].setStateInRange.val);
int.TryParse(block.transform.Find("IFRangeTime").GetComponent<TMP_InputField>().text, out actList[ind].setStateInRange.sec);
string timeStr = "";
if (actList[ind].setStateInRange.sec != 0)
timeStr = " за время " + actList[ind].setStateInRange.sec + " сек";
actList[ind].title = "[" + sce.curObject.name + "] " + "Установить значение состояния \"" + actList[ind].setStateInRange.val + "\"" + timeStr;
}
//if (actList[ind].type == "openPanel") { }
//if (actList[ind].type == "switchTo3D") { }
if (actList[ind].type == "setTextField")
{
actList[ind].setTextField.text = block.transform.Find("IFStateVal").GetComponent<TMP_InputField>().text;
string rusColor = "зелёный"; actList[ind].setTextField.color = "green";
if (block.transform.Find("TextColorGroup/ToggleRed").GetComponent<Toggle>().isOn)
{ actList[ind].setTextField.color = "red"; rusColor = "красный"; }
if (block.transform.Find("TextColorGroup/ToggleYellow").GetComponent<Toggle>().isOn)
{ actList[ind].setTextField.color = "yellow"; rusColor = "жёлтый"; }
if (block.transform.Find("TextColorGroup/ToggleWhite").GetComponent<Toggle>().isOn)
{ actList[ind].setTextField.color = "white"; rusColor = "белый"; }
actList[ind].title = "[" + sce.curObject.name + "] " + "Установить текстовое поле в \""+ actList[ind].setTextField.text + "\"" + " ("+ rusColor + ")";
}
if (actList[ind].type == "setIntField")
{
int.TryParse(block.transform.Find("IFIntFrom").GetComponent<TMP_InputField>().text, out actList[ind].setIntField.valFrom);
int.TryParse(block.transform.Find("IFIntTo").GetComponent<TMP_InputField>().text, out actList[ind].setIntField.valTo);
int.TryParse(block.transform.Find("IFIntTime").GetComponent<TMP_InputField>().text, out actList[ind].setIntField.sec);
string timeStr = "";
if (actList[ind].setIntField.sec != 0)
timeStr = " за время " + actList[ind].setIntField.sec + " сек";
string rusColor = "зелёный"; actList[ind].setIntField.color = "green";
if (block.transform.Find("TextColorGroup/ToggleRed").GetComponent<Toggle>().isOn)
{ actList[ind].setIntField.color = "red"; rusColor = "красный"; }
if (block.transform.Find("TextColorGroup/ToggleYellow").GetComponent<Toggle>().isOn)
{ actList[ind].setIntField.color = "yellow"; rusColor = "жёлтый"; }
if (block.transform.Find("TextColorGroup/ToggleWhite").GetComponent<Toggle>().isOn)
{ actList[ind].setTextField.color = "white"; rusColor = "белый"; }
actList[ind].title = "[" + sce.curObject.name + "] " + "Изменить числовое текстовое поле c \""+ actList[ind].setIntField.valFrom + "\" до \"" + actList[ind].setIntField.valTo + "\"" +timeStr +" (" + rusColor + ")";
}
if (actList[ind].type == "setFloatField")
{
float f;
f = float.Parse(block.transform.Find("IFIntFrom").GetComponent<TMP_InputField>().text, System.Globalization.CultureInfo.InvariantCulture);
//float.TryParse(block.transform.Find("IFIntFrom").GetComponent<TMP_InputField>().text, out f);
actList[ind].setIntField.valFrom = Mathf.FloorToInt(f * 10f);
//float.TryParse(block.transform.Find("IFIntTo").GetComponent<TMP_InputField>().text, out f);
f = float.Parse(block.transform.Find("IFIntTo").GetComponent<TMP_InputField>().text, System.Globalization.CultureInfo.InvariantCulture);
actList[ind].setIntField.valTo = Mathf.FloorToInt(f * 10f);
int.TryParse(block.transform.Find("IFIntTime").GetComponent<TMP_InputField>().text, out actList[ind].setIntField.sec);
string timeStr = "";
if (actList[ind].setIntField.sec != 0)
timeStr = " за время " + actList[ind].setIntField.sec + " сек";
string rusColor = "зелёный"; actList[ind].setIntField.color = "green";
if (block.transform.Find("TextColorGroup/ToggleRed").GetComponent<Toggle>().isOn)
{ actList[ind].setIntField.color = "red"; rusColor = "красный"; }
if (block.transform.Find("TextColorGroup/ToggleYellow").GetComponent<Toggle>().isOn)
{ actList[ind].setIntField.color = "yellow"; rusColor = "жёлтый"; }
if (block.transform.Find("TextColorGroup/ToggleWhite").GetComponent<Toggle>().isOn)
{ actList[ind].setTextField.color = "white"; rusColor = "белый"; }
actList[ind].title = "[" + sce.curObject.name + "] " +
"Изменить дробное числовое текстовое поле c \"" +
String.Format("{0:F1}", actList[ind].setIntField.valFrom/10f) +
"\" до \"" +
String.Format("{0:F1}", actList[ind].setIntField.valTo / 10f) +
"\"" + timeStr + " (" + rusColor + ")";
}
sce.InsertAction(actList[ind]);
}
// setState, setStateInRange, openPanel, setTextField, setIntField, switchTo3D, highlightOn, highlightOff,
// highlightTime, waitForClick, waitForTime, setCurCameraPos, showText, hideText, execScenario, playAudio
public void InsActHighlightOn()
{
if (sce.curObject == null) return;
ScAction newAct;
newAct = new ScAction(); newAct.type = "highlightOn";
newAct.objName = sce.curObject.name;
newAct.title = "[" + sce.curObject.name + "] " + "Включить подсветку объекта";
sce.InsertAction(newAct);
}
public void InsActHighlightOff()
{
if (sce.curObject == null) return;
ScAction newAct;
newAct = new ScAction(); newAct.type = "highlightOff";
newAct.objName = sce.curObject.name;
newAct.title = "[" + sce.curObject.name + "] " + "Выключить подсветку";
sce.InsertAction(newAct);
}
public void InsActHighlightTime()
{
if (sce.curObject == null) return;
ScAction newAct;
newAct = new ScAction(); newAct.type = "highlightTime";
newAct.objName = sce.curObject.name;
newAct.highlightTime = new actHighlightTime();
int.TryParse(GameObject.Find("IFFlashObjTime").GetComponent<TMP_InputField>().text, out newAct.highlightTime.sec);
newAct.title = "[" + sce.curObject.name + "] " + "Подсветить на время " + newAct.highlightTime.sec + " сек";
sce.InsertAction(newAct);
}
public void InsActWaitForClick()
{
if (sce.curObject == null) return;
ScAction newAct;
newAct = new ScAction(); newAct.type = "waitForClick";
newAct.objName = sce.curObject.name;
newAct.title = "[" + sce.curObject.name + "] " + "Ожидать нажатия на объект";
sce.InsertAction(newAct);
}
public void InsActWaitForTime()
{
ScAction newAct;
newAct = new ScAction(); newAct.type = "waitForTime";
newAct.objName = "";
newAct.waitForTime = new actWaitForTime();
int.TryParse(GameObject.Find("IFWaitForTime").GetComponent<TMP_InputField>().text, out newAct.waitForTime.sec);
newAct.title = "Пауза " + newAct.waitForTime.sec + " сек";
sce.InsertAction(newAct);
}
public void InsActShowText()
{
ScAction newAct;
newAct = new ScAction(); newAct.type = "showText";
newAct.objName = "";
newAct.showText = new actShowText();
newAct.showText.text = GameObject.Find("IFShowText").GetComponent<TMP_InputField>().text;
newAct.title = "Вывести текст \"" + newAct.showText.text;
//if(newAct.showText.text.Length > 15) newAct.title += "..";
newAct.title += "\"";
sce.InsertAction(newAct);
}
public void InsActHideText()
{
ScAction newAct;
newAct = new ScAction(); newAct.type = "hideText";
newAct.objName = "";
newAct.title = "Скрыть текст";
sce.InsertAction(newAct);
}
public void InsActSetCurCameraPos()
{
ScAction newAct;
newAct = new ScAction(); newAct.type = "setCurCameraPos";
newAct.objName = "";
newAct.setCurCameraPos = new actSetCurCameraPos();
GameObject viewCamera = man.viewCamera;
GameObject cabinCamera = man.cabinCamera;
GameObject curCamera;
if (cabinCamera.activeInHierarchy)
curCamera = cabinCamera;
else
curCamera = viewCamera;
newAct.setCurCameraPos.fov = (int)curCamera.GetComponent<Camera>().fieldOfView;
newAct.setCurCameraPos.viewMode = man.viewmode;
newAct.setCurCameraPos.position = new uVector3();
newAct.setCurCameraPos.position.x = curCamera.transform.position.x;
newAct.setCurCameraPos.position.y = curCamera.transform.position.y;
newAct.setCurCameraPos.position.z = curCamera.transform.position.z;
newAct.setCurCameraPos.rotation = new uVector3();
newAct.setCurCameraPos.rotation.x = curCamera.transform.rotation.eulerAngles.x;
newAct.setCurCameraPos.rotation.y = curCamera.transform.rotation.eulerAngles.y;
newAct.setCurCameraPos.rotation.z = curCamera.transform.rotation.eulerAngles.z;
newAct.setCurCameraPos.scale = new uVector3();
newAct.setCurCameraPos.scale.x = curCamera.transform.localScale.x;
newAct.setCurCameraPos.scale.y = curCamera.transform.localScale.y;
newAct.setCurCameraPos.scale.z = curCamera.transform.localScale.z;
if (cabinCamera.activeInHierarchy) // внутри
newAct.setCurCameraPos.camera = "cabin";
else // обзорка
{
newAct.setCurCameraPos.camera = "view";
newAct.setCurCameraPos.scriptOffset = new uVector3();
newAct.setCurCameraPos.scriptOffset.x = viewCamera.GetComponent<CameraFree>().offset.x;
newAct.setCurCameraPos.scriptOffset.y = viewCamera.GetComponent<CameraFree>().offset.y;
newAct.setCurCameraPos.scriptOffset.z = viewCamera.GetComponent<CameraFree>().offset.z;
}
newAct.title = "Установить положение камеры";
sce.InsertAction(newAct);
}
public void InsActExecScenario()
{
Dropdown scExecDropdown = GameObject.Find("DropdownCallScenario").GetComponent<Dropdown>();
if (scExecDropdown.options.Count == 0 || scExecDropdown.value == -1)
return;
ScAction newAct;
newAct = new ScAction(); newAct.type = "execScenario";
newAct.objName = "";
newAct.execScenario = new actExecScenario();
newAct.execScenario.fastFlag = GameObject.Find("fastCheckbox").GetComponent<Toggle>().isOn;
newAct.execScenario.name = scExecDropdown.options[scExecDropdown.value].text;
string fastStr = "";
if (newAct.execScenario.fastFlag)
fastStr = "(момент.)";
newAct.title = "Выполнить сценарий"+ fastStr + " \"" + newAct.execScenario.name;
//if (newAct.execScenario.name.Length > 15) newAct.title += "..";
newAct.title += "\"";
sce.InsertAction(newAct);
}
public void InsActPlayAudio()
{
Dropdown dd = GameObject.Find("DropdownPlayAudio").GetComponent<Dropdown>();
if (dd.options[dd.value].text == "") return;
StartCoroutine(InsActPlayAudioCoroutine(dd.options[dd.value].text));
}
public void InsActSetSkybox()
{
ScAction newAct;
newAct = new ScAction(); newAct.type = "setSkybox";
newAct.objName = "";
newAct.setSkybox = new actSetSkybox(); newAct.setSkybox.name = "";
string ruName = "";
if (GameObject.Find("groundCheckbox").GetComponent<Toggle>().isOn)
{ newAct.setSkybox.name = "ground"; ruName = "земля"; }
if (GameObject.Find("skyCheckbox").GetComponent<Toggle>().isOn)
{ newAct.setSkybox.name = "sky"; ruName = "небо"; }
newAct.title = "Установить окружение: " + ruName;
sce.InsertAction(newAct);
}
public void InsActShowRect(int x1, int y1, int x2, int y2)
{
ScAction newAct;
newAct = new ScAction(); newAct.type = "showRect";
newAct.objName = "";
newAct.showRect = new actShowRect();
newAct.showRect.x1 = x1; newAct.showRect.y1 = y1;// newAct.showRect.z1 = z1;
newAct.showRect.x2 = x2; newAct.showRect.y2 = y2;// newAct.showRect.z2 = z2;
newAct.title = "Выделение области";
sce.InsertAction(newAct);
}
public void InsActHideRects()
{
ScAction newAct;
newAct = new ScAction(); newAct.type = "hideRects";
newAct.objName = "";
newAct.title = "Скрыть все выделения областей";
sce.InsertAction(newAct);
}
IEnumerator InsActPlayAudioCoroutine(string name)
{
AudioClip clip;
string path = Path.Combine(Application.streamingAssetsPath, "Scenario", sce.SC.name, name);
UnityWebRequest www;
if (name.EndsWith(".wav"))
www = UnityWebRequestMultimedia.GetAudioClip(path, AudioType.WAV);
else
www = UnityWebRequestMultimedia.GetAudioClip(path, AudioType.MPEG);
yield return www.SendWebRequest();
if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
{
Debug.LogError("error loading audio - " + www.error);
clip = null;
yield break;
}
else
clip = DownloadHandlerAudioClip.GetContent(www);
ScAction newAct;
newAct = new ScAction(); newAct.type = "playAudio";
newAct.objName = "";
newAct.playAudio = new actPlayAudio();
newAct.playAudio.filename = name;
newAct.title = "Воспроизвести аудио ("+Math.Round(clip.length, 1)+"с) \"" + newAct.playAudio.filename + "\"";
sce.InsertAction(newAct);
}
//нет необходимости в доп. данных:
// public class actOpenPanel { }
// public class actSwitchTo3D { }
// public class actHighlightOn { }
// public class actHighlightOff { }
// public class actWaitForClick { }
// public class actHideText { }
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a156bf39ee182fc47b714dca0643413e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: