private void OnCreatePolyshape() { GameObject go; ExposeToEditor exposeToEditor; CreateShape(PBShapeType.Cube, out go, out exposeToEditor); exposeToEditor.SetName("Poly Shape"); IRTE rte = IOC.Resolve <IRTE>(); RuntimeWindow scene = rte.GetWindow(RuntimeWindowType.Scene); Vector3 position; Quaternion rotation; GetPositionAndRotation(scene, out position, out rotation); go.transform.position = position; go.transform.rotation = rotation; PBMesh pbMesh = go.GetComponent <PBMesh>(); pbMesh.Clear(); PBPolyShape polyShape = go.AddComponent <PBPolyShape>(); polyShape.IsEditing = true; rte.Selection.activeGameObject = go; IProBuilderTool tool = IOC.Resolve <IProBuilderTool>(); tool.Mode = ProBuilderToolMode.PolyShape; }
private void Start() { m_window = GetComponent <T>(); m_editor = m_window.Editor; m_wm = IOC.Resolve <IWindowManager>(); StartOverride(); }
private void GetMinPoint(ref float minDistance, ref Vector3 minPoint, ref bool minPointFound, Transform tr) { IRTE editor = Editor; for (int j = 0; j < m_boundingBoxCorners.Length; ++j) { Vector3 worldPoint = tr.TransformPoint(m_boundingBoxCorners[j]); Vector2 screenPoint; if (Window.Pointer.WorldToScreenPoint(Position, worldPoint, out screenPoint)) { Vector2 mousePoint; if (Window.Pointer.XY(Position, out mousePoint)) { float distance = (screenPoint - mousePoint).magnitude; if (distance < minDistance) { minPointFound = true; minDistance = distance; minPoint = worldPoint; } } } } }
private void Awake() { m_editor = IOC.Resolve <IRTE>(); if (Window == null) { Window = m_editor.GetWindow(RuntimeWindowType.SceneView); if (Window == null) { Debug.LogError("m_window == null"); enabled = false; return; } } m_awaked = true; AwakeOverride(); if (IsWindowActive) { OnWindowActivated(); } m_editor.ActiveWindowChanged += OnActiveWindowChanged; }
private void Awake() { m_editor = IOC.Resolve <IRTE>(); if (Window == null) { Window = GetDefaultWindow(); if (Window == null) { Debug.LogError("m_window == null"); enabled = false; return; } } AwakeOverride(); m_awaked = true; if (IsWindowActive) { OnWindowActivating(); OnWindowActivated(); } m_editor.ActiveWindowChanging += OnActiveWindowChanging; m_editor.ActiveWindowChanged += OnActiveWindowChanged; }
protected virtual IEnumerator Start() { m_editor = IOC.Resolve <IRTE>(); m_view = GetComponent <MaterialPaletteView>(); m_proBuilderTool = IOC.Resolve <IProBuilderTool>(); m_paletteManager = IOC.Resolve <IMaterialPaletteManager>(); m_paletteManager.PaletteChanged += OnPaletteChanged; m_paletteManager.MaterialAdded += OnMaterialAdded; m_paletteManager.MaterialCreated += OnMaterialCreated; m_paletteManager.MaterialRemoved += OnMaterialRemoved; yield return(new WaitUntil(() => m_paletteManager.IsReady)); yield return(new WaitWhile(() => m_editor.IsBusy)); m_view.TreeView.ItemDataBinding += OnItemDataBinding; m_view.TreeView.ItemDrop += OnItemDrop; m_view.TreeView.SelectionChanged += OnSelectionChanged; if (m_view.CreateMaterialButton != null) { m_view.CreateMaterialButton.onClick.AddListener(CreateMaterial); } m_view.TreeView.Items = m_paletteManager.Palette.Materials; m_view.TreeView.CanEdit = false; m_view.TreeView.CanReorder = true; m_view.TreeView.CanReparent = false; m_view.TreeView.CanSelectAll = false; m_view.TreeView.CanUnselectAll = true; m_view.TreeView.CanRemove = false; }
public void Apply() { Transform pivotPoint = Editor.m_pivotPoint.transform; pivotPoint.position = PivotPointPosition; pivotPoint.rotation = PivotPointRotation; pivotPoint.localScale = PivotPointScale; for (int i = 0; i < Editor.m_editableMeshes.Count; ++i) { Editor.m_editableMeshes[i].SelectedFaces = null; } for (int i = 0; i < EditableMeshes.Length; ++i) { EditableMeshes[i].SelectedFaces = SelectedFaces[i]; } Editor.m_editableMeshes = EditableMeshes.ToList(); Editor.m_lastFace = LastFace; IRTE rte = IOC.Resolve <IRTE>(); if (rte != null) { rte.Selection.Select(ActiveObject, Selection); } }
protected virtual void Start() { if (m_editor == null) { m_editor = m_gizmo.Editor; } }
private void Awake() { m_editor = IOC.Resolve <IRTE>(); m_localization = IOC.Resolve <ILocalization>(); #pragma warning disable CS0612 if (m_componentsRoot == null) { m_componentsRoot = transform; } if (m_activeWorkspace == null) { if (m_dockPanels != null) { if (m_dialogManager == null) { m_dialogManager = FindObjectOfType <DialogManager>(); } InitActiveWorkspace_Internal(); } else { Debug.LogError("m_activeWorkspace is null"); return; } } }
private void Awake() { m_tool = IOC.Resolve <IProBuilderTool>(); m_editor = IOC.Resolve <IRuntimeEditor>(); m_editor.Undo.UndoCompleted += OnUpdateVisualState; m_editor.Undo.RedoCompleted += OnUpdateVisualState; m_editor.Undo.StateChanged += OnUpdateVisualState; if (m_useGizmosToggle != null) { m_useGizmosToggle.onValueChanged.AddListener(OnUseGizmosValueChanged); } if (m_fillModeEditor != null) { m_fillModeEditor.Init(m_tool.UV, m_tool.UV, Strong.PropertyInfo((PBAutoUnwrapSettings x) => x.fill), null, "Fill"); } if (m_anchorEditor != null) { m_anchorEditor.Init(m_tool.UV, m_tool.UV, Strong.PropertyInfo((PBAutoUnwrapSettings x) => x.anchor), null, "Anchor"); } if (m_offsetEditor != null) { m_offsetEditor.Init(m_tool.UV, m_tool.UV, Strong.PropertyInfo((PBAutoUnwrapSettings x) => x.offset), null, "Offset"); } if (m_rotationEditor != null) { m_rotationEditor.Min = 0; m_rotationEditor.Max = 360; m_rotationEditor.Init(m_tool.UV, m_tool.UV, Strong.PropertyInfo((PBAutoUnwrapSettings x) => x.rotation), null, "Rotation"); } if (m_tilingEditor != null) { m_tilingEditor.Init(m_tool.UV, m_tool.UV, Strong.PropertyInfo((PBAutoUnwrapSettings x) => x.scale), null, "Tiling"); } if (m_worldSpaceEditor != null) { m_worldSpaceEditor.Init(m_tool.UV, m_tool.UV, Strong.PropertyInfo((PBAutoUnwrapSettings x) => x.useWorldSpace), null, "World Space"); } if (m_flipUEditor != null) { m_flipUEditor.Init(m_tool.UV, m_tool.UV, Strong.PropertyInfo((PBAutoUnwrapSettings x) => x.flipU), null, "Flip U"); } if (m_flipVEditor != null) { m_flipVEditor.Init(m_tool.UV, m_tool.UV, Strong.PropertyInfo((PBAutoUnwrapSettings x) => x.flipV), null, "Flip V"); } if (m_swapUVEditor != null) { m_swapUVEditor.Init(m_tool.UV, m_tool.UV, Strong.PropertyInfo((PBAutoUnwrapSettings x) => x.swapUV), null, "Swap UV"); } }
protected override void OnEditorExist() { base.OnEditorExist(); m_rte = IOC.Resolve <IRTE>(); m_rte.ObjectsDuplicated += OnObjectsDuplicated; }
protected override void OnEditorExist() { base.OnEditorExist(); m_editor = IOC.Resolve <IRTE>(); m_editor.ActiveWindowChanged += OnActiveWindowChanged; OnActiveWindowChanged(m_editor.ActiveWindow); }
private void Awake() { m_editor = IOC.Resolve <IRTE>(); m_editor.IsOpenedChanged += OnIsOpenedChanged; m_exposeToEditor = GetComponent <ExposeToEditor>(); RuntimeHandlesComponent.InitializeIfRequired(ref Appearance); }
private void Start() { m_parentDialog = GetComponentInParent <Dialog>(); if (m_parentDialog != null) { m_parentDialog.IsOkVisible = true; m_parentDialog.OkText = m_localization.GetString("ID_RTEditor_AssetLibSelectDialog_Select", "Select"); m_parentDialog.IsCancelVisible = true; m_parentDialog.CancelText = m_localization.GetString("ID_RTEditor_AssetLibSelectDialog_Cancel", "Cancel"); m_parentDialog.Ok += OnOk; } if (m_builtInTreeView == null) { Debug.LogError("m_builtInTreeView == null"); return; } if (m_externalTreeView == null) { Debug.LogError("m_externalTreeView == null"); return; } m_windowManager = IOC.Resolve <IWindowManager>(); m_builtInTreeView.ItemDataBinding += OnItemDataBinding; m_builtInTreeView.ItemDoubleClick += OnItemDoubleClick; m_builtInTreeView.CanDrag = false; m_builtInTreeView.CanEdit = false; m_builtInTreeView.CanUnselectAll = false; m_externalTreeView.ItemDataBinding += OnItemDataBinding; m_externalTreeView.ItemDoubleClick += OnItemDoubleClick; m_externalTreeView.CanDrag = false; m_externalTreeView.CanEdit = false; m_externalTreeView.CanUnselectAll = false; m_externalTreeView.transform.parent.parent.gameObject.SetActive(false); m_builtInTreeView.transform.parent.parent.gameObject.SetActive(true); m_project = IOC.Resolve <IProject>(); m_builtInTreeView.Items = m_project.GetStaticAssetLibraries().Values.Distinct().ToArray(); m_builtInTreeView.SelectedIndex = 0; IRTE editor = IOC.Resolve <IRTE>(); editor.IsBusy = true; m_project.GetAssetBundles((error, assetBundles) => { editor.IsBusy = false; if (error.HasError) { m_windowManager.MessageBox(m_localization.GetString("ID_RTEditor_AssetLibSelectDialog_UnableToListBundles", "Unable to list asset bundles"), error.ToString()); return; } m_externalTreeView.Items = assetBundles; m_externalTreeView.SelectedIndex = 0; }); }
private void Start() { m_outlineEffect = Camera.gameObject.AddComponent <OutlineEffect>(); m_editor = IOC.Resolve <IRTE>(); TryToAddRenderers(m_editor.Selection); m_editor.Selection.SelectionChanged += OnRuntimeEditorSelectionChanged; RTEComponent rteComponent = GetComponentInParent <RTEComponent>(); if (rteComponent != null) { m_sceneWindow = rteComponent.Window; if (m_sceneWindow != null) { m_sceneWindow.IOCContainer.RegisterFallback <IOutlineManager>(this); } } if (RenderPipelineInfo.Type != RPType.Standard) { Debug.Log("OutlineManager is not supported"); Destroy(this); } }
private void Awake() { m_editor = IOC.Resolve <IRTE>(); List <RTECursor> cursorSettings; if (m_cursorSettings == null) { cursorSettings = new List <RTECursor>(); } else { cursorSettings = m_cursorSettings.ToList(); } AddCursorIfRequired(cursorSettings, KnownCursor.DropAllowed, "Drag & Drop Allowed", "RTE_DropAllowed_Cursor"); AddCursorIfRequired(cursorSettings, KnownCursor.DropNowAllowed, "Drag & Drop Not Allowed", "RTE_DropNotAllowed_Cursor"); AddCursorIfRequired(cursorSettings, KnownCursor.HResize, "Horizontal Resize", "RTE_HResize_Cursor"); AddCursorIfRequired(cursorSettings, KnownCursor.VResize, "Vertical Resize", "RTE_VResize_Cursor"); m_cursorSettings = cursorSettings.ToArray(); m_editor.IsOpenedChanged += OnIsOpenedChanged; if (m_editor.IsOpened) { ApplyCursorSettings(); ApplyColors(); } }
protected virtual void Start() { if (m_editor == null) { m_editor = m_handle.Editor; } }
private void EndRecordLayerProperties() { IRTE editor = IOC.Resolve <IRTE>(); Terrain terrain = Terrain; int layerIndex = m_layersList.SelectedIndex; Vector2 tileSize = SelectedLayer.tileSize; Vector2 tileOffset = SelectedLayer.tileOffset; editor.Undo.CreateRecord(record => { TerrainLayer layer = terrain.terrainData.terrainLayers[layerIndex]; if (layer != null) { layer.tileOffset = tileOffset; layer.tileSize = tileSize; } return(true); }, record => { TerrainLayer layer = terrain.terrainData.terrainLayers[layerIndex]; if (layer != null) { layer.tileOffset = m_initialTileOffset; layer.tileSize = m_initialTileSize; } return(true); }); }
private void OnFlatten() { Terrain terrain = TerrainEditor.Terrain; float[,] oldHeightmap = GetHeightmap(); float[,] newHeightmap = GetHeightmap(); int w = newHeightmap.GetLength(0); int h = newHeightmap.GetLength(1); float heightmapScale = terrain.terrainData.heightmapScale.y; for (int i = 0; i < w; ++i) { for (int j = 0; j < w; ++j) { newHeightmap[i, j] = Height / heightmapScale; } } terrain.terrainData.SetHeights(0, 0, newHeightmap); IRTE editor = IOC.Resolve <IRTE>(); editor.Undo.CreateRecord(record => { terrain.terrainData.SetHeights(0, 0, newHeightmap); return(true); }, record => { terrain.terrainData.SetHeights(0, 0, oldHeightmap); return(true); }); }
private void RecordState(float[,,] oldAlphamap, TerrainLayer[] oldLayers) { Terrain terrain = Terrain; float[,,] newAlphamap = GetAlphamaps(); TerrainLayer[] newLayers = terrain.terrainData.terrainLayers.ToArray(); IRTE editor = IOC.Resolve <IRTE>(); editor.Undo.CreateRecord(record => { if (terrain.terrainData != null) { terrain.terrainData.terrainLayers = newLayers; terrain.terrainData.SetAlphamaps(0, 0, newAlphamap); UpdateLayersList(terrain); } return(true); }, record => { if (terrain.terrainData != null) { terrain.terrainData.terrainLayers = oldLayers; terrain.terrainData.SetAlphamaps(0, 0, oldAlphamap); UpdateLayersList(terrain); } return(true); }); }
private void Awake() { m_editor = IOC.Resolve <IRTE>(); m_layersInfo = (LayersInfo)m_editor.Selection.activeObject; foreach (LayersInfo.Layer layer in m_layersInfo.Layers) { GameObject editor = Instantiate(m_editorPrefab, m_editorsPanel, false); TextMeshProUGUI text = editor.GetComponentInChildren <TextMeshProUGUI>(true); if (text != null) { text.text = layer.Index + ": "; } StringEditor stringEditor = editor.GetComponentInChildren <StringEditor>(true); if (stringEditor != null) { if (layer.Index <= 5) { TMP_InputField inputField = stringEditor.GetComponentInChildren <TMP_InputField>(true); inputField.selectionColor = new Color(0, 0, 0, 0); inputField.readOnly = true; } stringEditor.Init(layer, layer, Strong.MemberInfo((LayersInfo.Layer x) => x.Name), null, string.Empty, null, () => m_isDirty = true, null, false); } } }
protected override TerrainAreaHandle CreateHandle(SceneView scene) { TerrainAreaHandle exisitingHandle = GetComponentInChildren <TerrainAreaHandle>(); TerrainAreaHandle handle = base.CreateHandle(scene); IRTE rte = IOC.Resolve <IRTE>(); if (rte.Selection.gameObjects != null) { handle.Targets = rte.Selection.gameObjects.Select(go => go.transform).ToArray(); } if (exisitingHandle != null) { handle.Position = exisitingHandle.Position; } IRenderPipelineCameraUtility cameraUtility = IOC.Resolve <IRenderPipelineCameraUtility>(); if (cameraUtility != null) { cameraUtility.RequiresDepthTexture(scene.Camera, true); } return(handle); }
protected virtual void Start() { if (m_prefab == null) { Debug.LogWarning("m_prefab is not set"); return; } m_editor = IOC.Resolve <IRTE>(); m_scene = m_editor.GetWindow(RuntimeWindowType.Scene); IResourcePreviewUtility resourcePreview = IOC.Resolve <IResourcePreviewUtility>(); m_texture = resourcePreview.TakeSnapshot(m_prefab); if (m_preview != null) { m_preview.sprite = Sprite.Create(m_texture, new Rect(0, 0, m_texture.width, m_texture.height), new Vector2(0.5f, 0.5f)); m_preview.color = Color.white; } if (m_prefabName != null) { m_prefabName.text = m_prefab.name; } }
protected virtual void Awake() { m_rte = IOC.Resolve <IRTE>(); if (m_objectToggle != null) { m_objectToggle.onValueChanged.AddListener(OnObject); } if (m_vetexToggle != null) { m_vetexToggle.onValueChanged.AddListener(OnVertex); } if (m_edgeToggle != null) { m_edgeToggle.onValueChanged.AddListener(OnEdge); } if (m_faceToggle != null) { m_faceToggle.onValueChanged.AddListener(OnFace); } if (m_pivotModeToggle != null) { m_pivotModeToggle.onValueChanged.AddListener(OnPivotMode); } if (m_pivotRotationToggle != null) { m_pivotRotationToggle.onValueChanged.AddListener(OnPivotRotation); } m_rte.Tools.PivotRotationChanged += OnPivotRotationChanged; m_rte.Tools.PivotModeChanged += OnPivotModeChanged; }
private IEnumerator CoImport(IFileImporter importer, string path) { IRTE rte = IOC.Resolve <IRTE>(); rte.IsBusy = true; IProjectTree projectTree = IOC.Resolve <IProjectTree>(); string targetPath = Path.GetFileNameWithoutExtension(path); if (projectTree != null && projectTree.SelectedItem != null) { ProjectItem folder = projectTree.SelectedItem; targetPath = folder.RelativePath(false) + "/" + targetPath; targetPath = targetPath.TrimStart('/'); IProject project = IOC.Resolve <IProject>(); targetPath = project.GetUniquePath(targetPath, typeof(Texture2D), folder); } yield return(StartCoroutine(importer.Import(path, targetPath))); rte.IsBusy = false; m_parentDialog.Close(); rte.ActivateWindow(RuntimeWindowType.Scene); }
protected override void OnEditorExist() { base.OnEditorExist(); m_editor = IOC.Resolve <IRTE>(); m_compiler = new Complier(); IOC.RegisterFallback(m_compiler); if (m_scriptManager == null) { m_scriptManager = gameObject.AddComponent <RuntimeScriptsManager>(); } Subscribe(); IRTEAppearance appearance = IOC.Resolve <IRTEAppearance>(); List <AssetIcon> icons = appearance.AssetIcons.ToList(); icons.Add(new AssetIcon { AssetTypeName = typeof(RuntimeTextAsset).FullName + Ext, Icon = Resources.Load <Sprite>("RTE_Script") }); appearance.AssetIcons = icons.ToArray(); Register(); }
private void GetMinPoint(Transform meshTransform, ref float minDistance, ref Vector3 minPoint, ref bool minPointFound, Mesh mesh) { if (mesh != null && mesh.isReadable) { IRTE editor = Editor; Vector3[] vertices = mesh.vertices; for (int i = 0; i < vertices.Length; ++i) { Vector3 vert = vertices[i]; vert = meshTransform.TransformPoint(vert); Vector2 screenPoint; if (Window.Pointer.WorldToScreenPoint(Position, vert, out screenPoint)) { Vector2 mousePoint; if (Window.Pointer.XY(Position, out mousePoint)) { float distance = (screenPoint - mousePoint).magnitude; if (distance < minDistance) { minPointFound = true; minDistance = distance; minPoint = vert; } } } } } }
private IEnumerator CoImport(IFileImporter importer, string path) { IRTE rte = IOC.Resolve <IRTE>(); rte.IsBusy = true; IProjectTree projectTree = IOC.Resolve <IProjectTree>(); string targetPath = Path.GetFileNameWithoutExtension(path); if (projectTree != null && projectTree.SelectedFolder != null) { ProjectItem folder = projectTree.SelectedFolder; targetPath = folder.RelativePath(false) + "/" + targetPath; targetPath = targetPath.TrimStart('/'); IProject project = IOC.Resolve <IProject>(); targetPath = project.GetUniquePath(targetPath, typeof(Texture2D), folder); } yield return(importer.Import(path, targetPath)); rte.IsBusy = false; }
public static void CreateTerrain() { IRTE editor = IOC.Resolve <IRTE>(); TerrainData terrainData = new TerrainData(); terrainData.SetDetailResolution(1024, 32); terrainData.heightmapResolution = 513; terrainData.size = new Vector3(200, 20, 200); terrainData.terrainLayers = new[] { #if UNITY_2019_2 //2019.2.12 unity terrain issue fix (2 same layers to make texture visibile) new TerrainLayer() { diffuseTexture = (Texture2D)Resources.Load("Textures/RTT_DefaultGrass") }, #endif new TerrainLayer() { diffuseTexture = (Texture2D)Resources.Load("Textures/RTT_DefaultGrass") } }; GameObject go = Terrain.CreateTerrainGameObject(terrainData); go.isStatic = false; if (go != null) { editor.AddGameObjectToScene(go); } }
public static IEnumerable <GameObject> FindAll(IRTE editor, ExposeToEditorObjectType type, bool roots = true) { if (SceneManager.GetActiveScene().isLoaded) { return(FindAllUsingSceneManagement(editor, type, roots)); } List <GameObject> filtered = new List <GameObject>(); GameObject[] objects = Resources.FindObjectsOfTypeAll <GameObject>(); for (int i = 0; i < objects.Length; ++i) { GameObject obj = objects[i] as GameObject; if (obj == null) { continue; } if (!obj.IsPrefab()) { filtered.Add(obj); } } return(filtered.Where(f => IsExposedToEditor(editor, f, type, roots))); }