public Vector3 getActiveCameraPosition()
 {
     if (CameraList == null)
     {
         WarningSystem.addWarning("Null camera list", "Attempt to get active camera POSITION failed", Code.Error);
         return(Vector3.zero);
     }
     return(CameraList[1].gameObject.transform.position);
 }
    public void setActiveCameraPosition(Vector3 newPosition)
    {
        if (CameraList == null)
        {
            WarningSystem.addWarning("Null camera list", "Restoring Camera Position Failed", Code.Error);
            return;
        }

        CameraList[1].gameObject.transform.position = newPosition;
    }
    public void setActiveCameraRotation(Quaternion newRotation)
    {
        if (CameraList == null)
        {
            WarningSystem.addWarning("Null camera list", "Restoring Camera Rotation Failed", Code.Error);
            return;
        }

        CameraList[1].gameObject.transform.rotation = newRotation;
    }
    public Quaternion getActiveCameraRotation()
    {
        if (CameraList == null)
        {
            WarningSystem.addWarning("Null camera list", "Attempt to get active camera ROTATION failed", Code.Error);
            return(Quaternion.identity);
        }

        return(CameraList[1].gameObject.transform.rotation);
    }
Exemplo n.º 5
0
    private void saveNewPathData(PathData data)
    {
        WarningSystem.addWarning("Attempt to Save Pathdata", "Shouldn't be called in render", Code.Error);

        /*
         * XmlSerializer serializer = new XmlSerializer(typeof(PathData));
         * //string exeFolder = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
         * TextWriter textWriter = new StreamWriter(activeProject.projectFolderPath + "\\paths\\" + data.pathName + ".xml");
         * serializer.Serialize(textWriter, data);
         * textWriter.Close();
         */
    }
 public void removeItem(string aName)
 {
     //Check if we have it already then remove
     if (fileNames.Contains(aName))
     {
         //Remove Logic
     }
     else
     {
         WarningSystem.addWarning("Removal request failed", "Attempted to remove item that was a member of collection", Code.Warning);
     }
 }
Exemplo n.º 7
0
        public override void ProcessPacket(WarningSignalPacket packet, NebulaConnection conn)
        {
            WarningSystem ws = GameMain.data.warningSystem;

            Array.Clear(ws.warningCounts, 0, ws.warningCounts.Length);
            Array.Clear(ws.warningSignals, 0, ws.warningSignalCount);

            ws.warningSignalCount = packet.SignalCount;
            for (int i = 0; i < packet.SignalCount; i++)
            {
                int signalId = packet.Signals[i];
                ws.warningSignals[i]       = signalId;
                ws.warningCounts[signalId] = packet.Counts[i];
            }

            Multiplayer.Session.Warning.TickSignal = packet.Tick;
        }
Exemplo n.º 8
0
    // Use this for initialization
    void Start()
    {
        string path             = Application.dataPath + "\\projects\\";
        bool   previousProjects = DirectoryUtil.AssertDirectoryExistsOrRecreate(path);

        if (previousProjects)
        {
            DirectoryInfo[] subDirs = DirectoryUtil.getSubDirectoriesByParent(path);
            foreach (DirectoryInfo info in subDirs)
            {
                ProjectData newProject = new ProjectData();
                newProject.projectFolderPath = info.FullName;
                print("exists");
                WarningSystem.addWarning("Project Found", "Path:" + newProject.projectFolderPath, Code.Info);
            }
        }
    }
    private void copyKeys()
    {
        //UpdateKeyInfoList();

        if (selectedKeys.Count == 0)
        {
            WarningSystem.addWarning("Copy Frames", "No key frames to copy", Code.Info);
            return;
        }
        copiedKeys = new List <int>();
        for (int i = 0; i < selectedKeys.Count; i++)
        {
            copiedKeys.Add(selectedKeys[i]);
        }
        ifCopied = true;
        WarningSystem.addWarning("Copy Frames", "Selected frames have been copied", Code.Info);
    }
    public static DirectoryInfo[] getSubDirectoriesByParent(string directoryPath)
    {
        DirectoryInfo dir = new DirectoryInfo(directoryPath);

        DirectoryInfo[] subDirs = null;
        try
        {
            if (dir.Exists)
            {
                subDirs = dir.GetDirectories();
                return(subDirs);
            }
        }
        catch (Exception e)
        {
            Debug.Log(e);
            WarningSystem.addWarning("SubDirectory Error", "Error searching supplied path for subdirectories", Code.Error);
        }

        return(subDirs);
    }
    private void pasteKeys()
    {
        int diff = Mathf.Abs(startFrame - copiedKeys[0]);

        switch (checkFrames())
        {
        case 1:
            WarningSystem.addWarning("Paste frames", "Select keyframes with Shift key \tand click 'copy' button before paste it", Code.Info);
            return;

        case 2:
            WarningSystem.addWarning("Paste frames", "Not enough space(free frames) to paste copied frames", Code.Info);
            return;

        default:
            break;
        }

        //paste frames

        for (int i = 0; i < keyInfo.Count; i++)
        {
            for (int j = 0; j < copiedKeys.Count; j++)
            {
                if (i == copiedKeys[j] && keyInfo[i].isKeyed)
                {
                    //currentFrame = diff+i;
                    //setKey ();
                    duplicateKeys(i, diff + i);
                }
            }
        }

        InitFrameSelection();
        UpdateKeyInfoList();
    }
