コード例 #1
0
    void OnGUI()
    {
        GUILayout.Label("Cube Net Exporter", EditorStyles.boldLabel);
        myString       = EditorGUILayout.TextField("Net Name", myString);
        selectedSprite = (Sprite)EditorGUILayout.ObjectField("Sprite", selectedSprite, typeof(Sprite), true);
        if (GUILayout.Button("Export Selection"))
        {
            GameObject[] selection = GameObject.FindGameObjectsWithTag("BoxTileAnchor");
            selection_vectors = new Vector3[selection.Length];
            for (int i = 0; i < selection.Length; i++)
            {
                selection_vectors[i] = selection[i].transform.position;
            }
            CubeNet cubeNet = ScriptableObject.CreateInstance <CubeNet>();
            cubeNet.netName         = myString;
            cubeNet.vectors         = selection_vectors;
            cubeNet.thumbnailSprite = selectedSprite;
            string path             = "Assets/CubeNets";
            string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path + "/" + myString + ".asset");

            AssetDatabase.CreateAsset(cubeNet, assetPathAndName);

            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            EditorUtility.FocusProjectWindow();
            Selection.activeObject = cubeNet;
        }
    }
コード例 #2
0
    private static CubeNet[] GetAllCubeNets()
    {
        List <CubeNet> cubeNets = new List <CubeNet>();

        string[] guids;
        guids = AssetDatabase.FindAssets("t:CubeNet");
        foreach (string guid in guids)
        {
            string  path    = AssetDatabase.GUIDToAssetPath(guid);
            CubeNet cubeNet = (CubeNet)AssetDatabase.LoadAssetAtPath(path, typeof(CubeNet));
            cubeNets.Add(cubeNet);
        }
        return(cubeNets.ToArray());
    }
コード例 #3
0
ファイル: CubeNet.cs プロジェクト: carlberube/TestRollingCube
    static void ItemOnGUI(string guid, Rect rect)
    {
        string assetPath = AssetDatabase.GUIDToAssetPath(guid);

        CubeNet obj = AssetDatabase.LoadAssetAtPath(assetPath, typeof(CubeNet)) as CubeNet;

        if (obj != null)
        {
            Sprite sprite         = obj.thumbnailSprite;
            var    croppedTexture = new Texture2D((int)sprite.rect.width, (int)sprite.rect.height);
            var    pixels         = sprite.texture.GetPixels((int)sprite.textureRect.x,
                                                             (int)sprite.textureRect.y,
                                                             (int)sprite.textureRect.width,
                                                             (int)sprite.textureRect.height);
            croppedTexture.SetPixels(pixels);
            croppedTexture.Apply();
            rect.width = rect.height;
            GUI.DrawTexture(rect, croppedTexture);
        }
    }
コード例 #4
0
    void CreateCubeNet(CubeNet cubeNet)
    {
        if (levelScene.IsValid())
        {
            new_scene = levelScene;
        }
        if (!new_scene.IsValid())
        {
            new_scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Additive);
        }
        EditorSceneManager.SetActiveScene(new_scene);
        string label = cubeNet.name;

        while (labelForCubeNetObject.ContainsKey(label))
        {
            int index = 1;
            label = label + "_" + index.ToString();
            index++;
        }

        GameObject parentGameObject = new GameObject();

        parentGameObject.AddComponent <EditModeSnapController>();
        parentGameObject.name = label;
        foreach (Vector3 pos in cubeNet.vectors)
        {
            GameObject tileAnchor = (GameObject)PrefabUtility.InstantiatePrefab(tileAnchorPrefab);
            tileAnchor.transform.SetPositionAndRotation(pos, Quaternion.identity);
            tileAnchor.transform.SetParent(parentGameObject.transform);
        }
        labelForCubeNetObject[label] = parentGameObject;
        GameObject[] selection = new GameObject[1];
        selection[0]      = parentGameObject;
        Selection.objects = selection;
        EditorSceneManager.SetActiveScene(activeScene);
    }
コード例 #5
0
ファイル: Program.cs プロジェクト: CarlosX/cubenet
 public void _OnClientConnect(ref object de, CubeNet.Systems.Client net)
 {
     LogConsole.Show("Client Connect!");
     de = new Systems(net);
 }