static void Init() { window = (VertexPainter)EditorWindow.GetWindow(typeof(VertexPainter)); onSceneGUIFunc = new SceneView.OnSceneFunc(OnSceneGUI); SceneView.onSceneGUIDelegate += onSceneGUIFunc; VertexPainterHash = window.GetHashCode(); currentSelection = Selection.activeGameObject; if (currentSelection != null) { currentSelectionMeshFilter = currentSelection.GetComponent <MeshFilter>(); if (currentSelectionMeshFilter != null) { currentSelectionMesh = currentSelectionMeshFilter.sharedMesh; } else { Debug.Log("Meshfilter null"); } } ChannelsToPaint.Red = true; ChannelsToPaint.Blue = true; ChannelsToPaint.Green = true; }
static void InitPaletteWindowProps() { if (_paletteWindowOnGui == null) { _paletteWindowOnGui = (SceneView.OnSceneFunc)Delegate.CreateDelegate(typeof(SceneView.OnSceneFunc), EditorWindow.GetWindow(_paletteWindowType), "OnSceneViewGUI"); } }
public static void DisableTilemapFocus() { if (_paletteWindowOnGui != null) { SceneView.onSceneGUIDelegate += _paletteWindowOnGui; _paletteWindowOnGui = null; } }
private void AddOnSceneGUIListener() { if (_onSceneGUIListener == null) { _onSceneGUIListener = OnSceneGUI; SceneView.onSceneGUIDelegate += _onSceneGUIListener; } }
private void RemoveOnSceneGUIListener() { if (_onSceneGUIListener != null) { SceneView.onSceneGUIDelegate -= _onSceneGUIListener; _onSceneGUIListener = null; } }
void OnEnable() { if (onSceneGUIFunc == null) { onSceneGUIFunc = new SceneView.OnSceneFunc(OnSceneGUI); } currentPoints = new List <Vector3>(); }
public static void UnregisterOnPreSceneGUIDelegate(SceneView.OnSceneFunc func) { var del = onPreSceneGuiDelegate; if (del != null) { del -= func; } }
void OnDestroy() { Save(); s_window = null; SceneView.onSceneGUIDelegate -= s_OnSceneGUI; EditorApplication.update -= s_OnEditorWindowUpdate; s_OnSceneGUI = null; s_OnEditorWindowUpdate = null; }
public static void OverlayLabel(Vector3 position, GUIContent content, GUIStyle style) { SceneView.OnSceneFunc del = null; del = delegate { // ReSharper disable once DelegateSubtraction SceneView.onSceneGUIDelegate -= del; Handles.Label(position, content, style); }; SceneView.onSceneGUIDelegate += del; }
/// <summary> /// Disable the visualization. /// </summary> public void Hide() { if (mDelegate != null) { SceneView.onSceneGUIDelegate -= mDelegate; SceneView.RepaintAll(); } mNavmeshData = null; mDataVersion = -1; mNavmesh = null; mDelegate = null; }
public static void RegisterOnPreSceneGUIDelegate(SceneView.OnSceneFunc func) { var del = onPreSceneGuiDelegate; if (del == null) { onPreSceneGuiDelegate = func; } else { del += func; } }
public IEnumerator BoneGizmo_MouseClick_SelectsClosestBoneGameObject_BoneTransformsHaveNoParent([ValueSource("BoneGizmoGOPositionCases")] BoneGizmoGOPositionTestCase testCase) { m_SpriteSkin.transform.position = testCase.position; Selection.activeGameObject = m_SpriteSkin.gameObject; UnityEditor.Tools.current = Tool.None; foreach (var transform in m_SpriteSkin.boneTransforms) { transform.parent = null; } // Get Mouse Position based on actual SceneView state by using SceneView delegate bool doingTest = false; bool testDone = false; Vector2 sceneViewMousePosition = Vector2.zero; SceneView.OnSceneFunc sceneViewDelegate = (sceneView) => { if (sceneView != s_SceneView) { return; } if (!doingTest) { doingTest = true; ResetSceneViewCamera(); sceneViewMousePosition = WorldToSceneViewPosition(testCase.position); testDone = true; } }; SceneView.onSceneGUIDelegate += sceneViewDelegate; while (!testDone) { yield return(null); } SceneView.onSceneGUIDelegate -= sceneViewDelegate; SceneViewMouseClick(sceneViewMousePosition); var selectedGO = m_SpriteSkin.boneTransforms[1].gameObject; var selection = Selection.activeGameObject; Assert.AreNotEqual(m_SpriteSkin.gameObject, selection); Assert.AreEqual(selectedGO, selection); Assert.AreEqual(Tool.None, UnityEditor.Tools.current); }
/// <summary> /// Show the visualization for the object. /// </summary> /// <param name="data">The object to visualize.</param> public void Show(INavmeshData data) { Hide(); if (!(ScriptableObject)data) { return; } mNavmeshData = data; mDelegate = new SceneView.OnSceneFunc(OnSceneGUI); SceneView.onSceneGUIDelegate += mDelegate; SceneView.RepaintAll(); }
void AddDelegate() { SceneView.OnSceneFunc del = SceneView.onSceneGUIDelegate; if (del != null) { Delegate[] arrays = del.GetInvocationList(); for (int i = 0; i < arrays.Length; i++) { if (arrays[i].Target == this) { Debug.Log("重复添加"); return; } } } SceneView.onSceneGUIDelegate += OnSceneUI; }
static void Init () { window = (VertexPainter)EditorWindow.GetWindow (typeof (VertexPainter)); onSceneGUIFunc = new SceneView.OnSceneFunc(OnSceneGUI); SceneView.onSceneGUIDelegate += onSceneGUIFunc; VertexPainterHash = window.GetHashCode(); currentSelection = Selection.activeGameObject; if (currentSelection!= null) { currentSelectionMeshFilter = currentSelection.GetComponent<MeshFilter>(); if (currentSelectionMeshFilter!= null) currentSelectionMesh = currentSelectionMeshFilter.sharedMesh; else Debug.Log("meshfilter null"); } }
//初始化函数 void Init() { minSize = new Vector2(600, 0); RenderSettings.fog = false; _delegate = new SceneView.OnSceneFunc(OnSceneFunc); SceneView.onSceneGUIDelegate += _delegate; m_sBornListPath = ""; m_sObstaclePath = ""; m_sNavigationPath = ""; //加载选择图片 ChangeTexture(ref _windowInstance.m_ObstcalePng); //加载prefab string sPrefabPath = "Assets/Z_Temp/Obstacle/SceneEditorPerfab/"; //ObsPrefabs = AssetDatabase.LoadAssetAtPath( sPrefabPath + "Obstacle.prefab", typeof(GameObject)) as GameObject; ; RegionBorn = AssetDatabase.LoadAssetAtPath(sPrefabPath + "RegionBorn.prefab", typeof(GameObject)) as GameObject;; PointBorn = AssetDatabase.LoadAssetAtPath(sPrefabPath + "PointBorn.prefab", typeof(GameObject)) as GameObject;; ScenePointBorn = AssetDatabase.LoadAssetAtPath(sPrefabPath + "ScenePointBorn.prefab", typeof(GameObject)) as GameObject;; PathPointBorn = AssetDatabase.LoadAssetAtPath(sPrefabPath + "PathPointBorn.prefab", typeof(GameObject)) as GameObject; PatrolBorn = AssetDatabase.LoadAssetAtPath(sPrefabPath + "PatrolBorn.prefab", typeof(GameObject)) as GameObject; //生成各个父节点 AllParent = GameObject.Find("Parent"); if (AllParent == null) { GameObject parent = AssetDatabase.LoadAssetAtPath(sPrefabPath + "Parent.prefab", typeof(GameObject)) as GameObject; AllParent = Instantiate(parent) as GameObject; AllParent.transform.position = new Vector3(0, 0, 0); AllParent.name = AllParent.name.Replace("(Clone)", ""); } m_csPathGrid = AllParent.GetComponent <PathGridComponent>(); m_csPathGrid.m_debugShow = true; CheekParent(); m_csPathGrid.InitArray(false); GetFloorHeight(); _windowInstance.position = new Rect(400, 90, 150, 940); BornInfoWindow.OpenWindow(); EditerDataClass._Instance.Init(); //InteractionTool.AddObserver(EditerDataClass._Instance); //InteractionTool.AddObserver(BornInfoWindow._Instance); // InteractionTool.InitObserver(); //自动导入阻挡文件 InteractionTool.Importobstacle(true); }
public static void RemoveGUI(SceneView.OnSceneFunc func) { if (UnitySymbol.Has("UNITY_2019_1_OR_NEWER")) { if (s_func.ContainsKey(func)) { var t = typeof(SceneView); var ev = t.GetEvent("duringSceneGui"); ev.RemoveEventHandler(null, s_func[func]); s_func.Remove(func); } } else { SceneView.onSceneGUIDelegate -= func; } Repaint(); }
private void RegisterStaticOnSceneGUI() { Delegate arg_23_0 = SceneView.onSceneGUIDelegate; if (SelectableEditor.< > f__mg$cache0 == null) { SelectableEditor.< > f__mg$cache0 = new SceneView.OnSceneFunc(SelectableEditor.StaticOnSceneGUI); } SceneView.onSceneGUIDelegate = (SceneView.OnSceneFunc)Delegate.Remove(arg_23_0, SelectableEditor.< > f__mg$cache0); if (SelectableEditor.s_Editors.Count > 0) { Delegate arg_64_0 = SceneView.onSceneGUIDelegate; if (SelectableEditor.< > f__mg$cache1 == null) { SelectableEditor.< > f__mg$cache1 = new SceneView.OnSceneFunc(SelectableEditor.StaticOnSceneGUI); } SceneView.onSceneGUIDelegate = (SceneView.OnSceneFunc)Delegate.Combine(arg_64_0, SelectableEditor.< > f__mg$cache1); } }
public static void AddGUI(SceneView.OnSceneFunc func) { if (UnitySymbol.Has("UNITY_2019_1_OR_NEWER")) { if (!s_func.ContainsKey(func)) { var t = typeof(SceneView); var ev = t.GetEvent("duringSceneGui"); Action <SceneView> a = (ss) => { func(ss); }; ev.AddEventHandler(null, a); s_func.Add(func, a); } } else { SceneView.onSceneGUIDelegate += func; } Repaint(); }
public static void SceneEvent(bool state) { if (state) { if (_onSceneGUI_ == null) { _onSceneGUI_ = new SceneView.OnSceneFunc(instance.OnSceneGUI); SceneView.onSceneGUIDelegate += _onSceneGUI_; } } else { SceneView.onSceneGUIDelegate -= _onSceneGUI_; _onSceneGUI_ = null; } SceneView.RepaintAll(); }
public override void OnInspectorGUI() { plotter = (HairyPlotter)target; if (!plotter) { return; } if (sceneViewCallback == null) { sceneViewCallback = new SceneView.OnSceneFunc(OnSceneViewRender); } if (!ReferenceEquals(SceneView.onSceneGUIDelegate, sceneViewCallback)) { SceneView.onSceneGUIDelegate = sceneViewCallback; } plotter.InitEditing(); EditorGUILayout.LabelField("Edit Mesh", plotter.EditMesh.name); EditorGUILayout.LabelField("Original Mesh", plotter.OriginalMesh ?? ""); EditorGUILayout.LabelField("Vertex Count", plotter.VertexCount.ToString()); EditorGUILayout.LabelField("Triangle Count", plotter.TriangleCount.ToString()); EditorGUILayout.LabelField("Unused Vertices", plotter.UnusedVerticesCount.ToString()); VertexToolbox(); TriangleToolbox(); VertexSelectionToolbox(); TriangleSelectionToolbox(); UvToolbox(); plotter.UpdateMesh(); if (Event.current.type == EventType.Repaint) { if (SceneView.lastActiveSceneView != null) { SceneView.lastActiveSceneView.Repaint(); } } }
static void Init() { if (s_window == null) { s_window = ScriptableObject.CreateInstance <MenuShortcutsWindow>(); s_window.titleContent = new GUIContent("Shortcuts"); CheckInitAllMenuItems(); } if (s_shortcuts.Count == 0) { s_page = Page.All; } else { s_page = Page.Shortcuts; } s_window.Show(); s_OnSceneGUI = OnSceneGUI; s_OnEditorWindowUpdate = OnEditorWindowUpdate; EditorApplication.update += s_OnEditorWindowUpdate; SceneView.onSceneGUIDelegate += s_OnSceneGUI; }
void OnEnable() { Undo.undoRedoPerformed += UndoRedo; if (onSceneFunc == null) { onSceneFunc = new SceneView.OnSceneFunc(OnSceneGUI); } GameObject g = new GameObject("RobBossTarget"); g.hideFlags = HideFlags.HideAndDontSave; raycastTarget = g.AddComponent <MeshCollider>(); colliderMesh = new Mesh(); colliderMesh.name = "RobBossColliderMesh"; colliderMesh.hideFlags = HideFlags.HideAndDontSave; raycastTarget.sharedMesh = colliderMesh; directional = EditorPrefs.GetInt("RobBoss.Directional", 0) == 1; string colorString = EditorPrefs.GetString("RobBoss.Color", "FFFFFFFF"); ColorUtility.TryParseHtmlString("#" + colorString, out color); radius = EditorPrefs.GetFloat("RobBoss.Radius", 0.5f); blend = EditorPrefs.GetFloat("RobBoss.Blend", 0.1f); }
void OnEnable() { window = this; onSceneGUIFunc = this.OnSceneGUI; SceneView.onSceneGUIDelegate += onSceneGUIFunc; string guiPath = "Assets/ProCore/QuickBrush/Resources/Skin/"; addPrefabTexture = AssetDatabase.LoadAssetAtPath(guiPath + "qb_addPrefabIcon.tga", typeof(Texture2D)) as Texture2D; addPrefabFieldTexture = AssetDatabase.LoadAssetAtPath(guiPath + "qb_addPrefabField.tga", typeof(Texture2D)) as Texture2D; removePrefabXTexture_normal = AssetDatabase.LoadAssetAtPath(guiPath + "qb_removePrefabXIcon_normal.tga", typeof(Texture2D)) as Texture2D; removePrefabXTexture_hover = AssetDatabase.LoadAssetAtPath(guiPath + "qb_removePrefabXIcon_hover.tga", typeof(Texture2D)) as Texture2D; selectPrefabCheckTexture_normal = AssetDatabase.LoadAssetAtPath(guiPath + "qb_selectPrefabCheck_normal.tga", typeof(Texture2D)) as Texture2D; selectPrefabCheckTexture_hover = AssetDatabase.LoadAssetAtPath(guiPath + "qb_selectPrefabCheck_hover.tga", typeof(Texture2D)) as Texture2D; prefabFieldBackgroundTexture = AssetDatabase.LoadAssetAtPath(guiPath + "qb_prefabFieldBackground.tga", typeof(Texture2D)) as Texture2D; brushIcon_Active = AssetDatabase.LoadAssetAtPath(guiPath + "qb_brushIcon_Active.tga", typeof(Texture2D)) as Texture2D; brushIcon_Inactive = AssetDatabase.LoadAssetAtPath(guiPath + "qb_brushIcon_Inactive.tga", typeof(Texture2D)) as Texture2D; eraserIcon_Active = AssetDatabase.LoadAssetAtPath(guiPath + "qb_eraserIcon_Active.tga", typeof(Texture2D)) as Texture2D; eraserIcon_Inactive = AssetDatabase.LoadAssetAtPath(guiPath + "qb_eraserIcon_Inactive.tga", typeof(Texture2D)) as Texture2D; placementIcon_Active = AssetDatabase.LoadAssetAtPath(guiPath + "qb_placementIcon_Active.tga", typeof(Texture2D)) as Texture2D; ///// UpdateGroups(); //BuildStyles(); EnableMenu(); ClearForm(); //Temp Removes any instance of ObjectContainer from the scene. //qb_ObjectContainer tryInstance = (qb_ObjectContainer)FindObjectOfType(typeof(qb_ObjectContainer)); //if(tryInstance != null) // Object.DestroyImmediate(tryInstance.gameObject); }
public static void RemoveGUI(SceneView.OnSceneFunc func) { SceneView.onSceneGUIDelegate -= func; #endif }
public static void AddGUI(SceneView.OnSceneFunc func) { SceneView.onSceneGUIDelegate += func; #endif }
public static bool SceneViewHasDelegate(SceneView.OnSceneFunc targetDelegate) { return(HasDelegate(SceneView.onSceneGUIDelegate, targetDelegate)); }
void OnEnable() { onSceneGUIFunc = this.OnSceneGUI; SceneView.onSceneGUIDelegate += onSceneGUIFunc; }
//static string prefs_directory = string.Empty; //The Directory in which templates are stored - should be validated - if invalid, create when template is saved #endregion public void OnEnable() { window = this; onSceneGUIFunc = this.OnSceneGUI; SceneView.onSceneGUIDelegate += onSceneGUIFunc; directory = qb_Utility.GetHeadDirectory(); LoadTextures(); BuildStyles(); EnableMenu(); }
public override void OnInspectorGUI() { plotter = (HairyPlotter)target; if (!plotter) return; if (sceneViewCallback == null) sceneViewCallback = new SceneView.OnSceneFunc(OnSceneViewRender); if (!ReferenceEquals(SceneView.onSceneGUIDelegate, sceneViewCallback)) SceneView.onSceneGUIDelegate = sceneViewCallback; plotter.InitEditing(); EditorGUILayout.LabelField("Edit Mesh", plotter.EditMesh.name); EditorGUILayout.LabelField("Original Mesh", plotter.OriginalMesh ?? ""); EditorGUILayout.LabelField("Vertex Count", plotter.VertexCount.ToString()); EditorGUILayout.LabelField("Triangle Count", plotter.TriangleCount.ToString()); EditorGUILayout.LabelField("Unused Vertices", plotter.UnusedVerticesCount.ToString()); VertexToolbox(); TriangleToolbox(); VertexSelectionToolbox(); TriangleSelectionToolbox(); UvToolbox(); plotter.UpdateMesh(); if (Event.current.type == EventType.Repaint) { if (SceneView.lastActiveSceneView != null) { SceneView.lastActiveSceneView.Repaint(); } } }
void OnEnable() { m_SceneGUIDelegate = new SceneView.OnSceneFunc(OnSceneGUIDelegate); SceneView.onSceneGUIDelegate += m_SceneGUIDelegate; }
void OnEnable() { if (onSceneGUIFunc == null) { onSceneGUIFunc = new SceneView.OnSceneFunc(OnSceneGUI); } currentPoints = new List<Vector3>(); }
/// <summary> /// Show the visualization for the object. /// </summary> /// <param name="data">The object to visualize.</param> public void Show(INavmeshData data) { Hide(); if (!(ScriptableObject)data) return; mNavmeshData = data; mDelegate = new SceneView.OnSceneFunc(OnSceneGUI); SceneView.onSceneGUIDelegate += mDelegate; SceneView.RepaintAll(); }
// Remove delegate from UnityEditor.SceneView.onPreSceneGUIDelegate public static void RemoveOnPreSceneGUIDelegate(SceneView.OnSceneFunc func) { onPreSceneGUIDelegate = Delegate.Remove(func, onPreSceneGUIDelegate) as SceneView.OnSceneFunc; }
public void SetOnPreSceneGUIDelegate(SceneView.OnSceneFunc del) { fi_onPreSceneGUIDelegate.SetValue(null, del); }
public static void UpdatePrefabInstancePropertyModifications(UnityEngine.Object prefabInstance, bool withUndo) { if (prefabInstance == null) { throw new ArgumentNullException("prefabInstance"); } if (!(prefabInstance is ISupportsPrefabSerialization)) { throw new ArgumentException("Type must implement ISupportsPrefabSerialization"); } if (!(prefabInstance is ISerializationCallbackReceiver)) { throw new ArgumentException("Type must implement ISerializationCallbackReceiver"); } if (!OdinPrefabSerializationEditorUtility.ObjectIsPrefabInstance(prefabInstance)) { throw new ArgumentException("Value must be a prefab instance"); } Action action = null; EditorApplication.HierarchyWindowItemCallback hierarchyCallback = (arg1, arg2) => action(); EditorApplication.ProjectWindowItemCallback projectCallback = (arg1, arg2) => action(); SceneView.OnSceneFunc sceneCallback = (arg) => action(); EditorApplication.hierarchyWindowItemOnGUI += hierarchyCallback; EditorApplication.projectWindowItemOnGUI += projectCallback; SceneView.onSceneGUIDelegate += sceneCallback; action = () => { EditorApplication.hierarchyWindowItemOnGUI -= hierarchyCallback; EditorApplication.projectWindowItemOnGUI -= projectCallback; SceneView.onSceneGUIDelegate -= sceneCallback; // Clear out pre-existing modifications, as they can actually mess this up { ISupportsPrefabSerialization supporter = (ISupportsPrefabSerialization)prefabInstance; if (supporter.SerializationData.PrefabModifications != null) { supporter.SerializationData.PrefabModifications.Clear(); } if (supporter.SerializationData.PrefabModificationsReferencedUnityObjects != null) { supporter.SerializationData.PrefabModificationsReferencedUnityObjects.Clear(); } UnitySerializationUtility.PrefabModificationCache.CachePrefabModifications(prefabInstance, new List <PrefabModification>()); } try { if (prefabInstance == null) { // Ignore - the object has been destroyed since the method was invoked. return; } if (Event.current == null) { throw new InvalidOperationException("Delayed property modification delegate can only be called during the GUI event loop; Event.current must be accessible."); } try { PrefabUtility.RecordPrefabInstancePropertyModifications(prefabInstance); } catch (Exception ex) { Debug.LogError("Exception occurred while calling Unity's PrefabUtility.RecordPrefabInstancePropertyModifications:"); Debug.LogException(ex); } var tree = PropertyTree.Create(prefabInstance); tree.DrawMonoScriptObjectField = false; bool isRepaint = Event.current.type == EventType.Repaint; if (!isRepaint) { GUIHelper.PushEventType(EventType.Repaint); } InspectorUtilities.BeginDrawPropertyTree(tree, withUndo); foreach (var property in tree.EnumerateTree(true)) { if (property.ValueEntry == null) { continue; } if (!property.SupportsPrefabModifications) { continue; } property.Update(true); if (!(property.ChildResolver is IKeyValueMapResolver)) { continue; } if (property.ValueEntry.DictionaryChangedFromPrefab) { tree.PrefabModificationHandler.RegisterPrefabDictionaryDeltaModification(property, 0); } else { var prefabProperty = tree.PrefabModificationHandler.PrefabPropertyTree.GetPropertyAtPath(property.Path); if (prefabProperty == null) { continue; } if (prefabProperty.ValueEntry == null) { continue; } if (!property.SupportsPrefabModifications) { continue; } if (!(property.ChildResolver is IKeyValueMapResolver)) { continue; } tree.PrefabModificationHandler.RegisterPrefabDictionaryDeltaModification(property, 0); } } InspectorUtilities.EndDrawPropertyTree(tree); if (!isRepaint) { GUIHelper.PopEventType(); } ISerializationCallbackReceiver receiver = (ISerializationCallbackReceiver)prefabInstance; receiver.OnBeforeSerialize(); receiver.OnAfterDeserialize(); } catch (Exception ex) { Debug.LogException(ex); } }; foreach (SceneView scene in SceneView.sceneViews) { scene.Repaint(); } }