예제 #1
0
    void CreateNewPainterElement(GameObject variation)
    {
        PrefabPainterElement newElement = CreateNewElement(variation);


        System.Array.Resize(ref allElements, allElements.Length + 1);
        System.Array.Resize(ref elementNames, elementNames.Length + 1);


        allElements[allElements.Length - 1]   = newElement;
        elementNames[elementNames.Length - 1] = newElement.name;
        currentElementIndex = allElements.Length - 1;
    }
예제 #2
0
    PrefabPainterElement CreateNewElement(GameObject variation)
    {
        PrefabPainterElement newElement = ScriptableObject.CreateInstance <PrefabPainterElement>();

        string newElementName = "NewPainterElement";

        if (variation != null)
        {
            newElement.variations = new List <GameObject>()
            {
                variation
            };
            newElementName = variation.name + "_PainterElement";
        }
        AssetDatabase.CreateAsset(newElement, AssetDatabase.GenerateUniqueAssetPath("Assets/" + newElementName + ".asset"));
        AssetDatabase.SaveAssets();

        return(newElement);
    }
예제 #3
0
    static void DrawPainterElement(PrefabPainterElement element)
    {
        if (element == null)
        {
            return;
        }

        EditorGUI.indentLevel++;

        EditorGUILayout.BeginVertical("box");
        EditorGUILayout.Space();

        GameObject newVariation = (GameObject)EditorGUILayout.ObjectField("New Variation:", null, typeof(GameObject), false);

        if (newVariation != null)
        {
            element.variations.Add(newVariation);
            // System.Array.Resize(ref element.variations, element.variations.Count + 1);
            // element.variations[element.variations.Count -1] = newVariation;
        }

        int indexToDelete = -1;

        for (int i = 0; i < element.variations.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();
            element.variations[i] = (GameObject)EditorGUILayout.ObjectField(element.variations[i], typeof(GameObject), false);
            GUI.backgroundColor   = redColor;
            if (GUILayout.Button("", smallButtonWidth))
            {
                indexToDelete = i;
            }
            GUI.backgroundColor = Color.white;
            EditorGUILayout.EndHorizontal();
        }
        if (indexToDelete != -1)
        {
            element.variations.Remove(element.variations[indexToDelete]);
        }


        // EditorGUILayout.BeginHorizontal();

        // EditorGUILayout.LabelField("Randomize Rotations: (X, Y, Z)", randomAxisLabelWidth);

        // element.randomX = EditorGUILayout.Toggle(element.randomX, randomAxisWidth);
        // element.randomY = EditorGUILayout.Toggle(element.randomY, randomAxisWidth);
        // element.randomZ = EditorGUILayout.Toggle(element.randomZ, randomAxisWidth);

        // EditorGUILayout.EndHorizontal();

        // element.yOffset = EditorGUILayout.Vector3Field("Local Pos Offset", element.localPositionOffset);

        // element.localPositionOffset = EditorGUILayout.Vector3Field("Local Pos Offset", element.localPositionOffset);
        // element.localRotationOffset = EditorGUILayout.Vector3Field("Local Rot Offset", element.localRotationOffset);

        EditorGUILayout.Space();

        element.posOffsetMin = EditorGUILayout.Vector3Field("Pos Offset Min", element.posOffsetMin);
        element.posOffsetMax = EditorGUILayout.Vector3Field("Pos Offset Max", element.posOffsetMax);

        EditorGUILayout.Space();
        element.rotOffsetMin = EditorGUILayout.Vector3Field("Ros Offset Min", element.rotOffsetMin);
        element.rotOffsetMax = EditorGUILayout.Vector3Field("Rot Offset Max", element.rotOffsetMax);


        EditorGUILayout.Space();

        element.sizeMultiplierRange = EditorGUILayout.Vector2Field("Size Multiplier Range", element.sizeMultiplierRange);
        // element.randomizeSize = EditorGUILayout.Toggle("Random Size", element.randomizeSize);
        // if (element.randomizeSize) {
        // }

        EditorGUILayout.Space();

        element.alignNormal = EditorGUILayout.Toggle("Align To Normal", element.alignNormal);
        EditorGUILayout.EndVertical();
        EditorGUI.indentLevel--;

        EditorUtility.SetDirty(element);
    }