// Update is called once per frame void Update() { if (VCEditor.DocumentOpen()) { SetVoxelSize(VCEditor.s_Scene.m_Setting.m_VoxelSize); } }
// Update is called once per frame void Update() { if (VCEditor.DocumentOpen()) { int index = VCEditor.s_Scene.m_IsoData.QueryMaterialIndex(m_Material); if (index >= 0 && VCEditor.s_Scene.m_IsoData.m_Materials[index] == m_Material) { m_IndexLabel.text = "No." + (index + 1).ToString(); m_IndexLabel.color = Color.white; } else if (VCEditor.SelectedMaterial == m_Material) { if (VCEditor.SelectedVoxelType < 0) { m_IndexLabel.text = "ISO FULL"; m_IndexLabel.color = Color.red; } else { m_IndexLabel.text = "No." + (VCEditor.SelectedVoxelType + 1).ToString(); m_IndexLabel.color = Color.white; } } else { m_IndexLabel.text = ""; m_IndexLabel.color = Color.white; } bool tempmat = VCEAssetMgr.s_TempMaterials.ContainsKey(m_Material.m_Guid); bool existmat = VCEAssetMgr.s_Materials.ContainsKey(m_Material.m_Guid); m_AddBtn.SetActive(tempmat && !existmat); m_DelBtn.SetActive(!tempmat && existmat && index < 0 && VCEditor.SelectedMaterial == m_Material); } }
void CheckAddCheatItem(string msg) { if (null == MainPlayer.Instance.entity) { return; } CheatData data = CheatData.GetData(msg); if (null != data) { if (1 == data.addType) { if (MainPlayer.Instance.entity.packageCmpt.Add(data.itemID, 1) && "0" != data.successNotice) { PeTipMsg.Register(data.successNotice, PeTipMsg.EMsgLevel.HighLightRed); } } else if (2 == data.addType) { if (0 == VCEditor.MakeCreation("Isos/Mission/" + data.isoName) && "0" != data.successNotice) { PeTipMsg.Register(data.successNotice, PeTipMsg.EMsgLevel.HighLightRed); } } } }
// Update is called once per frame void Update() { if (VCERefPlane.XRef > 0) { m_XRefTrans.gameObject.SetActive(true); } else { m_XRefTrans.gameObject.SetActive(false); } if (VCERefPlane.YRef > 0) { m_YRefTrans.gameObject.SetActive(true); m_BasePlane.m_ShowGrid = false; } else { m_YRefTrans.gameObject.SetActive(false); m_BasePlane.m_ShowGrid = true; } if (VCERefPlane.ZRef > 0) { m_ZRefTrans.gameObject.SetActive(true); } else { m_ZRefTrans.gameObject.SetActive(false); } float voxelsize = (VCEditor.DocumentOpen()) ? (VCEditor.s_Scene.m_Setting.m_VoxelSize) : (0.01f); m_XRefTrans.localPosition = Vector3.right * (VCERefPlane.XRef * voxelsize); m_YRefTrans.localPosition = Vector3.up * (VCERefPlane.YRef * voxelsize); m_ZRefTrans.localPosition = Vector3.forward * (VCERefPlane.ZRef * voxelsize); }
public static bool RayAdjustHeight(Ray ray, Vector3 basepoint, out float height) { height = basepoint.y; if (!VCEditor.DocumentOpen()) { return(false); } ray = VCEMath.TransformRayToIsoCoord(ray); if (Mathf.Abs(ray.direction.x) < 0.001f && Mathf.Abs(ray.direction.z) < 0.001f) { return(false); } else { Vector3 horz = Vector3.Cross(Vector3.up, ray.direction).normalized; Plane ray_plane = new Plane(ray.origin, ray.GetPoint(10), ray.origin + horz * 10); Ray vert = new Ray(basepoint + Vector3.up * 2000, Vector3.down); float enter = 0; if (ray_plane.Raycast(vert, out enter)) { height = vert.GetPoint(enter).y; return(true); } else { return(false); } } }
public void OnSaveClick() { if (VCEditor.s_ProtectLock0) { return; } VCEditor.ClearSelections(); m_StatPanel.OnCreationInfoRefresh(); if (File.Exists(VCConfig.s_IsoPath + VCEditor.s_Scene.m_DocumentPath)) { if (VCEditor.s_Scene.SaveIso()) { VCEMsgBox.Show(VCEMsgBoxType.SAVE_OK); } else { VCEMsgBox.Show(VCEMsgBoxType.SAVE_FAILED); } if (m_ISOTab.isChecked) { m_IsoList.RefreshIsoList(); } } else { OnSaveAsClick(); } }
public override void Cancel() { if (VCEditor.DocumentOpen()) { VCEditor.Instance.m_UI.m_DefaultBrush_Material.isChecked = true; } }
void PeLauncher.ILaunchable.Launch() { VCEditor.Open(); VCEditor.OnCloseFinally += delegate() { Debug.Log("vceditor closed"); }; }
void OnSelectedMatClick() { if (VCEditor.Instance.m_UI.m_MaterialTab.isChecked && VCEditor.SelectedMaterial != null) { VCEditor.DeselectBrushes(); VCEditor.Instance.m_UI.m_MaterialWindow.ShowWindow(VCEditor.SelectedMaterial); } }
public static void DoCreateSceneFromMsgBox() { if (s_SceneToCreate == null) { s_SceneToCreate = VCConfig.FirstSceneSetting; } VCEditor.NewScene(s_SceneToCreate); }
public void OnItemClick(GameObject sender) { VCEUICreationTypeItem sender_item = sender.GetComponentInParent <VCEUICreationTypeItem>(); int usage = sender_item.usage; VCESceneSetting scene = sender_item.m_Scene; // 树形菜单 if (usage == 0) { parentId = scene.m_Id; m_BackButton.gameObject.SetActive(true); CreateChildItems(); } // 创建新的ISO else if (usage == 1) { parentId = scene.m_Id; m_BackButton.gameObject.SetActive(true); CreateChildItems(); } // 加载旧的ISO else if (usage == 2) { OnCloseClick(gameObject); VCEditor.Instance.m_UI.m_ISOTab.isChecked = true; VCEditor.Instance.m_UI.m_IsoTip.Show(); } // Template else if (usage == 3) { TextAsset asset = Resources.Load <TextAsset>("Isos/" + scene.m_Id.ToString() + "/index"); if (asset == null) { OnCloseClick(gameObject); VCEditor.NewScene(scene); return; } int count = 0; int.TryParse(asset.text, out count); if (count == 0) { OnCloseClick(gameObject); VCEditor.NewScene(scene); return; } int tmpIdx = (int)(Random.value * count - 0.00001f); OnCloseClick(gameObject); VCEditor.NewScene(scene, tmpIdx); } // Empty else if (usage == 4) { OnCloseClick(gameObject); VCEditor.NewScene(scene); } }
public void OnSaveAsClick() { if (VCEditor.s_ProtectLock0) { return; } VCEditor.ClearSelections(); m_StatPanel.OnCreationInfoRefresh(); m_SaveWindow.Show(VCEditor.s_Scene.m_IsoData); }
// Simulate VCE void OnGUI() { if (!VCEditor.s_Active) { if (GUI.Button(new Rect((Screen.width - 300) * 0.5f, (Screen.height - 70) * 0.5f, 300, 70), "Voxel Creation Editor")) { VCEditor.Open(); } } }
// Update is called once per frame void LateUpdate() { VCDecalAsset decal_asset = VCEAssetMgr.GetDecal(m_Guid); if (decal_asset == null) { if (m_Iso != null && m_Iso.m_DecalAssets != null && m_AssetIndex >= 0 && m_AssetIndex < VCIsoData.DECAL_ARR_CNT) { decal_asset = m_Iso.m_DecalAssets[m_AssetIndex]; } } if (decal_asset == null) { m_Projector.gameObject.SetActive(false); return; } if (VCEditor.DocumentOpen() && m_Tool != null && m_Tool.m_SelBound != null) { m_Tool.m_SelBound.transform.localScale = new Vector3(m_Size, m_Size, m_Depth * 2 - 0.002f); m_Tool.m_SelBound.transform.localPosition = new Vector3(0, 0, 0); } Material usedMaterial = null; if (m_ShaderIndex >= 0 && m_ShaderIndex < m_DecalMats.Length) { usedMaterial = m_DecalMats[m_ShaderIndex]; } m_Projector.gameObject.SetActive(usedMaterial != null); if (usedMaterial != null) { m_Projector.material = usedMaterial; m_Projector.nearClipPlane = 0.001f - m_Depth; m_Projector.farClipPlane = m_Depth - 0.001f; m_Projector.orthographicSize = m_Size * 0.5f; usedMaterial.SetTexture("_Texture", decal_asset.m_Tex); usedMaterial.SetColor("_TintColor", m_Color); usedMaterial.SetFloat("_Size", m_Size * 0.5f); usedMaterial.SetFloat("_Depth", m_Depth); usedMaterial.SetVector("_Center", new Vector4(transform.position.x, transform.position.y, transform.position.z, 1)); usedMaterial.SetVector("_Forward", new Vector4(transform.forward.x, transform.forward.y, transform.forward.z, 0)); if (m_Mirrored) { usedMaterial.SetVector("_Right", -new Vector4(transform.right.x, transform.right.y, transform.right.z, 0)); } else { usedMaterial.SetVector("_Right", new Vector4(transform.right.x, transform.right.y, transform.right.z, 0)); } usedMaterial.SetVector("_Up", new Vector4(transform.up.x, transform.up.y, transform.up.z, 0)); } }
public static VCEComponentTool RayPickComponent(Ray ray, int order = 0) { if (!VCEditor.DocumentOpen()) { return(null); } RaycastHit rch_v; float voxel_dist = 1000000; if (RayCastVoxel(ray, out rch_v, MC_ISO_VALUE)) { voxel_dist = rch_v.distance * VCEditor.s_Scene.m_Setting.m_VoxelSize;; } RaycastHit[] rchs = Physics.RaycastAll(ray, VCEditor.s_Scene.m_Setting.EditorWorldSize.magnitude * 10F, VCConfig.s_EditorLayerMask); RaycastHit temp_rch; // Sort by dist for (int i = 0; i < rchs.Length - 1; ++i) { for (int j = i + 1; j < rchs.Length; ++j) { if (rchs[i].distance > rchs[j].distance) { temp_rch = rchs[i]; rchs[i] = rchs[j]; rchs[j] = temp_rch; } } } List <VCEComponentTool> list_comp = new List <VCEComponentTool> (); foreach (RaycastHit rch in rchs) { if (rch.distance <= voxel_dist) { GLComponentBound glcb = rch.collider.gameObject.GetComponent <GLComponentBound>(); if (glcb != null) { list_comp.Add(glcb.m_ParentComponent); } } } if (list_comp.Count == 0) { return(null); } else { return(list_comp[order % list_comp.Count]); } }
public void OnRedoClick() { if (VCEditor.s_ProtectLock0) { return; } if (VCEHistory.Redo()) { VCEditor.ClearSelections(); VCEditor.SelectedMaterial = VCEditor.SelectedMaterial; VCEStatusBar.ShowText("Redo".ToLocalizationString(), 2); } }
void ToggleComponentColliders(bool _enabled) { if (!VCEditor.DocumentOpen()) { return; } foreach (VCComponentData cd in VCEditor.s_Scene.m_IsoData.m_Components) { VCEComponentTool c = cd.m_Entity.GetComponent <VCEComponentTool>(); c.m_SelBound.enabled = _enabled; c.m_SelBound.GetComponent <Collider>().enabled = _enabled; } }
void Start() { if (VCEditor.DocumentOpen()) { m_SelectionMgr = VCEditor.Instance.m_VoxelSelection; CreateMainInspector(); VCEditor.Instance.m_NearVoxelIndicator.enabled = true; } else { GameObject.Destroy(this.gameObject); } }
public void OnEffectTab(bool isChecked) { if (isChecked) { VCEditor.Instance.m_VoxelSelection.ClearSelection(); VCEditor.Instance.m_NearVoxelIndicator.enabled = false; VCEStatusBar.ShowText("Add effects".ToLocalizationString(), 5, true); } else { VCEditor.DeselectBrushes(); DestroyBrushInst(ref m_SelectComponentBrushInst); } }
public void OnMaterialTab(bool isChecked) { if (isChecked) { VCEditor.Instance.m_NearVoxelIndicator.enabled = true; //VCEStatusBar.ShowTextLowPriority("Draw voxel blocks", 5, true); } else { VCEditor.DeselectBrushes(); VCEditor.SelectedMaterial = null; m_MaterialWindow.HideWindow(); } }
public void OnExportClick() { // Make Creation int r = VCEditor.MakeCreation(); if (r == -4) // Inventory is full { return; } if (!VCEditor.s_MultiplayerMode) { VCEMsgBox.Show((r == 0) ? VCEMsgBoxType.EXPORT_OK : VCEMsgBoxType.EXPORT_FAILED); } }
public void OnQuitClick() { if (VCEditor.s_ProtectLock0) { return; } if (VCEHistory.s_Modified) { VCEMsgBox.Show(VCEMsgBoxType.CLOSE_QUERY); } else { VCEditor.Quit(); } }
public void OnExportClick() { if (VCEditor.s_ProtectLock0) { return; } VCEditor.ClearSelections(); m_StatPanel.OnCreationInfoRefresh(); if (!File.Exists(VCConfig.s_IsoPath + VCEditor.s_Scene.m_DocumentPath)) { VCEMsgBox.Show(VCEMsgBoxType.EXPORT_NOTSAVED); return; } m_ExportWindow.Show(); }
// Update is called once per frame void Update() { if (!VCEditor.DocumentOpen()) { return; } int MaxHeight = VCEditor.s_Scene.m_Setting.m_EditorSize.y; m_Slider.numberOfSteps = MaxHeight + 1; int yValue = Mathf.RoundToInt(m_Slider.sliderValue * MaxHeight); m_Label.text = "Y = " + yValue.ToString(); VCERefPlane.YRef = yValue; }
public void OnDecalTab(bool isChecked) { if (isChecked) { VCEditor.Instance.m_VoxelSelection.ClearSelection(); VCEditor.Instance.m_NearVoxelIndicator.enabled = false; VCEStatusBar.ShowText("Add decals".ToLocalizationString(), 5, true); } else { VCEditor.DeselectBrushes(); VCEditor.SelectedDecal = null; DestroyBrushInst(ref m_SelectComponentBrushInst); DestroyBrushInst(ref m_DrawDecalBrushInst); m_DecalWindow.HideWindow(); } }
public void OnPaintTab(bool isChecked) { if (isChecked) { VCEditor.Instance.m_NearVoxelIndicator.enabled = true; VCEditor.Instance.m_GLGroup.SetActive(false); VCEStatusBar.ShowText("Paint voxel blocks".ToLocalizationString(), 5, true); } else { VCEditor.DeselectBrushes(); if (VCEditor.s_Ready) { VCEditor.Instance.m_GLGroup.SetActive(true); } } }
public void OnBtnClick() { if (m_SceneSetting.m_Category == EVCCategory.cgAbstract) { return; } UICamera.selectedObject = null; notExpandTime = 0; if (VCEHistory.s_Modified) { s_SceneToCreate = m_SceneSetting; VCEMsgBox.Show(VCEMsgBoxType.SWITCH_QUERY); } else { VCEditor.NewScene(m_SceneSetting); } }
void Start() { if (VCEditor.DocumentOpen()) { m_Selection = new List <SelectInfo> (); CreateMainInspector(); } else { GameObject.Destroy(this.gameObject); } // Gizmos events m_MovingGizmo.OnDragBegin = OnGizmoBegin; m_MovingGizmo.OnDrop = OnGizmoEnd; m_MovingGizmo.OnMoving = OnMoving; m_RotatingGizmo.OnDragBegin = OnGizmoBegin; m_RotatingGizmo.OnDrop = OnGizmoEnd; m_RotatingGizmo.OnRotating = OnRotating; }
void OnGUI() { if (!VCEditor.DocumentOpen()) { return; } GUI.skin = m_GUISkin; if (m_alpha_pos_x > m_alpha_threshold && xShow) { GUI.Label(new Rect(xpoint.x - 10, Screen.height - xpoint.y - 15, 20, 20), "x", "AxisText"); } if (m_alpha_pos_y > m_alpha_threshold && yShow) { GUI.Label(new Rect(ypoint.x - 10, Screen.height - ypoint.y - 15, 20, 20), "y", "AxisText"); } if (m_alpha_pos_z > m_alpha_threshold && zShow) { GUI.Label(new Rect(zpoint.x - 10, Screen.height - zpoint.y - 15, 20, 20), "z", "AxisText"); } }
// cast grid planes public static bool RayCastGrid(Ray ray, out RaycastHit rch) { rch = new RaycastHit(); if (!VCEditor.DocumentOpen()) { return(false); } if (Physics.Raycast(ray, out rch, VCEditor.s_Scene.m_Setting.EditorWorldSize.magnitude * 5F, VCConfig.s_EditorLayerMask)) { if (rch.collider.gameObject.GetComponent <GLGridPlane>() != null) { rch.point = rch.point / VCEditor.s_Scene.m_Setting.m_VoxelSize; rch.distance = rch.distance / VCEditor.s_Scene.m_Setting.m_VoxelSize; return(true); } else { rch = new RaycastHit(); return(false); } } return(false); }