private static void InsertClipboard(StepData stepData, int offset) { var target = AssetDatabase.LoadMainAssetAtPath(AssetDatabase.GetAssetPath(stepData.step.serializedObject.targetObject)) as ComposableObject; target.InsertElement(ClipboardItem, stepData.index + offset); ClipboardItem = null; }
protected override Rect OnAfterElementHeaderGUI(Rect rect, ComposableElement element) { var offset = 16; rect.x += offset; rect.width -= offset; return(rect); }
static void Copy(object data) { var stepData = data as StepData; if (ClipboardItem) { DestroyImmediate(ClipboardItem); } ClipboardItem = (ComposableElement)Instantiate(stepData.step.objectReferenceValue); ClipboardItem.name = ClipboardItem.name.Replace("(Clone)", ""); }
private static void AddSubAsset(ComposableElement instance, SerializedProperty stepField, UnityEngine.Object target) { AssetDatabase.AddObjectToAsset(instance, target); stepField.objectReferenceValue = instance; stepField.serializedObject.SetIsDifferentCacheDirty(); stepField.serializedObject.ApplyModifiedProperties(); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(instance)); AssetDatabase.SaveAssets(); }
private static void InsertClipboard(StepData stepData, int offset) { var dataArray = stepData.step.serializedObject.FindProperty(nameof(ComposableObject.Data)); dataArray.InsertArrayElementAtIndex(stepData.index + offset); var property = dataArray.GetArrayElementAtIndex(stepData.index + offset); var target = AssetDatabase.LoadMainAssetAtPath(AssetDatabase.GetAssetPath(stepData.step.serializedObject.targetObject)); AddSubAsset(ClipboardItem, property, target); ClipboardItem = null; }
protected override Rect OnBeforeElementHeaderGUI(Rect rect, ComposableElement element, ref string title) { var job = element as PipelineJob; var toggleRect = new Rect(rect.x + 2, rect.y + 1, 14, EditorGUIUtility.singleLineHeight); var titleContent = new GUIContent(title); job.Active = GUI.Toggle(toggleRect, job.Active, titleContent); toggleRect.x += 16; var size = GUI.skin.label.CalcSize(titleContent); toggleRect.width = size.x; toggleRect.height = size.y; GUI.Label(toggleRect, title); title = string.Empty; return(rect); }
protected virtual Rect OnAfterElementHeaderGUI(Rect rect, ComposableElement element) => rect;
protected virtual Rect OnBeforeElementHeaderGUI(Rect rect, ComposableElement element, ref string title) => rect;