protected override void OnGUI() { _panelScroll = EditorGUILayout.BeginScrollView(_panelScroll); if (m_windowInformation == null) { m_windowInformation = new TackRopeCreatorWindowInformation(); } bool v_refreshClicked = InspectorUtils.DrawButton("Refresh Informations", Color.cyan); if (v_refreshClicked) { Refresh(); } if (_needFillSelected) { FillSelectedObjects(); } if (_needRecreateList) { RecreateList(true); } if (m_windowInformation.Ropes != null) { m_windowInformation.RopeParent = (Transform)EditorGUILayout.ObjectField("Rope Parent", m_windowInformation.RopeParent, typeof(Transform), true); m_windowInformation.SelectedRopeIndex = EditorGUILayout.Popup("Ropes", m_windowInformation.SelectedRopeIndex, m_windowInformation.Ropes.GetStringList().ToArray()); Rope2D v_rope = m_windowInformation.Ropes != null && m_windowInformation.SelectedRopeIndex >= 0 && m_windowInformation.Ropes.Count > m_windowInformation.SelectedRopeIndex? m_windowInformation.Ropes[m_windowInformation.SelectedRopeIndex] : null; if (m_windowInformation.Rope != v_rope) { m_windowInformation.Rope = v_rope as TackRope; if (v_rope != null) { m_windowInformation.RopeDepth = v_rope.RopeDepth; m_windowInformation.RopeSortingLayerName = v_rope.RopeSortingLayerName; m_windowInformation.CustomPrefabNode = v_rope.CustomNodePrefab; } } bool v_pickSelected = EditorGUILayout.Toggle("Use Selected Objects in Scene", m_windowInformation.PickSelectedObjects); if (m_selectedObjects.Count > 2) { m_windowInformation.PlugLastWithFirst = EditorGUILayout.Toggle("Plug Last With First", m_windowInformation.PlugLastWithFirst); } if (m_windowInformation.PickSelectedObjects != v_pickSelected) { m_windowInformation.PickSelectedObjects = v_pickSelected; FillSelectedObjects(); RecreateList(true); } DrawList(); InspectorUtils.DrawTitleText("Rope Properties", new Color(1, 0.1f, 0.7f)); //Sorting Layer string[] v_sortingLayers = GetSortingLayerNames(); int v_sortingIndex = EditorGUILayout.Popup("Rope Sorting Layer", GetObjectIndexInArrayOrStrings(v_sortingLayers, m_windowInformation.RopeSortingLayerName), v_sortingLayers); m_windowInformation.RopeSortingLayerName = v_sortingLayers.Length > v_sortingIndex && v_sortingIndex >= 0? v_sortingLayers[v_sortingIndex] : "Default"; m_windowInformation.RopeDepth = EditorGUILayout.IntField("Rope Z Order", m_windowInformation.RopeDepth); m_windowInformation.CustomPrefabNode = EditorGUILayout.ObjectField("Custom Node Prefab", m_windowInformation.CustomPrefabNode, typeof(GameObject), false) as GameObject; m_windowInformation.AutomaticCalculateNodes = EditorGUILayout.Toggle("Automatic Calculate Amount of Nodes", m_windowInformation.AutomaticCalculateNodes); if (!m_windowInformation.AutomaticCalculateNodes) { m_windowInformation.AmountOfNodes = EditorGUILayout.IntField("Amount of Nodes", m_windowInformation.AmountOfNodes); } m_windowInformation.UsePrefabRopeScale = EditorGUILayout.Toggle("Use Prefab Rope Scale", m_windowInformation.UsePrefabRopeScale); InspectorUtils.DrawTitleText("", new Color(1, 0.1f, 0.7f)); GUILayout.Space(10); if (m_selectedObjects.Count >= 2) { //Final Buttons bool v_recreateClicked = false; bool v_deletePreviousClicked = false; if (m_currentCreatedRopes.Count > 0) { EditorGUILayout.BeginHorizontal(); v_recreateClicked = InspectorUtils.DrawButton("Recreate Previus Ropes", new Color(0.4f, 0.7f, 1f)); v_deletePreviousClicked = InspectorUtils.DrawButton("Delete Previus Ropes", new Color(1f, 0.7f, 0.1f)); EditorGUILayout.EndHorizontal(); } bool v_buttonClicked = InspectorUtils.DrawButton("Create New Rope", Color.green); if (v_recreateClicked) { RecreateRopeClicked(); } if (v_deletePreviousClicked) { DeleteRopeClicked(); } else if (v_buttonClicked) { CreateRopeClicked(); } } } EditorGUILayout.EndScrollView(); if (GUI.changed) { EditorUtility.SetDirty(this); } }
protected override void OnGUI () { _panelScroll = EditorGUILayout.BeginScrollView(_panelScroll); if(m_windowInformation == null) m_windowInformation = new TackRopeCreatorWindowInformation(); bool v_refreshClicked = InspectorUtils.DrawButton("Refresh Informations", Color.cyan); if(v_refreshClicked) Refresh(); if(_needFillSelected) FillSelectedObjects(); if(_needRecreateList) RecreateList(true); if(m_windowInformation.Ropes != null) { m_windowInformation.RopeParent = (Transform)EditorGUILayout.ObjectField ("Rope Parent", m_windowInformation.RopeParent, typeof(Transform), true); m_windowInformation.SelectedRopeIndex = EditorGUILayout.Popup("Ropes", m_windowInformation.SelectedRopeIndex, m_windowInformation.Ropes.GetStringList().ToArray()); Rope2D v_rope = m_windowInformation.Ropes != null && m_windowInformation.SelectedRopeIndex >=0 && m_windowInformation.Ropes.Count > m_windowInformation.SelectedRopeIndex? m_windowInformation.Ropes[m_windowInformation.SelectedRopeIndex] : null; if(m_windowInformation.Rope != v_rope) { m_windowInformation.Rope = v_rope as TackRope; if(v_rope != null) { m_windowInformation.RopeDepth = v_rope.RopeDepth; m_windowInformation.RopeSortingLayerName = v_rope.RopeSortingLayerName; m_windowInformation.CustomPrefabNode = v_rope.CustomNodePrefab; } } bool v_pickSelected = EditorGUILayout.Toggle("Use Selected Objects in Scene", m_windowInformation.PickSelectedObjects); if(m_selectedObjects.Count > 2) m_windowInformation.PlugLastWithFirst = EditorGUILayout.Toggle("Plug Last With First" , m_windowInformation.PlugLastWithFirst); if(m_windowInformation.PickSelectedObjects != v_pickSelected) { m_windowInformation.PickSelectedObjects = v_pickSelected; FillSelectedObjects(); RecreateList(true); } DrawList(); InspectorUtils.DrawTitleText("Rope Properties", new Color(1, 0.1f, 0.7f)); //Sorting Layer string[] v_sortingLayers = GetSortingLayerNames(); int v_sortingIndex = EditorGUILayout.Popup("Rope Sorting Layer", GetObjectIndexInArrayOrStrings(v_sortingLayers, m_windowInformation.RopeSortingLayerName), v_sortingLayers); m_windowInformation.RopeSortingLayerName = v_sortingLayers.Length > v_sortingIndex && v_sortingIndex >=0? v_sortingLayers[v_sortingIndex] : "Default"; m_windowInformation.RopeDepth = EditorGUILayout.IntField("Rope Z Order", m_windowInformation.RopeDepth); m_windowInformation.CustomPrefabNode = EditorGUILayout.ObjectField("Custom Node Prefab", m_windowInformation.CustomPrefabNode, typeof(GameObject), false) as GameObject; m_windowInformation.AutomaticCalculateNodes = EditorGUILayout.Toggle("Automatic Calculate Amount of Nodes", m_windowInformation.AutomaticCalculateNodes); if(!m_windowInformation.AutomaticCalculateNodes) m_windowInformation.AmountOfNodes = EditorGUILayout.IntField("Amount of Nodes", m_windowInformation.AmountOfNodes); m_windowInformation.UsePrefabRopeScale = EditorGUILayout.Toggle("Use Prefab Rope Scale", m_windowInformation.UsePrefabRopeScale); InspectorUtils.DrawTitleText("", new Color(1, 0.1f, 0.7f)); GUILayout.Space(10); if(m_selectedObjects.Count >= 2) { //Final Buttons bool v_recreateClicked = false; bool v_deletePreviousClicked = false; if(m_currentCreatedRopes.Count > 0) { EditorGUILayout.BeginHorizontal(); v_recreateClicked = InspectorUtils.DrawButton("Recreate Previus Ropes", new Color(0.4f, 0.7f,1f)); v_deletePreviousClicked = InspectorUtils.DrawButton("Delete Previus Ropes", new Color(1f, 0.7f,0.1f)); EditorGUILayout.EndHorizontal(); } bool v_buttonClicked = InspectorUtils.DrawButton("Create New Rope", Color.green); if(v_recreateClicked) RecreateRopeClicked(); if(v_deletePreviousClicked) DeleteRopeClicked(); else if(v_buttonClicked) CreateRopeClicked(); } } EditorGUILayout.EndScrollView(); if(GUI.changed) EditorUtility.SetDirty(this); }