Exemplo n.º 12
0
    void OnGUI()
    {
        if (isInitialized)
        {
            GUI.skin  = GuiManager.GetSkin();
            GUI.depth = 3;

            if (isDisplayingPrompt)
            {
                GUI.enabled = false;
            }

            GUI.BeginGroup(new Rect(Screen.width / 2 - 250, Screen.height / 2 - 300, 500, 600));
            // All rectangles are now adjusted to the group. (0,0) is the topleft corner of the group.

            // We'll make a box so you can see where the group is on-screen.
            GUI.Box(new Rect(0, 0, 500, 600), "Project Editor: " + activeProject.projectName);

            GUI.Label(new Rect(35, 25, 360, 30), "Tank:   Warning:Numbers only");

            // Unity textfields work by assigning a value on return, without the assignment they are uneditable
            // Decided to parse them back to floats on the fly.

            //TODO: Limit to only number input Regex.Replace(text, @"[^0-9 ]", "");
            GUI.Label(new Rect(35, 50, 100, 30), "Width(MM) : ");
            activeProject.tankDimensions.x = float.Parse(GUI.TextField(new Rect(150, 50, 100, 25), activeProject.tankDimensions.x.ToString()));
            GUI.Label(new Rect(35, 75, 100, 30), "Height(MM): ");
            activeProject.tankDimensions.y = float.Parse(GUI.TextField(new Rect(150, 75, 100, 25), activeProject.tankDimensions.y.ToString()));
            GUI.Label(new Rect(35, 100, 100, 30), "Depth(MM) : ");
            activeProject.tankDimensions.z = float.Parse(GUI.TextField(new Rect(150, 100, 100, 25), activeProject.tankDimensions.z.ToString()));

            GUI.Label(new Rect(290, 25, 180, 30), "Background Color");
            GUI.Label(new Rect(295, 50, 30, 30), "R");
            activeProject.backgroundR = int.Parse(GUI.TextField(new Rect(330, 50, 35, 25), activeProject.backgroundR.ToString()));

            GUI.Label(new Rect(295, 75, 30, 30), "G");
            activeProject.backgroundG = int.Parse(GUI.TextField(new Rect(330, 75, 35, 25), activeProject.backgroundG.ToString()));

            GUI.Label(new Rect(295, 100, 30, 30), "B");
            activeProject.backgroundB = int.Parse(GUI.TextField(new Rect(330, 100, 35, 25), activeProject.backgroundB.ToString()));


            GUI.Label(new Rect(35, 140, 100, 30), "Fish Models : ");
            fishModelScrollVector = GUI.BeginScrollView(new Rect(15, 160, 220, 120), fishModelScrollVector, new Rect(0, 0, 200, 150));

            activeProject.type = GUILayout.SelectionGrid(activeProject.type, getPossibleFishModels(), 1, "toggle");

            //selectedModelIndex =
            GUI.EndScrollView();


            GUI.Label(new Rect(260, 140, 100, 30), "Fish Paths : ");
            fishPathsScrollVector = GUI.BeginScrollView(new Rect(260, 155, 220, 120), fishPathsScrollVector, new Rect(0, 0, 200, 150));
            pathNames.render();

            GUI.EndScrollView();

            if (GUI.Button(new Rect(260, 290, 80, 32), "New Path"))
            {
                PlayerPrefs.SetInt("FishType", activeProject.type);
                isDisplayingPrompt = true;
                //Application.LoadLevel(1);
                //GameRegistry activeRegistry = gameObject.GetComponent<GameRegistry>();
                //activeRegistry.switchState(States.AnimationEditor);
                //WarningSystem.addWarning("Write Failure", "Failed to write path data", Code.Error);
            }

            if (GUI.Button(new Rect(365, 290, 80, 32), "Edit Path"))
            {
                if (pathNames.hasActive())
                {
                    List <string> activePaths = pathNames.getActive();
                    // Check that only one is selected
                    if (activePaths.Count != 1)
                    {
                        WarningSystem.addWarning("Please select a path.", "Please select only a single path for editing", Code.Warning);
                    }
                    else
                    {
                        // Open the path
                        PlayerPrefs.SetInt("FishType", activeProject.type);
                        PlayerPrefs.SetString("PathDir", activePaths[0]);
                        if (tpsNames.hasActive())
                        {
                            List <string> activeMorphs = tpsNames.getActive();
                            if (activeMorphs.Count > 1)
                            {
                                WarningSystem.addWarning("Please select a single TPS", "Please select just one morph for path editing", Code.Warning);
                            }
                            else
                            {
                                if (textureNames.hasActive())
                                {
                                    List <string> activeTextures = textureNames.getActive();
                                    if (activeTextures.Count > 1)
                                    {
                                        WarningSystem.addWarning("Please select a single texture", "Please select a single texture for path editing", Code.Warning);
                                    }
                                    else
                                    {
                                        PlayerPrefs.SetString("MorphPath", activeMorphs[0]);
                                        PlayerPrefs.SetString("TexturePath", activeTextures[0]);
                                        Application.LoadLevel(1);
                                    }
                                }
                                else
                                {
                                    PlayerPrefs.SetString("MorphPath", activeMorphs[0]);
                                    PlayerPrefs.SetString("TexturePath", "default");
                                    Application.LoadLevel(1);
                                }
                            }
                        }
                        else
                        {
                            PlayerPrefs.SetString("TexturePath", "default");
                            PlayerPrefs.SetString("MorphPath", "default");
                            Application.LoadLevel(1);
                        }
                    }
                }
                else
                {
                    WarningSystem.addWarning("Select a path!", "First select an existing path or create a new one.", Code.Warning);
                }
            }

            // End the group we started above. This is very important to remember!


            GUI.Label(new Rect(35, 340, 100, 30), "Textures : ");
            fishTexturesScrollVec = GUI.BeginScrollView(new Rect(15, 355, 220, 120), fishTexturesScrollVec, new Rect(0, 0, 200, 150));
            textureNames.render();
            // Put something inside the ScrollView
            //toggleThree = GUI.Toggle(new Rect(10, 10, 20, 24), toggleThree, ""); GUI.Label(new Rect(35, 10, 100, 24), "need swordtail tps");

            // End the ScrollView
            GUI.EndScrollView();
            //GUI.enabled = false;
            if (GUI.Button(new Rect(25, 500, 100, 32), "Batch Render"))
            {
                // Store FishType
                bool hasRequirementsToRender = true;

                PlayerPrefs.SetInt("FishType", activeProject.type);
                // Check if Paths
                if (pathNames.hasActive())
                {
                    List <string> activePaths = pathNames.getActive();
                    PlayerPrefsX.SetStringArray("PathsDir", activePaths.ToArray());
                }
                else
                {
                    WarningSystem.addWarning("Select a path!", "First select an existing path or create a new one.", Code.Warning);
                    hasRequirementsToRender = false;
                }
                // Check textures
                if (textureNames.hasActive())
                {
                    List <string> activeTextures = textureNames.getActive();
                    PlayerPrefsX.SetStringArray("TexturesDir", activeTextures.ToArray());
                }
                else
                {
                    WarningSystem.addWarning("Select a texture!", "Please select at least one existing texture.", Code.Warning);
                    hasRequirementsToRender = false;
                }

                // Check TPS
                if (tpsNames.hasActive())
                {
                    List <string> activeTPS = tpsNames.getActive();
                    PlayerPrefsX.SetStringArray("TPSDir", activeTPS.ToArray());
                }
                else
                {
                    PlayerPrefsX.SetStringArray("TPSDir", new string[] { "default" });
                }

                // Launch Renderer
                if (hasRequirementsToRender)
                {
                    Application.LoadLevel(2);
                }
            }

            GUI.enabled = true;

            GUI.Label(new Rect(260, 340, 100, 30), "TPS : ");
            tpsTexturesScrollVec = GUI.BeginScrollView(new Rect(260, 355, 220, 120), tpsTexturesScrollVec, new Rect(0, 0, 200, 150));
            tpsNames.render();
            // Put something inside the ScrollView
            //toggleThree = GUI.Toggle(new Rect(10, 10, 20, 24), toggleThree, ""); GUI.Label(new Rect(35, 10, 100, 24), "need swordtail tps");

            // End the ScrollView
            GUI.EndScrollView();



            //GUI.Label(new Rect(260, 480, 100, 30), "Time Dilation: ");

            GUI.Label(new Rect(260, 485, 120, 30), "Frame Rate: ");
            activeProject.dialFrames = int.Parse(GUI.TextField(new Rect(390, 485, 50, 25), activeProject.dialFrames.ToString()));
            GUI.Label(new Rect(260, 510, 120, 30), "Render Every: ");
            activeProject.snapshotPer = int.Parse(GUI.TextField(new Rect(390, 515, 50, 25), activeProject.snapshotPer.ToString()));

            if (GUI.Button(new Rect(250, 550, 220, 32), "Windows Only: Open Project Folder"))
            {
                try{
                    string itemPath = activeProject.projectFolderPath.Replace(@"/", @"\");                       // explorer doesn't like front slashes
                    System.Diagnostics.Process.Start("explorer.exe", "/select," + itemPath);
                }catch
                {
                    WarningSystem.addWarning("Failed to spawn explorer", "Unable to open explorer, are you using a mac?", Code.Error);
                }
            }

            GUI.enabled = true;

            if (isDisplayingPrompt)
            {
                GUI.BeginGroup(new Rect(120, 100, 500, 500));
                GUI.Box(new Rect(30, 80, 190, 180), "Enter Path Name:");

                GUI.SetNextControlName("ProjectPathField");
                pathName = GUI.TextField(new Rect(50, 120, 150, 32), pathName, 40);
                GUI.FocusControl("ProjectPathField");

                if (GUI.Button(new Rect(50, 190, 150, 32), "Ok"))
                {
                    isDisplayingPrompt = false;

                    PlayerPrefs.SetInt("FishType", activeProject.type);
                    PlayerPrefs.SetString("PathDir", activeProject.projectFolderPath + "\\paths\\" + pathName + ".xml");
                    PlayerPrefs.SetString("PathName", pathName);
                    Application.LoadLevel(1);

                    //Directory.CreateDirectory(activeProject.projectFolderPath + "\\paths\\" + pathName);

                    PathData newPathData = new PathData();
                    newPathData.pathName  = pathName;
                    newPathData.keyframes = new List <KeyframeInfo>(0);
                    saveNewPathData(newPathData);
                    //GameRegistry activeRegistry = gameObject.GetComponent<GameRegistry>();
                    //activeRegistry.switchState(States.AnimationEditor);

                    // Create Project Directory and Add to the display list
                }
                GUI.EndGroup();
            }


            GUI.EndGroup();
        }
    }
Exemplo n.º 13
0
 // Use this for initialization
 void Start()
 {
     warningSystem = FindObjectOfType <WarningSystem>();
 }
Exemplo n.º 14
0
    public void LoadFile(string filename)
    {
        string[] lines  = File.ReadAllLines(filename);
        bool     doData = false;

        Vector3[] tmpTpsData  = new Vector3[1];
        int       tpsDataSize = 0;
        int       count       = 1;

        try{
            foreach (string line in lines)
            {
                //added Chengde two lines, 06062013
                if (line == "")         //sometimes tps file will contain nothing every the other line due to users' mis-operation of tps file generation.
                {
                    continue;
                }

                if (line.StartsWith("LM="))
                {
                    tpsDataSize = int.Parse(line.Remove(0, 3));
                    doData      = true;
                    tmpTpsData  = new Vector3[tpsDataSize + 1];
                }
                else if (line.StartsWith("IMAGE="))
                {
                    doData = false;
                }
                else if (line.StartsWith("SCALE="))
                {
                    scale = float.Parse(line.Remove(0, 6)) * ScaleConvert;
                }

                else if (doData)
                {
                    if (count <= tpsDataSize)
                    {
                        string[] points = line.Split(' ');
                        float    x      = 0;
                        float    z      = float.Parse(points[0]);
                        float    y      = float.Parse(points[1]);
                        tmpTpsData[count] = new Vector3(x, y, z);
                        //print (tmpTpsData[count]);
                        count++;
                    }
                }
            }
        }catch (Exception e)
        {
            WarningSystem.addWarning(e.Message, "Error Parsing Swordtail Morph, only single spaces?", Code.Error);
            Console.WriteLine("{0} Exception caught.", e);
        }
        Vector3[] newTpsPoint = new Vector3[tpsDataSize + 1];
        for (int i = 1; i <= tpsDataSize; i++)
        {
            if (tmpTpsData[1].y < tmpTpsData[2].y)
            {
                newTpsPoint[i].y = (tmpTpsData[i].y - tmpTpsData[1].y) * scale;
            }
            else
            {
                newTpsPoint[i].y = (tmpTpsData[1].y - tmpTpsData[i].y) * scale;
            }


            if (tmpTpsData[1].z > tmpTpsData[16].z)
            {
                newTpsPoint[i].z = (tmpTpsData[1].z - tmpTpsData[i].z) * scale;
            }
            else
            {
                newTpsPoint[i].z = (tmpTpsData[i].z - tmpTpsData[1].z) * scale;
            }
        }
        tpsData = newTpsPoint;
    }
Exemplo n.º 15
0
    void OnGUI()
    {
        //if(mySkin != null)
        GUI.skin = GuiManager.GetSkin();

        // Launch Screen
        GUI.BeginGroup(new Rect(Screen.width / 2 - 75, Screen.height / 2 - 150, 250, 350));
        // All rectangles are now adjusted to the group. (0,0) is the topleft corner of the group.

        // We'll make a box so you can see where the group is on-screen.
        GUI.Box(new Rect(0, 0, 250, 350), "Anyfish Editor");
        if (GUI.Button(new Rect(65, 40, 120, 32), "New Project"))
        {
            Directory.CreateDirectory(Application.dataPath + "\\projects\\test\\");
            WarningSystem.addWarning("New Project Folder", "New path:", Code.Info);
        }
        GUI.Button(new Rect(65, 80, 120, 32), "Load Project");


        scrollViewVector = GUI.BeginScrollView(new Rect(15, 140, 220, 120), scrollViewVector, new Rect(0, 0, 200, 150));

        // Put something inside the ScrollView
        toggleTxt = GUI.Toggle(new Rect(10, 10, 20, 24), toggleTxt, ""); GUI.Label(new Rect(35, 10, 100, 24), "Stickleback");
        toggleTwo = GUI.Toggle(new Rect(10, 40, 20, 24), toggleTwo, ""); GUI.Label(new Rect(35, 40, 100, 24), "Swordtail");
        toggleTwo = GUI.Toggle(new Rect(10, 70, 20, 24), toggleTwo, ""); GUI.Label(new Rect(35, 70, 100, 24), "Blinky");
        toggleTwo = GUI.Toggle(new Rect(10, 100, 20, 24), toggleTwo, ""); GUI.Label(new Rect(35, 100, 100, 24), "Loop Example");
        // End the ScrollView
        GUI.EndScrollView();

        // End the group we started above. This is very important to remember!
        GUI.EndGroup();


        /*
         * GUI.depth = 3;
         * GUI.BeginGroup (new Rect (Screen.width / 2 - 250, Screen.height / 2 - 300, 500, 600));
         * // All rectangles are now adjusted to the group. (0,0) is the topleft corner of the group.
         *
         * // We'll make a box so you can see where the group is on-screen.
         * GUI.Box (new Rect (0,0,500,600), "Project Editor");
         *
         * GUI.Label(new Rect(35, 25, 100, 30), "Tank: ");
         *
         * GUI.Label(new Rect(35, 50, 100, 30), "Width(MM) : ");
         * GUI.TextField(new Rect(110, 50, 100, 25), "1000");
         * GUI.Label(new Rect(35, 75, 100, 30), "Height(MM): ");
         * GUI.TextField(new Rect(110, 75, 100, 25), "700");
         * GUI.Label(new Rect(35, 100, 100, 30), "Depth(MM) : ");
         * GUI.TextField(new Rect(110, 100, 100, 25), "1400");
         *
         * //GUI.Button (new Rect (65,40,120,32), "New Project");
         * //GUI.Button (new Rect (65,80,120,32), "Load Project");
         *
         * GUI.Label(new Rect(35, 140, 100, 30), "Fish Models : ");
         * scrollViewVector = GUI.BeginScrollView (new Rect (15, 155, 220, 120), scrollViewVector, new Rect (0, 0, 200, 150));
         *
         * // Put something inside the ScrollView
         *      toggleTwo = GUI.Toggle(new Rect(10, 10, 20, 24), toggleTwo, ""); GUI.Label(new Rect(35, 10, 100, 24), "Jacob Park");
         *      toggleTxt = GUI.Toggle(new Rect(10, 40, 20, 24), toggleTxt, ""); GUI.Label(new Rect(35, 40, 100, 24), "Consensus");
         * toggleTwo = GUI.Toggle(new Rect(10, 70, 20, 24), toggleTwo, ""); GUI.Label(new Rect(35, 70, 100, 24), "Distorted Test");
         * toggleTwo = GUI.Toggle(new Rect(10, 100, 20, 24), toggleTwo, ""); GUI.Label(new Rect(35, 100, 100, 24), "Oyster");
         * // End the ScrollView
         * GUI.EndScrollView();
         *
         *
         * GUI.Label(new Rect(260, 140, 100, 30), "Fish Paths : ");
         * scrollViewVector2 = GUI.BeginScrollView (new Rect (260, 155, 220, 120), scrollViewVector2, new Rect (0, 0, 200, 150));
         *
         * // Put something inside the ScrollView
         *      toggleThree = GUI.Toggle(new Rect(10, 10, 20, 24), toggleThree, ""); GUI.Label(new Rect(35, 10, 100, 24), "Zig Zag");
         *      toggleTwo = GUI.Toggle(new Rect(10, 40, 20, 24), toggleTwo, ""); GUI.Label(new Rect(35, 40, 100, 24), "Loop");
         * toggleThree = GUI.Toggle(new Rect(10, 70, 20, 24), toggleThree, ""); GUI.Label(new Rect(35, 70, 100, 24), "Nest Point");
         * toggleThree = GUI.Toggle(new Rect(10, 100, 20, 24), toggleThree, ""); GUI.Label(new Rect(35, 100, 100, 24), "Idle Wander");
         * // End the ScrollView
         * GUI.EndScrollView();
         *
         * GUI.Button (new Rect (260,290,80,32), "New Path");
         * GUI.Button (new Rect (365,290,80,32), "Edit Path");
         *
         * // End the group we started above. This is very important to remember!
         *
         *
         * GUI.Label(new Rect(35, 340, 100, 30), "Textures : ");
         * scrollViewVector2 = GUI.BeginScrollView (new Rect (15, 355, 220, 120), scrollViewVector2, new Rect (0, 0, 200, 150));
         *
         * // Put something inside the ScrollView
         *      toggleThree = GUI.Toggle(new Rect(10, 10, 20, 24), toggleThree, ""); GUI.Label(new Rect(35, 10, 100, 24), "1164");
         *      toggleThree = GUI.Toggle(new Rect(10, 40, 20, 24), toggleThree, ""); GUI.Label(new Rect(35, 40, 100, 24), "1169");
         * toggleThree = GUI.Toggle(new Rect(10, 70, 20, 24), toggleThree, ""); GUI.Label(new Rect(35, 70, 100, 24), "1171");
         * toggleThree = GUI.Toggle(new Rect(10, 100, 20, 24), toggleThree, ""); GUI.Label(new Rect(35, 100, 100, 24), "1175");
         * // End the ScrollView
         * GUI.EndScrollView();
         *
         * GUI.Button (new Rect (25,500,100,32), "Batch Render");
         * // End the group we started above. This is very important to remember!
         *
         * GUI.Label(new Rect(260, 340, 100, 30), "Time Dialation: ");
         *
         * GUI.Label(new Rect(260, 365, 120, 30), "Dialation frames : ");
         * GUI.TextField(new Rect(370, 365, 50, 25), "16");
         * GUI.Label(new Rect(260, 390, 120, 30), "Render Every: ");
         * GUI.TextField(new Rect(370, 390, 50, 25), "4");
         *
         *
         *
         * GUI.EndGroup ();
         */
    }
Exemplo n.º 16
0
    void OnGUI()
    {
        //GuiManager guiManager = GameObject.Find("GuiManagerObject").GetComponent<GuiManager>();
        GUI.skin  = GuiManager.GetSkin();
        GUI.depth = 10;
        // Launch Screen
        GUI.BeginGroup(new Rect(Screen.width / 2 - 175, Screen.height / 2 - 250, 250, 380));
        // All rectangles are now adjusted to the group. (0,0) is the topleft corner of the group.

        // We'll make a box so you can see where the group is on-screen.
        GUI.Box(new Rect(0, 0, 250, 380), "Anyfish Editor");


        if (GUI.Button(new Rect(65, 40, 120, 32), "New Project"))
        {
            isDisplayingNamePrompt = true;
        }


        if (GUI.Button(new Rect(65, 80, 120, 32), "Load Project"))
        {
            if (projectSelectionIndex != -1)
            {
                GameRegistry activeRegistry = gameObject.GetComponent <GameRegistry>();
                activeRegistry.activeProjectDirectory = projects[projectSelectionIndex].projectFolderPath;
                activeRegistry.switchState(States.ProjectEditor);
            }
            else
            {
                WarningSystem.addWarning("Select a Project", "Please selection a project before loading.", Code.Warning);
            }
        }

        if (isDisplayingNamePrompt)
        {
            GUI.enabled = false;
        }
        scrollViewVector = GUI.BeginScrollView(new Rect(15, 140, 220, 120), scrollViewVector, new Rect(0, 0, 200, 1000));

        projectSelectionIndex = GUILayout.SelectionGrid(projectSelectionIndex, getProjectNames(), 1, "toggle");


        // End the ScrollView
        GUI.EndScrollView();
        GUI.enabled = true;
        if (isDisplayingNamePrompt)
        {
            GUI.Box(new Rect(30, 80, 190, 180), "Enter Project Name:");

            GUI.SetNextControlName("ProjectNameField");
            projectName = GUI.TextField(new Rect(50, 120, 150, 32), projectName, 40);
            GUI.FocusControl("ProjectNameField");

            if (GUI.Button(new Rect(50, 190, 150, 32), "Ok"))
            {
                isDisplayingNamePrompt = false;

                // Create Project Directory and Add to the display list
                Directory.CreateDirectory(Application.dataPath + "\\projects\\" + projectName);
                ProjectData newProject = new ProjectData();

                //Creates a relative path for the project which is used in the xml file later. (Mohammad)
                string relative = "";
                if (Directory.Exists(Application.dataPath))
                {
                    string p        = Application.dataPath;
                    string parpath1 = Directory.GetParent(Application.dataPath).FullName;
                    string parpath2 = Directory.GetParent(parpath1).FullName;
                    string parpath3 = Directory.GetParent(parpath2).FullName;
                    relative = "../../" + Application.dataPath.Remove(0, parpath3.Length) + "\\projects\\" + projectName;
                }


                //newProject.projectFolderPath = Application.dataPath + "\\projects\\" + projectName;
                newProject.projectFolderPath = relative;
                newProject.projectName       = projectName;
                newProject.tankDimensions.x  = 1000;
                newProject.tankDimensions.z  = 700;
                newProject.tankDimensions.y  = 1000;
                createDirectoryIfItDoesntExist("tps", newProject.projectFolderPath);
                createDirectoryIfItDoesntExist("fins", newProject.projectFolderPath);
                createDirectoryIfItDoesntExist("textures", newProject.projectFolderPath);
                createDirectoryIfItDoesntExist("paths", newProject.projectFolderPath);
                Debug.Log("Project path: " + newProject.projectFolderPath);
                saveNewProjectData(newProject);
                projects.Add(newProject);
                WarningSystem.addWarning("New Project Folder", "New path:" + newProject.projectFolderPath, Code.Info);
            }
        }
        if (GUI.Button(new Rect(65, 290, 120, 32), "About"))
        {
            WarningSystem.addWarning("Version Info", "Version: 1.1 \t\tReleased: Jan 1, 2014 \nUpdates: Keyframe multi-selection, version info etc. ", Code.Info);
        }
        // End the group we started above. This is very important to remember!
        GUI.EndGroup();
    }
    public void OnMouseClick()
    {
        if (containingRect.Contains(Event.current.mousePosition))
        {
            Vector2 mosPos = new Vector2(Event.current.mousePosition.x - containingRect.x + scrollViewVector.x, Event.current.mousePosition.y - containingRect.y);
            Debug.Log("InsideTest");
            for (int i = 0; i < keys.Count; i++)
            {
                if ((keys[i] as KeyframeTexture).contains(mosPos))
                {
                    Event e = Event.current;
                    if (e.shift)
                    {
                        //Only works one keyframes
                        if (keyInfo[startFrame].isKeyed == false || keyInfo[i].isKeyed == false)
                        {
                            WarningSystem.addWarning("Warning", "Only keyframes should be selected", Code.Info);
                            startFrame = i;
                            return;
                        }
                        if (startFrame > i)
                        {
                            WarningSystem.addWarning("Warning", "Select frames from left to right", Code.Info);
                            startFrame = i;
                            break;
                        }
                        endFrame = i;
                        WarningSystem.addWarning("Select Frames", "Frame " + startFrame + " to " + endFrame + " is selected.", Code.Info);


                        selectedKeys.Clear();
                        int cnt = 0;
                        foreach (KeyframeTexture key in keys)
                        {
                            if (cnt >= startFrame && cnt <= endFrame)
                            {
                                selectedKeys.Add(cnt);
                            }

                            cnt++;
                        }

                        startFrame = i;
                    }
                    else if (e.control)
                    {
                        //Only works one keyframes
                        if (keyInfo[startFrame].isKeyed == false || keyInfo[i].isKeyed == false)
                        {
                            WarningSystem.addWarning("Select Frames", "Only keyframes should be selected", Code.Info);
                            startFrame = i;
                            return;
                        }

                        int cnt = 0;
                        foreach (KeyframeTexture key in keys)
                        {
                            if (cnt == i)
                            {
                                selectedKeys.Add(cnt);
                                break;
                            }
                            cnt++;
                        }

                        startFrame = i;
                    }
                    else
                    {
                        selectedKeys.Clear();
                        selectedKeys.Add(i);

                        startFrame = i;
                        gotoFrame(i);
                        Messenger <int> .Broadcast("SetTextureByFrame", i);
                    }
                    selectedKeys.Sort();
                    UpdateSelectedKeys();
                }
            }
        }
    }