Ejemplo n.º 1
0
        Transitioner SetTransitioner(int index, System.Type transitionerType, string assetName,
                                     string propName)
        {
            DeleteChildAssetsWithName(assetName);
            if (transitionerType == null)
            {
                return(null);
            }
            Transitioner newChild = (Transitioner)CreateInstance(transitionerType.ToString());

            newChild.Reset((AttachStrategy)target);
            newChild.hideFlags = HideFlags.HideInHierarchy;
            newChild.name      = assetName;
            AssetDatabase.AddObjectToAsset(newChild, serializedObject.targetObject);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            SerializedProperty prop = serializedObject.FindProperty(propName);

            if (prop.arraySize < index + 1)
            {
                prop.arraySize = index + 1;
            }
            prop.GetArrayElementAtIndex(index).objectReferenceValue = newChild;
            serializedObject.ApplyModifiedProperties();
            return(newChild);
        }