コード例 #1
0
    static void Init()
    {
        // Get existing open window or if none, make a new one:
        ReplaceWithPrefab window = (ReplaceWithPrefab)EditorWindow.GetWindow(typeof(ReplaceWithPrefab));

        window.Show();
    }
コード例 #2
0
    private void ReplaceWithPrefabCallback(object GuidObject)
    {
        string     guid   = (string)GuidObject;
        GameObject prefab = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid), typeof(Object)) as GameObject;

        ReplaceWithPrefab.Replace(prefab);
    }
コード例 #3
0
    static void ReplaceMenuItem()
    {
        // Get existing open window or if none, make a new one:
        ReplaceWithPrefab window = (ReplaceWithPrefab)GetWindow(typeof(ReplaceWithPrefab));

        window.Show();
    }
コード例 #4
0
    [MenuItem("Tools/Replace with Prefab")]    //[MenuItem("Tools/Community/Replace with Prefab")]
    static void StartWindow()
    {
        ReplaceWithPrefab window = (ReplaceWithPrefab)GetWindow(typeof(ReplaceWithPrefab));

        window.Show();

        window.titleContent = new GUIContent("Replace with Prefab");
        window.minSize      = window.windowMinSize;
        window.maxSize      = window.windowMaxSize;
    }
コード例 #5
0
    private void DrawToolbar(Event current)
    {
        GUILayout.BeginArea(topToolbarRect, new GUIStyle("Toolbar"));
        EditorGUILayout.BeginHorizontal();
        //labels
        if (GUILayout.Button(new GUIContent("Labels"), "ToolbarDropDown"))
        {
            GenericMenu lablesMenu = new GenericMenu();
            GenerateLabelsMenu(lablesMenu);
            lablesMenu.ShowAsContext();
        }
        //replace
        GUI.enabled = Selection.GetFiltered(typeof(GameObject), SelectionMode.ExcludePrefab).Cast <GameObject>().Any();
        if (GUILayout.Button(new GUIContent("Replace", "Replace selected instance with the selected prefab"), "ToolbarButton"))
        {
            ReplaceWithPrefab.Replace();
        }
        GUI.enabled = true;
        //settings
        if (GUILayout.Button(new GUIContent("Settings"), "ToolbarDropDown"))
        {
            GenericMenu settingsMenu = new GenericMenu();
            GenerateSettingsMenu(settingsMenu);
            settingsMenu.ShowAsContext();
        }
        EditorGUILayout.Space();
        GUIContent content = EditorGUIUtility.IconContent(settings.pivot ? "ToolHandlePivot" : "ToolHandleCenter");

        content.text = settings.pivot ? "Pivot" : "Center";
        if (GUILayout.Button(content, "ToolbarButton", GUILayout.Width(70)))
        {
            settings.pivot = !settings.pivot;
        }
        content                = EditorGUIUtility.IconContent("renderdoc");
        content.text           = "Surface";
        content.tooltip        = "Snap prefabs to the placing surface";
        settings.followSurface = GUILayout.Toggle(settings.followSurface, content, "ToolbarButton", GUILayout.Width(80));

        content         = EditorGUIUtility.IconContent("Toolbar Plus");
        content.text    = "Paint";
        content.tooltip = "Paint in the scene view with the selected prefab";
        settings.paint  = GUILayout.Toggle(settings.paint, content, "ToolbarButton", GUILayout.Width(80));
        GUILayout.FlexibleSpace();
        EditorGUI.BeginChangeCheck();
        settings.prefabElementSizeMultiply = EditorGUILayout.Slider(settings.prefabElementSizeMultiply, 0.5f, 1f, GUILayout.Width(128));
        settings.search = SearchField(GUIContent.none, settings.search, GUILayout.Height(EditorGUIUtility.singleLineHeight));
        if (EditorGUI.EndChangeCheck())
        {
            LoadPrefabInfos();
        }
        EditorGUILayout.EndHorizontal();
        GUILayout.EndArea();
    }