12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using UnityEngine;
- using UnityEngine.EventSystems;
- using UnityEngine.UI;
- using wf;
- namespace MyRoomCustom
- {
- public class CreativeRoomUIObjectSettings : MonoBehaviour
- {
- private CreativeRoomUIObjectSettings.TYPE_GIZMO_CONTROL typeGizmoControl
- {
- get
- {
- return this.m_TypeGizmoControl;
- }
- set
- {
- this.m_TypeGizmoControl = value;
- }
- }
- private CreativeRoomUIObjectSettings.TYPE_OBJECT_CONTROL typeObjectControl
- {
- get
- {
- return this.m_TypeObjectControl;
- }
- set
- {
- this.m_TypeObjectControl = value;
- }
- }
- public float snapValuePosition
- {
- get
- {
- return this.m_SnapValuePosition;
- }
- set
- {
- this.m_SnapValuePosition = value;
- }
- }
- public float snapValueRotation
- {
- get
- {
- return this.m_SnapValueRotation;
- }
- set
- {
- this.m_SnapValueRotation = value;
- }
- }
- public float snapValueScale
- {
- get
- {
- return this.m_SnapValueScale;
- }
- set
- {
- this.m_SnapValueScale = value;
- }
- }
- public bool isVisibleDeployObject
- {
- get
- {
- return this.m_IsVisibleDeployObject;
- }
- set
- {
- Toggle uitoggleVisibleDeployObject = this.m_UIToggleVisibleDeployObject;
- this.m_IsVisibleDeployObject = value;
- uitoggleVisibleDeployObject.isOn = value;
- }
- }
- private void Awake()
- {
- }
- private void Start()
- {
- if (this.m_GizmoControlObject == null)
- {
- this.m_GizmoControlObject = new GameObject("[CreativeRoomUI ObjectSettings] GizmoControlObject").AddComponent<CreativeRoomUIObjectSettings.GizmoObject>();
- GameObject gameObject = new GameObject("Gizmo Rot");
- GameObject gameObject2 = Utility.CreatePrefab(null, "System/Prefab/XYZAxis", true);
- GizmoRender gizmoRender = gameObject.AddComponent<GizmoRender>();
- WorldTransformAxis component = gameObject2.GetComponent<WorldTransformAxis>();
- this.m_GizmoControlObject.Initialize(gizmoRender, component);
- gizmoRender.offsetScale = 1f;
- gizmoRender.eAxis = false;
- gizmoRender.eRotate = true;
- gizmoRender.eScal = false;
- component.TargetObject = this.m_GizmoControlObject.gameObject;
- this.ButtonEvent_SetSelectingObjectEnableMove();
- if (this.m_SelectingObject != null)
- {
- Transform transform = this.m_SelectingObject.transform;
- this.m_GizmoControlObject.pos = transform.position;
- this.m_GizmoControlObject.eulerAngles = transform.eulerAngles;
- this.m_GizmoControlObject.scale = transform.localScale;
- }
- else
- {
- this.SetDeploymentObjectGizmoEnable(false);
- }
- }
- this.m_UIToggleObjectEnable.onValueChanged.AddListener(delegate(bool value)
- {
- if (this.m_SelectingObject)
- {
- this.m_SelectingObject.SetActive(value);
- this.m_DeploymentObjectInstanceArray[this.m_SelectingObject].active = value;
- }
- });
- this.m_UIToggleGizmoGridEnable.onValueChanged.AddListener(delegate(bool value)
- {
- this.typeObjectControl = ((!value) ? CreativeRoomUIObjectSettings.TYPE_OBJECT_CONTROL.Default : CreativeRoomUIObjectSettings.TYPE_OBJECT_CONTROL.Snap);
- });
- Action<InputField, Action<float>, Action> action = delegate(InputField input_field_, Action<float> delegate_changed, Action delegate_end)
- {
- input_field_.onValueChanged.AddListener(delegate(string str)
- {
- if (!input_field_.isFocused || this.m_SelectingObject == null || delegate_changed == null)
- {
- return;
- }
- float obj;
- if (float.TryParse(str, out obj))
- {
- delegate_changed(obj);
- }
- });
- input_field_.onEndEdit.AddListener(delegate(string str)
- {
- if (this.m_SelectingObject == null || delegate_end == null)
- {
- return;
- }
- delegate_end();
- });
- };
- action(this.m_UIInputFieldPosX, delegate(float value)
- {
- Vector3 pos = this.m_GizmoControlObject.pos;
- pos.x = value;
- Transform transform2 = this.m_SelectingObject.transform;
- Vector3 vector = pos;
- this.m_GizmoControlObject.pos = vector;
- transform2.position = vector;
- }, delegate
- {
- this.m_UIInputFieldPosX.text = this.m_GizmoControlObject.pos.x.ToString("f3");
- });
- action(this.m_UIInputFieldPosY, delegate(float value)
- {
- Vector3 pos = this.m_GizmoControlObject.pos;
- pos.y = value;
- Transform transform2 = this.m_SelectingObject.transform;
- Vector3 vector = pos;
- this.m_GizmoControlObject.pos = vector;
- transform2.position = vector;
- }, delegate
- {
- this.m_UIInputFieldPosY.text = this.m_GizmoControlObject.pos.y.ToString("f3");
- });
- action(this.m_UIInputFieldPosZ, delegate(float value)
- {
- Vector3 pos = this.m_GizmoControlObject.pos;
- pos.z = value;
- Transform transform2 = this.m_SelectingObject.transform;
- Vector3 vector = pos;
- this.m_GizmoControlObject.pos = vector;
- transform2.position = vector;
- }, delegate
- {
- this.m_UIInputFieldPosZ.text = this.m_GizmoControlObject.pos.z.ToString("f3");
- });
- action(this.m_UIInputFieldEulerX, delegate(float value)
- {
- Vector3 eulerAngles = this.m_GizmoControlObject.eulerAngles;
- eulerAngles.x = value;
- Transform transform2 = this.m_SelectingObject.transform;
- Vector3 eulerAngles2 = eulerAngles;
- this.m_GizmoControlObject.eulerAngles = eulerAngles2;
- transform2.eulerAngles = eulerAngles2;
- }, delegate
- {
- this.m_UIInputFieldEulerX.text = this.m_GizmoControlObject.eulerAngles.x.ToString("f3");
- });
- action(this.m_UIInputFieldEulerY, delegate(float value)
- {
- Vector3 eulerAngles = this.m_GizmoControlObject.eulerAngles;
- eulerAngles.y = value;
- Transform transform2 = this.m_SelectingObject.transform;
- Vector3 eulerAngles2 = eulerAngles;
- this.m_GizmoControlObject.eulerAngles = eulerAngles2;
- transform2.eulerAngles = eulerAngles2;
- }, delegate
- {
- this.m_UIInputFieldEulerY.text = this.m_GizmoControlObject.eulerAngles.y.ToString("f3");
- });
- action(this.m_UIInputFieldEulerZ, delegate(float value)
- {
- Vector3 eulerAngles = this.m_GizmoControlObject.eulerAngles;
- eulerAngles.z = value;
- Transform transform2 = this.m_SelectingObject.transform;
- Vector3 eulerAngles2 = eulerAngles;
- this.m_GizmoControlObject.eulerAngles = eulerAngles2;
- transform2.eulerAngles = eulerAngles2;
- }, delegate
- {
- this.m_UIInputFieldEulerZ.text = this.m_GizmoControlObject.eulerAngles.z.ToString("f3");
- });
- action(this.m_UIInputFieldScale, delegate(float value)
- {
- Vector3 scale = this.m_GizmoControlObject.scale;
- value = Mathf.Clamp(value, this.m_UISliderScale.minValue, this.m_UISliderScale.maxValue);
- scale.x = (scale.y = (scale.z = value));
- Transform transform2 = this.m_SelectingObject.transform;
- Vector3 vector = scale;
- this.m_GizmoControlObject.scale = vector;
- transform2.localScale = vector;
- this.m_UISliderScale.value = value;
- }, delegate
- {
- this.m_UIInputFieldScale.text = this.m_GizmoControlObject.scale.x.ToString("f3");
- });
- this.m_UISliderScale.onValueChanged.AddListener(delegate(float value)
- {
- if (this.m_GizmoControlObject == null || this.m_SelectingObject == null)
- {
- return;
- }
- Vector3 scale = this.m_GizmoControlObject.scale;
- scale.x = (scale.y = scale.z);
- if (!this.m_SelectingObject.activeInHierarchy)
- {
- if (Mathf.Approximately(scale.x, value))
- {
- return;
- }
- this.m_UISliderScale.value = scale.x;
- return;
- }
- else
- {
- if (Mathf.Approximately(scale.x, value))
- {
- return;
- }
- this.m_GizmoControlObject.scale = Vector3.one * value;
- this.m_UIInputFieldScale.text = value.ToString("f3");
- return;
- }
- });
- Action<string, Button, Func<Vector3>> action2 = delegate(string key, Button button, Func<Vector3> delegate_get_vector3)
- {
- button.onClick.AddListener(delegate()
- {
- if (this.m_SelectingObject == null)
- {
- return;
- }
- Vector3 vector = delegate_get_vector3();
- StringWriter stringWriter = new StringWriter();
- stringWriter.WriteLine(vector.x);
- stringWriter.WriteLine(vector.y);
- stringWriter.WriteLine(vector.z);
- this.SetClipboardData(key, stringWriter.ToString());
- });
- };
- Action<string, Button, Action<Vector3>> action3 = delegate(string key, Button button, Action<Vector3> delegate_return_vector3)
- {
- button.onClick.AddListener(delegate()
- {
- if (this.m_SelectingObject == null)
- {
- return;
- }
- string clipboardData = this.GetClipboardData(key);
- if (clipboardData == string.Empty)
- {
- return;
- }
- StringReader stringReader = new StringReader(clipboardData);
- try
- {
- Vector3 obj = default(Vector3);
- obj.x = float.Parse(stringReader.ReadLine());
- obj.y = float.Parse(stringReader.ReadLine());
- obj.z = float.Parse(stringReader.ReadLine());
- delegate_return_vector3(obj);
- }
- catch
- {
- }
- });
- };
- Action<Button, Func<Vector3>, Action<Vector3>> action4 = delegate(Button button, Func<Vector3> delegate_get_vector3, Action<Vector3> delegate_return_vector3)
- {
- button.onClick.AddListener(delegate()
- {
- if (this.m_SelectingObject == null)
- {
- return;
- }
- delegate_return_vector3(delegate_get_vector3());
- this.UpdateInputFieldText(this.m_SelectingObject.transform);
- });
- };
- Transform parent = this.m_UIInputFieldPosX.transform.parent;
- Button component2 = parent.Find("Button Copy").GetComponent<Button>();
- action2("pos", component2, () => this.m_GizmoControlObject.pos);
- component2 = parent.Find("Button Paste").GetComponent<Button>();
- action3("pos", component2, delegate(Vector3 vec)
- {
- Transform transform2 = this.m_SelectingObject.transform;
- this.m_GizmoControlObject.pos = vec;
- transform2.position = vec;
- this.UpdateInputFieldText(this.m_SelectingObject.transform);
- });
- component2 = parent.Find("Button Reset").GetComponent<Button>();
- action4(component2, () => Vector3.zero, delegate(Vector3 vec)
- {
- Transform transform2 = this.m_SelectingObject.transform;
- this.m_GizmoControlObject.pos = vec;
- transform2.position = vec;
- });
- parent = this.m_UIInputFieldEulerX.transform.parent;
- component2 = parent.Find("Button Copy").GetComponent<Button>();
- action2("rot", component2, () => this.m_GizmoControlObject.eulerAngles);
- component2 = parent.Find("Button Paste").GetComponent<Button>();
- action3("rot", component2, delegate(Vector3 vec)
- {
- Transform transform2 = this.m_SelectingObject.transform;
- this.m_GizmoControlObject.eulerAngles = vec;
- transform2.eulerAngles = vec;
- this.UpdateInputFieldText(this.m_SelectingObject.transform);
- });
- component2 = parent.Find("Button Reset").GetComponent<Button>();
- action4(component2, () => Vector3.zero, delegate(Vector3 vec)
- {
- Transform transform2 = this.m_SelectingObject.transform;
- this.m_GizmoControlObject.eulerAngles = vec;
- transform2.eulerAngles = vec;
- });
- parent = this.m_UIInputFieldScale.transform.parent;
- component2 = parent.Find("Button Copy").GetComponent<Button>();
- action2("scale", component2, () => this.m_GizmoControlObject.scale);
- component2 = parent.Find("Button Paste").GetComponent<Button>();
- action3("scale", component2, delegate(Vector3 vec)
- {
- Transform transform2 = this.m_SelectingObject.transform;
- this.m_GizmoControlObject.scale = vec;
- transform2.localScale = vec;
- this.UpdateInputFieldText(this.m_SelectingObject.transform);
- });
- component2 = parent.Find("Button Reset").GetComponent<Button>();
- action4(component2, () => Vector3.one, delegate(Vector3 vec)
- {
- Transform transform2 = this.m_SelectingObject.transform;
- this.m_GizmoControlObject.scale = vec;
- transform2.localScale = vec;
- });
- this.m_UIToggleVisibleDeployObject.onValueChanged.AddListener(delegate(bool value)
- {
- this.isVisibleDeployObject = value;
- List<GameObject> list = new List<GameObject>(this.m_DeploymentObjectInstanceArray.Keys);
- List<CreativeRoomUIObjectSettings.DeployObjectInstanceData> list2 = new List<CreativeRoomUIObjectSettings.DeployObjectInstanceData>(this.m_DeploymentObjectInstanceArray.Values);
- for (int i = 0; i < list.Count; i++)
- {
- list[i].SetActive(value & list2[i].active);
- }
- });
- }
- private void LateUpdate()
- {
- if (this.m_SelectingObject == null)
- {
- return;
- }
- Transform transform = this.m_SelectingObject.transform;
- Vector3 vector = this.m_GizmoControlObject.pos - transform.position;
- Vector3 vector2 = this.m_GizmoControlObject.eulerAngles - transform.eulerAngles;
- Vector3 vector3 = this.m_GizmoControlObject.scale - transform.localScale;
- if (this.m_SelectingObject.activeInHierarchy && (vector.sqrMagnitude > 0f || vector2.sqrMagnitude > 0f || vector3.sqrMagnitude > 0f))
- {
- if (this.typeObjectControl == CreativeRoomUIObjectSettings.TYPE_OBJECT_CONTROL.Default)
- {
- transform.position = this.m_GizmoControlObject.pos;
- transform.rotation = this.m_GizmoControlObject.rot;
- transform.localScale = this.m_GizmoControlObject.scale;
- this.UpdateInputFieldText(transform);
- }
- else if (this.typeObjectControl == CreativeRoomUIObjectSettings.TYPE_OBJECT_CONTROL.Snap)
- {
- if (vector.sqrMagnitude >= this.snapValuePosition * this.snapValuePosition)
- {
- Vector3 pos = this.m_GizmoControlObject.pos;
- pos.x = Mathf.Round(pos.x / this.snapValuePosition) * this.snapValuePosition;
- pos.y = Mathf.Round(pos.y / this.snapValuePosition) * this.snapValuePosition;
- pos.z = Mathf.Round(pos.z / this.snapValuePosition) * this.snapValuePosition;
- transform.position = pos;
- }
- if (vector2.sqrMagnitude >= this.snapValueRotation * this.snapValueRotation)
- {
- Quaternion rot = this.m_GizmoControlObject.rot;
- Quaternion rotation = transform.rotation;
- float snapValueRotation = this.snapValueRotation;
- float num = Quaternion.Angle(rotation, rot);
- if (Mathf.Abs(num) > snapValueRotation)
- {
- Quaternion rotation2 = Quaternion.RotateTowards(rotation, rot, Mathf.Floor(num / snapValueRotation) * snapValueRotation);
- transform.rotation = rotation2;
- }
- }
- if (vector3.sqrMagnitude >= this.snapValueScale * this.snapValueScale)
- {
- Vector3 localScale = Mathf.Round(this.m_GizmoControlObject.scale.x / this.snapValueScale) * this.snapValueScale * Vector3.one;
- transform.localScale = localScale;
- }
- if (vector.sqrMagnitude + vector2.sqrMagnitude + vector3.sqrMagnitude > 0f)
- {
- this.UpdateInputFieldText(transform);
- }
- }
- }
- if (NInput.GetMouseButtonUp(0) && this.m_SelectingObject)
- {
- this.m_GizmoControlObject.pos = transform.position;
- this.m_GizmoControlObject.eulerAngles = transform.eulerAngles;
- }
- if (!GizmoRender.UIVisible && GizmoRender.UIVisible != this.m_GizmoControlObject.gameObject.activeSelf)
- {
- this.SetDeploymentObjectGizmoEnable(false);
- }
- }
- public void Update()
- {
- if (EventSystem.current != null)
- {
- if (NInput.GetMouseButtonDown(0))
- {
- GameObject currentSelectedGameObject = EventSystem.current.currentSelectedGameObject;
- if (EventSystem.current.IsPointerOverGameObject() && currentSelectedGameObject != null && currentSelectedGameObject.GetComponent<RectTransform>())
- {
- this.SetDeploymentObjectGizmoEnable(false);
- }
- }
- else if (NInput.GetMouseButtonUp(0))
- {
- this.SetDeploymentObjectGizmoEnable(true);
- }
- }
- }
- private void SetClipboardData(string key, string value)
- {
- if (this.m_Clipboard.ContainsKey(key))
- {
- this.m_Clipboard[key] = value;
- }
- else
- {
- this.m_Clipboard.Add(key, value);
- }
- }
- private string GetClipboardData(string key)
- {
- if (!this.m_Clipboard.ContainsKey(key))
- {
- return string.Empty;
- }
- return this.m_Clipboard[key];
- }
- public void SetDeploymentObjectGizmoEnable(bool b)
- {
- if (this.m_GizmoControlObject == null)
- {
- return;
- }
- if (!base.gameObject.activeInHierarchy)
- {
- this.m_GizmoControlObject.gameObject.SetActive(false);
- }
- else if (this.m_SelectingObject == null)
- {
- this.m_GizmoControlObject.gameObject.SetActive(false);
- }
- else
- {
- this.m_GizmoControlObject.gameObject.SetActive(b);
- }
- }
- public void CreateOdoguObjectButtons(int placementObjCategoryID)
- {
- CreativeRoomUIObjectSettings.<CreateOdoguObjectButtons>c__AnonStorey4 <CreateOdoguObjectButtons>c__AnonStorey = new CreativeRoomUIObjectSettings.<CreateOdoguObjectButtons>c__AnonStorey4();
- <CreateOdoguObjectButtons>c__AnonStorey.placementObjCategoryID = placementObjCategoryID;
- <CreateOdoguObjectButtons>c__AnonStorey.$this = this;
- <CreateOdoguObjectButtons>c__AnonStorey.dataList = PlacementData.GetDatas((PlacementData.Data data) => data.categoryID == <CreateOdoguObjectButtons>c__AnonStorey.placementObjCategoryID);
- Debug.LogFormat("カテゴリID「{0}」\nデータ数「{1}」", new object[]
- {
- <CreateOdoguObjectButtons>c__AnonStorey.placementObjCategoryID,
- <CreateOdoguObjectButtons>c__AnonStorey.dataList.Count
- });
- this.m_UIParentDeployableObjectButtons.Show<Button>(<CreateOdoguObjectButtons>c__AnonStorey.dataList.Count, delegate(int i, Button button)
- {
- PlacementData.Data data = <CreateOdoguObjectButtons>c__AnonStorey.dataList[i];
- Text componentInChildren = button.GetComponentInChildren<Text>();
- RawImage component = button.GetComponent<RawImage>();
- Texture texture = null;
- if (!<CreateOdoguObjectButtons>c__AnonStorey.$this.m_CachedItemIconDic.TryGetValue(data.ID, out texture))
- {
- texture = data.GetThumbnail();
- <CreateOdoguObjectButtons>c__AnonStorey.$this.m_CachedItemIconDic.Add(data.ID, texture);
- }
- if (texture != null)
- {
- componentInChildren.gameObject.SetActive(false);
- component.texture = texture;
- }
- else
- {
- componentInChildren.text = data.drawName;
- }
- button.onClick.AddListener(delegate()
- {
- GameObject gameObject = <CreateOdoguObjectButtons>c__AnonStorey.CreateOdoguObject(data.ID);
- if (!gameObject)
- {
- return;
- }
- <CreateOdoguObjectButtons>c__AnonStorey.AddEvent_ObjectClickSelect(gameObject);
- <CreateOdoguObjectButtons>c__AnonStorey.CreateDeploymentObjectButtons();
- <CreateOdoguObjectButtons>c__AnonStorey.SetSelectingObject(gameObject, null);
- <CreateOdoguObjectButtons>c__AnonStorey.m_UIToggleVisibleDeployObject.isOn = true;
- });
- });
- }
- private GameObject CreateOdoguObject(int objectID)
- {
- GameObject gameObject = GameObject.Find("Deployment Object Parent");
- if (gameObject == null)
- {
- gameObject = new GameObject("Deployment Object Parent");
- }
- if (!PlacementData.Contains(objectID))
- {
- Debug.LogWarningFormat("[Creative Room]配置物データID[{0}]の情報は存在しません", new object[]
- {
- objectID
- });
- return null;
- }
- PlacementData.Data data = PlacementData.GetData(objectID);
- GameObject prefab = data.GetPrefab();
- if (prefab == null)
- {
- return null;
- }
- GameObject gameObject2 = UnityEngine.Object.Instantiate<GameObject>(prefab);
- GameObject gameObject3 = new GameObject(gameObject2.name);
- gameObject2.transform.SetParent(gameObject3.transform, true);
- CreativeRoomUIObjectSettings.DeployObjectInstanceData value = new CreativeRoomUIObjectSettings.DeployObjectInstanceData(CreativeRoomUIObjectSettings.TYPE_OBJECT_CONTROL.Default, objectID, null);
- this.m_DeploymentObjectInstanceArray.Add(gameObject3, value);
- gameObject3.transform.SetParent(gameObject.transform, false);
- return gameObject3;
- }
- private void AddEvent_ObjectClickSelect(GameObject Obj)
- {
- Collider[] cols = Obj.GetComponentsInChildren<Collider>();
- if (cols.Length <= 0)
- {
- Debug.LogWarning("配置物[" + Obj.name + "]に、当たり判定がついていないので強制的に追加しました");
- MeshRenderer componentInChildren = Obj.GetComponentInChildren<MeshRenderer>(true);
- if (componentInChildren != null)
- {
- componentInChildren.gameObject.AddComponent<BoxCollider>();
- }
- cols = Obj.GetComponentsInChildren<Collider>();
- }
- CreativeRoomUIObjectSettings.MouseEvent mouseEvent = cols[0].gameObject.AddComponent<CreativeRoomUIObjectSettings.MouseEvent>();
- mouseEvent.onPointerClick = delegate(PointerEventData data)
- {
- if (NInput.GetMouseButtonUp(0))
- {
- this.SetSelectingObject(Obj, null);
- }
- };
- mouseEvent.onBeginDrag = delegate(PointerEventData data)
- {
- for (int i = 0; i < cols.Length; i++)
- {
- cols[i].enabled = false;
- }
- };
- mouseEvent.onEndDrag = delegate(PointerEventData data)
- {
- for (int i = 0; i < cols.Length; i++)
- {
- cols[i].enabled = true;
- }
- };
- }
- public void ButtonEvent_SetSelectingObjectEnableMove()
- {
- this.m_GizmoControlObject.activeAxis = true;
- this.m_GizmoControlObject.activeRot = false;
- this.m_TypeGizmoControl = CreativeRoomUIObjectSettings.TYPE_GIZMO_CONTROL.Move;
- }
- public void ButtonEvent_SetSelectingObjectEnableRot()
- {
- this.m_GizmoControlObject.activeAxis = false;
- this.m_GizmoControlObject.activeRot = true;
- this.m_TypeGizmoControl = CreativeRoomUIObjectSettings.TYPE_GIZMO_CONTROL.Rotate;
- }
- public void ButtonEvent_SetSelectingObjectDisableGizmo()
- {
- this.m_GizmoControlObject.activeAxis = false;
- this.m_GizmoControlObject.activeRot = false;
- this.m_TypeGizmoControl = CreativeRoomUIObjectSettings.TYPE_GIZMO_CONTROL.None;
- }
- public void SetSelectingObject(GameObject newObj, GameObject buttonObj = null)
- {
- if (newObj && this.m_GizmoControlObject)
- {
- this.m_GizmoControlObject.pos = newObj.transform.position;
- this.m_GizmoControlObject.eulerAngles = newObj.transform.eulerAngles;
- this.m_GizmoControlObject.scale = newObj.transform.localScale;
- this.SetDeploymentObjectGizmoEnable(true);
- if (this.typeGizmoControl == CreativeRoomUIObjectSettings.TYPE_GIZMO_CONTROL.Move)
- {
- this.ButtonEvent_SetSelectingObjectEnableMove();
- }
- else if (this.typeGizmoControl == CreativeRoomUIObjectSettings.TYPE_GIZMO_CONTROL.Rotate)
- {
- this.ButtonEvent_SetSelectingObjectEnableRot();
- }
- else if (this.typeGizmoControl == CreativeRoomUIObjectSettings.TYPE_GIZMO_CONTROL.None)
- {
- this.ButtonEvent_SetSelectingObjectDisableGizmo();
- }
- }
- this.m_SelectingObject = newObj;
- this.typeGizmoControl = this.typeGizmoControl;
- if (newObj)
- {
- this.m_UIToggleObjectEnable.isOn = newObj.activeInHierarchy;
- }
- if (newObj)
- {
- this.UpdateInputFieldText(newObj.transform);
- }
- if (newObj == null)
- {
- if (this.m_GizmoControlObject)
- {
- this.SetDeploymentObjectGizmoEnable(false);
- }
- return;
- }
- Transform transform = this.m_UIParentDeploymentObjectButtons.transform;
- if (buttonObj == null && (buttonObj = this.m_DeploymentObjectInstanceArray[newObj].uiButtonObject) == null)
- {
- return;
- }
- Color color = new Color(0.65f, 0.65f, 0.65f, 1f);
- Color white = Color.white;
- for (int i = 0; i < transform.childCount; i++)
- {
- Transform child = transform.GetChild(i);
- Graphic targetGraphic = child.GetChild(0).GetComponent<Selectable>().targetGraphic;
- if (buttonObj != child.gameObject)
- {
- targetGraphic.color = color;
- }
- else
- {
- targetGraphic.color = white;
- }
- }
- }
- public void ButtonEvent_CameraFocus()
- {
- if (this.m_SelectingObject == null)
- {
- return;
- }
- WfCameraMoveSupport wfCameraMoveSupport = base.GetComponent<WfCameraMoveSupport>();
- if (wfCameraMoveSupport == null)
- {
- wfCameraMoveSupport = base.gameObject.AddComponent<WfCameraMoveSupport>();
- }
- Vector3 position = this.m_SelectingObject.transform.position;
- float distance = 5f;
- Vector2 aroundAngle = new Vector2(-135f, 45f);
- wfCameraMoveSupport.StartCameraPosition(position, distance, aroundAngle);
- }
- private void UpdateInputFieldText(Transform trans)
- {
- if (trans)
- {
- this.UpdateInputFieldText(trans.position, trans.eulerAngles, trans.lossyScale);
- }
- else
- {
- this.UpdateInputFieldText(Vector3.zero, Vector3.zero, Vector3.zero);
- }
- }
- private void UpdateInputFieldText(Vector3 pos, Vector3 euler, Vector3 scale)
- {
- if (!this.m_UIInputFieldPosX.isFocused)
- {
- this.m_UIInputFieldPosX.text = pos.x.ToString("f3");
- }
- if (!this.m_UIInputFieldPosY.isFocused)
- {
- this.m_UIInputFieldPosY.text = pos.y.ToString("f3");
- }
- if (!this.m_UIInputFieldPosZ.isFocused)
- {
- this.m_UIInputFieldPosZ.text = pos.z.ToString("f3");
- }
- if (!this.m_UIInputFieldEulerX.isFocused)
- {
- this.m_UIInputFieldEulerX.text = euler.x.ToString("f3");
- }
- if (!this.m_UIInputFieldEulerY.isFocused)
- {
- this.m_UIInputFieldEulerY.text = euler.y.ToString("f3");
- }
- if (!this.m_UIInputFieldEulerZ.isFocused)
- {
- this.m_UIInputFieldEulerZ.text = euler.z.ToString("f3");
- }
- if (!this.m_UIInputFieldScale.isFocused)
- {
- this.m_UIInputFieldScale.text = scale.x.ToString("f3");
- }
- this.m_UISliderScale.value = scale.x;
- }
- private void CreateDeploymentObjectButtons()
- {
- uGUIListViewer uiparentDeploymentObjectButtons = this.m_UIParentDeploymentObjectButtons;
- Transform transform = uiparentDeploymentObjectButtons.transform;
- VerticalLayoutGroup component = uiparentDeploymentObjectButtons.GetComponent<VerticalLayoutGroup>();
- component.enabled = false;
- Transform child = transform.GetChild(0);
- List<GameObject> list = new List<GameObject>(this.m_DeploymentObjectInstanceArray.Keys);
- for (int i = 0; i < this.m_DeploymentObjectInstanceArray.Count; i++)
- {
- GameObject Obj = list[i];
- CreativeRoomUIObjectSettings.DeployObjectInstanceData deployObjectInstanceData = this.m_DeploymentObjectInstanceArray[Obj];
- if (!(deployObjectInstanceData.uiButtonObject != null))
- {
- if (PlacementData.Contains(deployObjectInstanceData.objectID))
- {
- Transform transform2 = UnityEngine.Object.Instantiate<Transform>(child);
- transform2.gameObject.SetActive(true);
- transform2.SetParent(transform, false);
- Button[] componentsInChildren = transform2.GetComponentsInChildren<Button>();
- componentsInChildren[0].GetComponentInChildren<Text>().text = PlacementData.GetData(deployObjectInstanceData.objectID).drawName;
- Utility.SetLocalizeTerm(componentsInChildren[0].GetComponentInChildren<Text>(), PlacementData.GetData(deployObjectInstanceData.objectID).drawNameTerm, false);
- componentsInChildren[0].onClick.RemoveAllListeners();
- componentsInChildren[1].onClick.RemoveAllListeners();
- componentsInChildren[0].onClick.AddListener(delegate()
- {
- if (this.m_SelectingObject == Obj)
- {
- this.ButtonEvent_CameraFocus();
- }
- else
- {
- this.SetSelectingObject(Obj, null);
- }
- });
- componentsInChildren[1].onClick.AddListener(delegate()
- {
- this.DestroyDeploymentObject(Obj);
- });
- deployObjectInstanceData.uiButtonObject = transform2.gameObject;
- }
- }
- }
- this.m_UITextDeployObjectNum.text = this.m_DeploymentObjectInstanceArray.Count.ToString();
- component.enabled = true;
- }
- private void DestroyDeploymentObject(GameObject Obj)
- {
- if (this.m_SelectingObject != null && this.m_SelectingObject == Obj)
- {
- this.SetDeploymentObjectGizmoEnable(false);
- }
- if (this.m_DeploymentObjectInstanceArray.ContainsKey(Obj))
- {
- UnityEngine.Object.Destroy(this.m_DeploymentObjectInstanceArray[Obj].uiButtonObject);
- this.m_DeploymentObjectInstanceArray.Remove(Obj);
- UnityEngine.Object.Destroy(Obj);
- }
- this.m_UITextDeployObjectNum.text = this.m_DeploymentObjectInstanceArray.Count.ToString();
- }
- public void SaveDeployObjectData(BinaryWriter binary)
- {
- int count = this.m_DeploymentObjectInstanceArray.Count;
- binary.Write(count);
- List<GameObject> list = new List<GameObject>(this.m_DeploymentObjectInstanceArray.Keys);
- for (int i = 0; i < count; i++)
- {
- GameObject gameObject = list[i];
- CreativeRoomUIObjectSettings.DeployObjectInstanceData deployObjectInstanceData = this.m_DeploymentObjectInstanceArray[gameObject];
- binary.Write(gameObject.transform.position.x);
- binary.Write(gameObject.transform.position.y);
- binary.Write(gameObject.transform.position.z);
- binary.Write(gameObject.transform.eulerAngles.x);
- binary.Write(gameObject.transform.eulerAngles.y);
- binary.Write(gameObject.transform.eulerAngles.z);
- binary.Write(gameObject.transform.localScale.x);
- binary.Write(deployObjectInstanceData.active);
- binary.Write(deployObjectInstanceData.objectID);
- }
- }
- public void LoadDeployObjectData(BinaryReader brRead)
- {
- List<GameObject> list = new List<GameObject>(this.m_DeploymentObjectInstanceArray.Keys);
- for (int i = 0; i < list.Count; i++)
- {
- this.DestroyDeploymentObject(list[i]);
- }
- int num = brRead.ReadInt32();
- for (int j = 0; j < num; j++)
- {
- Vector3 zero = Vector3.zero;
- Vector3 zero2 = Vector3.zero;
- Vector3 localScale = Vector3.zero;
- zero[0] = brRead.ReadSingle();
- zero[1] = brRead.ReadSingle();
- zero[2] = brRead.ReadSingle();
- zero2[0] = brRead.ReadSingle();
- zero2[1] = brRead.ReadSingle();
- zero2[2] = brRead.ReadSingle();
- localScale = brRead.ReadSingle() * Vector3.one;
- bool active = brRead.ReadBoolean();
- int objectID = brRead.ReadInt32();
- GameObject gameObject = this.CreateOdoguObject(objectID);
- if (gameObject)
- {
- Transform transform = gameObject.transform;
- transform.position = zero;
- transform.eulerAngles = zero2;
- transform.localScale = localScale;
- gameObject.SetActive(active);
- this.AddEvent_ObjectClickSelect(gameObject);
- }
- }
- this.SetSelectingObject(null, null);
- this.CreateDeploymentObjectButtons();
- this.m_UIToggleVisibleDeployObject.isOn = true;
- }
- public static GameObject Load(BinaryReader brRead)
- {
- GameObject gameObject = new GameObject("Parent Deployment Object");
- Transform transform = gameObject.transform;
- int num = brRead.ReadInt32();
- for (int i = 0; i < num; i++)
- {
- Vector3 zero = Vector3.zero;
- Vector3 zero2 = Vector3.zero;
- Vector3 localScale = Vector3.zero;
- zero[0] = brRead.ReadSingle();
- zero[1] = brRead.ReadSingle();
- zero[2] = brRead.ReadSingle();
- zero2[0] = brRead.ReadSingle();
- zero2[1] = brRead.ReadSingle();
- zero2[2] = brRead.ReadSingle();
- localScale = brRead.ReadSingle() * Vector3.one;
- bool active = brRead.ReadBoolean();
- int num2 = brRead.ReadInt32();
- if (!PlacementData.Contains(num2))
- {
- Debug.LogWarningFormat("[Creative Room]配置物データID[{0}]の情報は存在しません", new object[]
- {
- num2
- });
- }
- else
- {
- PlacementData.Data data = PlacementData.GetData(num2);
- GameObject prefab = data.GetPrefab();
- if (!(prefab == null))
- {
- GameObject gameObject2 = UnityEngine.Object.Instantiate<GameObject>(prefab);
- GameObject gameObject3 = new GameObject(gameObject2.name);
- gameObject2.transform.SetParent(gameObject3.transform, true);
- Transform transform2 = gameObject3.transform;
- transform2.position = zero;
- transform2.eulerAngles = zero2;
- transform2.localScale = localScale;
- gameObject2.SetActive(active);
- transform2.SetParent(transform, true);
- }
- }
- }
- return gameObject;
- }
- private void OnEnable()
- {
- CreativeRoomUIObjectSettings.<OnEnable>c__AnonStorey8 <OnEnable>c__AnonStorey = new CreativeRoomUIObjectSettings.<OnEnable>c__AnonStorey8();
- <OnEnable>c__AnonStorey.$this = this;
- <OnEnable>c__AnonStorey.categoryIDList = PlacementData.CategoryIDList;
- this.m_UIParentDeployableObjectCategoryButtons.Show<Button>(<OnEnable>c__AnonStorey.categoryIDList.Count, delegate(int i, Button button)
- {
- Text componentInChildren = button.GetComponentInChildren<Text>();
- componentInChildren.text = PlacementData.GetCategoryName(<OnEnable>c__AnonStorey.categoryIDList[i]);
- Utility.SetLocalizeTerm(componentInChildren, "SceneCreativeRoom/カテゴリー/" + <OnEnable>c__AnonStorey.categoryIDList[i].ToString(), false);
- button.onClick.AddListener(delegate()
- {
- Debug.LogFormat("カテゴリ「{0}」", new object[]
- {
- PlacementData.GetCategoryName(<OnEnable>c__AnonStorey.categoryIDList[i])
- });
- <OnEnable>c__AnonStorey.CreateOdoguObjectButtons(<OnEnable>c__AnonStorey.categoryIDList[i]);
- });
- });
- }
- private void OnDisable()
- {
- this.SetDeploymentObjectGizmoEnable(false);
- }
- private void OnDestroy()
- {
- if (this.m_DeploymentObjectInstanceArray != null)
- {
- this.m_DeploymentObjectInstanceArray.Clear();
- }
- if (this.m_Clipboard != null)
- {
- this.m_Clipboard.Clear();
- }
- GameObject gameObject = GameObject.Find("Deployment Object Parent");
- if (gameObject != null)
- {
- UnityEngine.Object.Destroy(gameObject);
- }
- if (this.m_CachedItemIconDic != null)
- {
- int count = this.m_CachedItemIconDic.Count;
- List<Texture> list = new List<Texture>(this.m_CachedItemIconDic.Values);
- for (int i = 0; i < list.Count; i++)
- {
- if (list[i] != null)
- {
- UnityEngine.Object.DestroyImmediate(list[i], true);
- }
- list[i] = null;
- }
- this.m_CachedItemIconDic.Clear();
- }
- if (this.m_GizmoControlObject)
- {
- UnityEngine.Object.Destroy(this.m_GizmoControlObject);
- }
- }
- [Header("配置オブジェクトのカテゴリ一覧関連")]
- [SerializeField]
- [Tooltip("配置オブジェクトのカテゴリ一覧関連")]
- private uGUIListViewer m_UIParentDeployableObjectCategoryButtons;
- [Header("配置可能オブジェクト一覧関連")]
- [SerializeField]
- [Tooltip("配置可能オブジェクトのボタンを並べている親オブジェクト")]
- private uGUIListViewer m_UIParentDeployableObjectButtons;
- [Header("オブジェクトパラメータ一覧関連")]
- [SerializeField]
- [Tooltip("選択中の配置オブジェクトの有効/無効を切り替えるトグル ")]
- private Toggle m_UIToggleObjectEnable;
- [SerializeField]
- [Tooltip("オブジェクトのパラメータ操作スナップの有効/無効を切り替えるトグル")]
- private Toggle m_UIToggleGizmoGridEnable;
- [SerializeField]
- [Tooltip("選択中の配置オブジェクトの座標を入出力するエリア")]
- private InputField m_UIInputFieldPosX;
- [SerializeField]
- [Tooltip("選択中の配置オブジェクトの座標を入出力するエリア")]
- private InputField m_UIInputFieldPosY;
- [SerializeField]
- [Tooltip("選択中の配置オブジェクトの座標を入出力するエリア")]
- private InputField m_UIInputFieldPosZ;
- [SerializeField]
- [Tooltip("選択中の配置オブジェクトの回転を入出力するエリア")]
- private InputField m_UIInputFieldEulerX;
- [SerializeField]
- [Tooltip("選択中の配置オブジェクトの回転を入出力するエリア")]
- private InputField m_UIInputFieldEulerY;
- [SerializeField]
- [Tooltip("選択中の配置オブジェクトの回転を入出力するエリア")]
- private InputField m_UIInputFieldEulerZ;
- [SerializeField]
- [Tooltip("選択中の配置オブジェクトの大きさを入出力するエリア")]
- private InputField m_UIInputFieldScale;
- [SerializeField]
- [Tooltip("選択中の配置オブジェクトの大きさを入出力するスライダー")]
- private Slider m_UISliderScale;
- [Header("配置中オブジェクト一覧関連")]
- [SerializeField]
- [Tooltip("配置中オブジェクトの数を表示するテキスト")]
- private Text m_UITextDeployObjectNum;
- [SerializeField]
- [Tooltip("配置中オブジェクトのボタンを並べている親オブジェクト")]
- private uGUIListViewer m_UIParentDeploymentObjectButtons;
- [SerializeField]
- [Tooltip("すべての配置中オブジェクトの表示/非表示を切り替えるトグル")]
- private Toggle m_UIToggleVisibleDeployObject;
- private GameObject m_SelectingObject;
- private CreativeRoomUIObjectSettings.GizmoObject m_GizmoControlObject;
- private Dictionary<GameObject, CreativeRoomUIObjectSettings.DeployObjectInstanceData> m_DeploymentObjectInstanceArray = new Dictionary<GameObject, CreativeRoomUIObjectSettings.DeployObjectInstanceData>();
- private Dictionary<string, string> m_Clipboard = new Dictionary<string, string>();
- private Dictionary<int, Texture> m_CachedItemIconDic = new Dictionary<int, Texture>();
- private CreativeRoomUIObjectSettings.TYPE_GIZMO_CONTROL m_TypeGizmoControl;
- private CreativeRoomUIObjectSettings.TYPE_OBJECT_CONTROL m_TypeObjectControl;
- private float m_SnapValuePosition = 0.5f;
- private float m_SnapValueRotation = 15f;
- private float m_SnapValueScale = 0.1f;
- private bool m_IsVisibleDeployObject;
- private enum TYPE_GIZMO_CONTROL
- {
- Move,
- Rotate,
- None
- }
- private enum TYPE_OBJECT_CONTROL
- {
- Default,
- Snap
- }
- private class DeployObjectInstanceData
- {
- public DeployObjectInstanceData(CreativeRoomUIObjectSettings.TYPE_OBJECT_CONTROL type_, int objectID_, GameObject uiButtonObject_)
- {
- this.type = type_;
- this.objectID = objectID_;
- this.uiButtonObject = uiButtonObject_;
- this.active = true;
- }
- public CreativeRoomUIObjectSettings.TYPE_OBJECT_CONTROL type;
- public int objectID;
- public GameObject uiButtonObject;
- public bool active;
- }
- private class MouseEvent : MonoBehaviour, IPointerClickHandler, IBeginDragHandler, IEndDragHandler, IEventSystemHandler
- {
- public void OnPointerClick(PointerEventData data)
- {
- if (this.onPointerClick != null)
- {
- this.onPointerClick(data);
- }
- }
- public void OnBeginDrag(PointerEventData data)
- {
- if (this.onBeginDrag != null)
- {
- this.onBeginDrag(data);
- }
- }
- public void OnEndDrag(PointerEventData data)
- {
- if (this.onEndDrag != null)
- {
- this.onEndDrag(data);
- }
- }
- public Action<PointerEventData> onPointerClick;
- public Action<PointerEventData> onBeginDrag;
- public Action<PointerEventData> onEndDrag;
- }
- private class GizmoObject : MonoBehaviour
- {
- public GizmoRender gizmoRot { get; private set; }
- public WorldTransformAxis gizmoAxis { get; private set; }
- public Vector3 pos
- {
- get
- {
- return base.transform.position;
- }
- set
- {
- base.transform.position = value;
- }
- }
- public Vector3 eulerAngles
- {
- get
- {
- return this.gizmoRot.transform.eulerAngles;
- }
- set
- {
- this.gizmoRot.transform.eulerAngles = value;
- }
- }
- public Vector3 scale
- {
- get
- {
- return this.gizmoRot.transform.localScale;
- }
- set
- {
- this.gizmoRot.transform.localScale = value;
- }
- }
- public Quaternion rot
- {
- get
- {
- return this.gizmoRot.transform.rotation;
- }
- set
- {
- this.gizmoRot.transform.rotation = value;
- }
- }
- public bool activeAxis
- {
- get
- {
- return this.gizmoAxis.gameObject.activeInHierarchy;
- }
- set
- {
- this.gizmoAxis.gameObject.SetActive(value);
- }
- }
- public bool activeRot
- {
- get
- {
- return this.gizmoRot.gameObject.activeInHierarchy;
- }
- set
- {
- this.gizmoRot.gameObject.SetActive(value);
- }
- }
- public void Initialize(GizmoRender gizmoRot, WorldTransformAxis gizmoAxis)
- {
- this.gizmoRot = gizmoRot;
- this.gizmoAxis = gizmoAxis;
- this.gizmoRot.transform.SetParent(base.gameObject.transform);
- this.gizmoAxis.transform.SetParent(base.gameObject.transform);
- }
- private void OnDestroy()
- {
- if (this.gizmoRot != null && this.gizmoRot.lineMaterial != null)
- {
- UnityEngine.Object.Destroy(this.gizmoRot.lineMaterial);
- }
- }
- }
- }
- }
|