public override void DrawLowerPropertyBox() { if (selected && !SF_GUI.MultiSelectModifierHeld()) { ColorPickerCorner(lowerRect); } //Color vecPrev = texture.dataUniform; Rect tRect = lowerRect; UndoableEnterableFloatField(tRect, ref texture.dataUniform.x, "R channel", null); tRect.x += tRect.width; UndoableEnterableFloatField(tRect, ref texture.dataUniform.y, "G channel", null); tRect.x += tRect.width; UndoableEnterableFloatField(tRect, ref texture.dataUniform.z, "B channel", null); }
public override void DrawLowerPropertyBox() { if (selected && !SF_GUI.MultiSelectModifierHeld()) { ColorPickerCorner(lowerRect); } Vector4 cPrev = texture.dataUniform; Rect tRect = lowerRect; //SF_GUI.EnterableFloatField( this, tRect, ref texture.dataUniform.r, null ); UndoableEnterableFloatField(tRect, ref texture.dataUniform.x, "R channel", null); tRect.x += tRect.width; //SF_GUI.EnterableFloatField( this, tRect, ref texture.dataUniform.g, null ); UndoableEnterableFloatField(tRect, ref texture.dataUniform.y, "G channel", null); if (texture.dataUniform != cPrev) { OnUpdateNode(); } }
public override void DrawLowerPropertyBox() { if (selected && !SF_GUI.MultiSelectModifierHeld() && !IsGlobalProperty()) { ColorPickerCorner(lowerRect); } Vector4 vecPrev = texture.dataUniform; PrepareWindowColor(); Rect tRect = lowerRect; if (IsGlobalProperty()) { texture.dataUniform[0] = texture.dataUniform[1] = texture.dataUniform[2] = 0.5f; texture.dataUniform[3] = 1f; GUI.enabled = false; } texture.dataUniform[0] = UndoableFloatField(tRect, texture.dataUniform[0], "R channel"); tRect.x += tRect.width; texture.dataUniform[1] = UndoableFloatField(tRect, texture.dataUniform[1], "G channel"); tRect.x += tRect.width; texture.dataUniform[2] = UndoableFloatField(tRect, texture.dataUniform[2], "B channel"); tRect.x += tRect.width; texture.dataUniform[3] = UndoableFloatField(tRect, texture.dataUniform[3], "A channel"); ResetWindowColor(); if (texture.dataUniform != vecPrev) { OnUpdateValue(); OnUpdateNode(); } if (IsGlobalProperty()) { GUI.enabled = true; } }
public override void DrawLowerPropertyBox() { Vector4 vecPrev = texture.dataUniform; if (!IsGlobalProperty() && selected && !SF_GUI.MultiSelectModifierHeld()) { ColorPickerCorner(lowerRect); } PrepareWindowColor(); if (IsGlobalProperty()) { texture.dataUniform[0] = texture.dataUniform[1] = texture.dataUniform[2] = 0.5f; texture.dataUniform[3] = 1f; GUI.enabled = false; } Rect tRect = lowerRect; texture.dataUniform[0] = UndoableFloatField(tRect, texture.dataUniform[0], "R channel"); tRect.x += tRect.width; texture.dataUniform[1] = UndoableFloatField(tRect, texture.dataUniform[1], "G channel"); tRect.x += tRect.width; texture.dataUniform[2] = UndoableFloatField(tRect, texture.dataUniform[2], "B channel"); tRect.x += tRect.width; texture.dataUniform[3] = UndoableFloatField(tRect, texture.dataUniform[3], "A channel"); if (IsGlobalProperty()) { GUI.enabled = true; } ResetWindowColor(); if (texture.dataUniform != vecPrev) { OnUpdateNode(NodeUpdateType.Soft); editor.shaderEvaluator.ApplyProperty(this); } }
public void OnLocalGUI(Rect r) { //r = r.PadTop(Mathf.CeilToInt(22*zoom)); editor.mousePosition = Event.current.mousePosition; rect = r; // TOOLBAR //DrawToolbar( new Rect( rect.x, rect.y, rect.width, TOOLBAR_HEIGHT ) ); Rect localRect = new Rect(r); localRect.x = 0; localRect.y = 0; //rect.y += TOOLBAR_HEIGHT; //rect.height -= TOOLBAR_HEIGHT; // VIEW Rect rectInner = new Rect(rect); rectInner.width = float.MaxValue / 2f; rectInner.height = float.MaxValue / 2f; // TEMP: // Rect btn = rectInner; // btn.width = 64; // btn.height = 24; // if(SF_Debug.renderDataNodes){ // if(selection.Selection.Count > 0){ // if(GUI.Button(btn,"NSS")){ // editor.TakeNodePreviewScreenshot(); // } // } // } if (Event.current.type == EventType.Repaint) { nodeSpaceMousePos = ScreenSpaceToZoomSpace(Event.current.mousePosition); } bool mouseOverNode = false; SF_ZoomArea.Begin(zoom, rect, cameraPos); { selection.OnGUI(); // To detect if you press things if (editor.nodeView != null) { editor.nodeView.selection.DrawBoxSelection(); } if (Event.current.type == EventType.Repaint) { viewSpaceMousePos = ZoomSpaceToScreenSpace(Event.current.mousePosition); } // NODES if (editor.nodes != null) { // If we're repainting, draw in reverse to sort properly //if(Event.current.rawType == EventType.repaint){ for (int i = editor.nodes.Count - 1; i >= 0; i--) { if (!editor.nodes[i].Draw()) { break; } } /*} else { * for(int i=0;i<editor.nodes.Count;i++) { * if( !editor.nodes[i].Draw() ) * break; * } * }*/ if (!mouseOverNode) { for (int i = 0; i < editor.nodes.Count; i++) { if (editor.nodes[i].MouseOverNode(world: true)) { mouseOverNode = true; } } } if (Event.current.type == EventType.Repaint) { for (int i = 0; i < editor.nodes.Count; i++) { editor.nodes[i].DrawConnectors(); } } } UpdateCutLine(); UpdateCameraPanning(); } SF_ZoomArea.End(zoom); if (!SF_Node.isEditingAnyNodeTextField) { SF_Editor.instance.UpdateKeyHoldEvents(mouseOverNode); } if (MouseInsideNodeView(false) && Event.current.type == EventType.ScrollWheel) { zoomTarget = ClampZoom(zoomTarget * (1f - Event.current.delta.y * 0.02f)); } SetZoom(Mathf.Lerp(zoom, zoomTarget, 0.2f)); if (Event.current.type == EventType.ContextClick && !SF_GUI.HoldingAlt()) { Vector2 mousePos = Event.current.mousePosition; if (rect.Contains(mousePos)) { // Now create the menu, add items and show it GenericMenu menu = new GenericMenu(); // First item is for creating a comment box //menu.AddItem( new GUIContent("Create comment box"), false, ContextClick, mousePos ); //menu.AddSeparator(""); for (int i = 0; i < editor.nodeTemplates.Count; i++) { if (editor.ps.catLighting.renderPath == SFPSC_Lighting.RenderPath.Deferred && !editor.nodeTemplates[i].availableInDeferredPrePass) { continue; // Skip forward nodes when in deferred } menu.AddItem(new GUIContent(editor.nodeTemplates[i].fullPath), false, ContextClick, editor.nodeTemplates[i]); } editor.ResetRunningOutdatedTimer(); menu.ShowAsContext(); Event.current.Use(); } } if (Event.current.type == EventType.DragPerform) { Object droppedObj = DragAndDrop.objectReferences[0]; if (droppedObj is Texture2D || /*droppedObj is ProceduralTexture ||*/ droppedObj is RenderTexture) { SFN_Tex2d texNode = editor.nodeBrowser.OnStopDrag() as SFN_Tex2d; texNode.TextureAsset = droppedObj as Texture; texNode.OnAssignedTexture(); Event.current.Use(); } //if(droppedObj is ProceduralMaterial){ // OnDroppedSubstance(droppedObj as ProceduralMaterial); //} } if (Event.current.type == EventType.DragUpdated && Event.current.type != EventType.DragPerform) { if (DragAndDrop.objectReferences.Length > 0) { Object dragObj = DragAndDrop.objectReferences[0]; if (dragObj is Texture2D || /*dragObj is ProceduralTexture || */ dragObj is RenderTexture) { DragAndDrop.visualMode = DragAndDropVisualMode.Link; if (!editor.nodeBrowser.IsPlacing()) { editor.nodeBrowser.OnStartDrag(editor.GetTemplate <SFN_Tex2d>()); } else { editor.nodeBrowser.UpdateDrag(); } } // else if(dragObj is ProceduralMaterial){ // DragAndDrop.visualMode = DragAndDropVisualMode.Link; //} else { DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; } } else { DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; } } // If release if (MouseInsideNodeView(false) && Event.current.type == EventType.MouseUp) { bool ifCursorStayed = Vector2.SqrMagnitude(mousePosStart - Event.current.mousePosition) < SF_Tools.stationaryCursorRadius; if (ifCursorStayed && !SF_GUI.MultiSelectModifierHeld()) { selection.DeselectAll(registerUndo: true); } //editor.Defocus( deselectNodes: ifCursorStayed ); } if (SF_GUI.ReleasedRawLMB()) { SF_NodeConnector.pendingConnectionSource = null; } // If press if (Event.current.type == EventType.MouseDown && MouseInsideNodeView(false)) { //bool ifNotHoldingModifier = !SF_GUI.MultiSelectModifierHeld(); mousePosStart = Event.current.mousePosition; editor.Defocus(); } if (!editor.screenshotInProgress) { Rect logoRect = rect; logoRect.y -= 14; logoRect.x += 1; logoRect.width = SF_GUI.Logo.width; logoRect.height = SF_GUI.Logo.height; GUI.color = new Color(1f, 1f, 1f, 0.5f); GUI.DrawTexture(logoRect, SF_GUI.Logo); logoRect.y += logoRect.height; logoRect.height = 16; GUI.Label(logoRect, "v" + SF_Tools.version, EditorStyles.boldLabel); GUI.color = Color.white; } }
public void OnGUI() { /* * selectionBox.x = Event.current.mousePosition.x; * selectionBox.y = Event.current.mousePosition.y; * selectionBox.width = 128; * selectionBox.height = 128; */ if (SF_GUI.ReleasedRawLMB() && boxSelecting) { ExecuteBoxSelect(); } if (SF_GUI.PressedLMB() && SF_GUI.HoldingBoxSelect()) { boxSelecting = true; if (!SF_GUI.MultiSelectModifierHeld()) { DeselectAll(registerUndo: true); } selectionBox.x = Event.current.mousePosition.x; selectionBox.y = Event.current.mousePosition.y; Event.current.Use(); } // Duplicate, copy, cut, paste EventType et = Application.platform == RuntimePlatform.OSXEditor ? EventType.KeyDown : EventType.KeyUp; // TODO: Use KeyDown for Windows too if (SF_GUI.HoldingControl() && Event.current.type == et && !SF_Node.isEditingAnyNodeTextField) { switch (Event.current.keyCode) { case (KeyCode.D): DuplicateSelection(); break; case (KeyCode.C): CopySelection(); break; case (KeyCode.X): CutSelection(); break; case (KeyCode.V): PasteFromClipboard(); break; } } // Selection box if (boxSelecting) { selectionBox.width = Event.current.mousePosition.x - selectionBox.x; selectionBox.height = Event.current.mousePosition.y - selectionBox.y; if (Event.current.isMouse) { Event.current.Use(); } } if (SF_GUI.PressedDelete() && !SF_Node.isEditingAnyNodeTextField) { DeleteSelected(); Event.current.Use(); } }