/// <summary> /// Selects nothing (null), a link or one or more modules /// </summary> /// <param name="mod"></param> public void Select(params object[] objects) { Clear(); if (objects == null || objects.Length == 0) { return; } if (objects[0] is List <CGModule> ) { objects = ((List <CGModule>)objects[0]).ToArray(); } if (objects[0] is CGModuleLink) { SelectedLink = (CGModuleLink)objects[0]; } else { List <Component> cmp = new List <Component>(); foreach (object o in objects) { if (o is CGModule) { SelectedModules.Add((CGModule)o); cmp.Add((CGModule)o); } } if (CurvyProject.Instance.CGSynchronizeSelection) { DTSelection.SetGameObjects(cmp.ToArray()); } } }
void itemGUI(Rect rect, int index, bool isActive, bool isFocused) { var item = sorted[index]; var r = getRects(rect); if (item.gameObject == Selection.activeGameObject) { DTHandles.DrawSolidRectangleWithOutline(rect.ScaleBy(4, 2), new Color(0, 0, 0.2f, 0.1f), new Color(.24f, .37f, .59f)); } else if (index > 0) { DTHandles.PushHandlesColor(new Color(0.1f, 0.1f, 0.1f)); Handles.DrawLine(new Vector2(rect.xMin - 5, rect.yMin), new Vector2(rect.xMax + 4, rect.yMin)); DTHandles.PopHandlesColor(); } bool repaint = false; var cnt = new GUIContent(item.ToString(), "Click to select"); r[0].width = DTStyles.HtmlLinkLabel.CalcSize(cnt).x; if (DTGUI.LinkButton(r[0], cnt, ref repaint))// EditorStyles.label)) { DTSelection.SetGameObjects(sorted[index]); } if (repaint) { Repaint(); } item.ConnectionSyncPosition = GUI.Toggle(r[1], item.ConnectionSyncPosition, ""); item.ConnectionSyncRotation = GUI.Toggle(r[8], item.ConnectionSyncRotation, ""); if (GUI.Button(r[2], new GUIContent(CurvyStyles.DeleteSmallTexture, "Delete"), CurvyStyles.ImageButton)) { item.Disconnect(); CurvyProject.Instance.ScanConnections(); GUIUtility.ExitGUI(); } if (item.CanHaveFollowUp) { GUI.Label(r[3], "Head to"); doFollowUpPopup(r[4], item); bool b = item.FollowUpHeading == ConnectionHeadingEnum.Minus; if (GUI.Toggle(r[5], b, new GUIContent("", "Head to spline start")) != b) { item.FollowUpHeading = (!b) ? ConnectionHeadingEnum.Minus : ConnectionHeadingEnum.Auto; } b = item.FollowUpHeading == ConnectionHeadingEnum.Sharp; if (GUI.Toggle(r[6], b, new GUIContent("", "No Heading")) != b) { item.FollowUpHeading = (!b) ? ConnectionHeadingEnum.Sharp : ConnectionHeadingEnum.Auto; } b = item.FollowUpHeading == ConnectionHeadingEnum.Plus; if (GUI.Toggle(r[7], b, new GUIContent("", "Head to spline end")) != b) { item.FollowUpHeading = (!b) ? ConnectionHeadingEnum.Plus : ConnectionHeadingEnum.Auto; } } }
void ConnectionGUI(DTInspectorNode node) { if (mConnectionEditor != null && Target.Connection != null) { EditorGUILayout.BeginHorizontal(); Target.Connection.name = EditorGUILayout.TextField("Name", Target.Connection.name); if (GUILayout.Button(new GUIContent("Select", "Select the Connection GameObject"))) { DTSelection.SetGameObjects(Target.Connection); } EditorGUILayout.EndHorizontal(); mConnectionEditor.OnInspectorGUI(); } }
void OnUpdate() { // check if a deleted Curvy object defines a new object to select if (EditorApplication.isPlayingOrWillChangePlaymode) { CurvySpline._newSelectionInstanceIDINTERNAL = 0; } if (CurvySpline._newSelectionInstanceIDINTERNAL != 0) { var o = EditorUtility.InstanceIDToObject(CurvySpline._newSelectionInstanceIDINTERNAL); if (o != null && o is Component) { DTSelection.SetGameObjects((Component)o); } CurvySpline._newSelectionInstanceIDINTERNAL = 0; } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var mControlRect = position; CGResourceManagerAttribute A = (CGResourceManagerAttribute)attribute; var lst = this.GetPropertySourceField <ICGResourceCollection>(property); label = EditorGUI.BeginProperty(position, label, property); if (lst != null) { if (lst.Count > 0) { label.text += string.Format("[{0}]", lst.Count); } EditorGUI.PrefixLabel(mControlRect, label); mControlRect.x = (A.ReadOnly) ? mControlRect.xMax - 60 : mControlRect.xMax - 82; mControlRect.width = 60; if (GUI.Button(mControlRect, new GUIContent("Select", CurvyStyles.SelectTexture, "Select"))) { DTSelection.SetGameObjects(lst.ItemsArray); } } }