Example #1
0
        /// <summary>
        /// 加载解决方案
        /// </summary>
        /// <param name="modle"></param>
        public void LoadSolution(Modle modle)
        {
            GameObject m_Model = Instantiate(Resources.Load("Model/" + modle.modleName) as GameObject);

            m_Model.name = modle.modleName;
            m_Model.transform.position = Util.Vector3dToVector3(modle.position);
            m_Model.transform.rotation = Quaternion.Euler(modle.rotation.x, modle.rotation.y, modle.rotation.z);
            m_Model.AddComponent <ExposeToEditor>();

            modelDic.Add(m_Model, modle);
            solutionInfo.equipmentList.Add(modle);
        }
Example #2
0
        public void Exec(string cmd)
        {
            cmd = cmd.ToLower();
            GameObject go = null;

            switch (cmd)
            {
            case "createempty":
                go      = new GameObject();
                go.name = "Empty";
                break;

            case "createemptychild":
                go      = new GameObject();
                go.name = "Empty";
                IRuntimeSelection selection = m_editor.Selection;
                go.transform.SetParent(selection.activeTransform, false);
                break;

            case "cube":
                go = GameObject.CreatePrimitive(PrimitiveType.Cube);
                go.GetComponent <Renderer>().sharedMaterial = m_defaultMaterial;
                break;

            case "sphere":
                go = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                go.GetComponent <Renderer>().sharedMaterial = m_defaultMaterial;
                break;

            case "capsule":
                go = GameObject.CreatePrimitive(PrimitiveType.Capsule);
                go.GetComponent <Renderer>().sharedMaterial = m_defaultMaterial;
                break;

            case "cylinder":
                go = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
                go.GetComponent <Renderer>().sharedMaterial = m_defaultMaterial;
                break;

            case "plane":
                go = GameObject.CreatePrimitive(PrimitiveType.Plane);
                go.GetComponent <Renderer>().sharedMaterial = m_defaultMaterial;
                break;

            case "quad":
                go = GameObject.CreatePrimitive(PrimitiveType.Quad);
                go.GetComponent <Renderer>().sharedMaterial = m_defaultMaterial;
                break;

            case "directionallight":
            {
                go      = new GameObject();
                go.name = "Directional Light";
                Light light = go.AddComponent <Light>();
                light.type = LightType.Directional;
            }
            break;

            case "pointlight":
            {
                go      = new GameObject();
                go.name = "Point Light";
                Light light = go.AddComponent <Light>();
                light.type = LightType.Point;
            }
            break;

            case "spotlight":
            {
                go      = new GameObject();
                go.name = "Spot Light";
                Light light = go.AddComponent <Light>();
                light.type = LightType.Point;
            }
            break;

            case "camera":
            {
                go = new GameObject();
                go.SetActive(false);
                go.name = "Camera";
                go.AddComponent <Camera>();
                go.AddComponent <GameViewCamera>();
            }
            break;

                #region Imp
            case "机器人":
                go      = Instantiate(Resources.Load("Model/" + cmd) as GameObject);
                go.name = cmd;
                break;

            case "总控":
                go      = Instantiate(Resources.Load("Model/" + cmd) as GameObject);
                go.name = cmd;
                break;

            case "总控电气柜":
                go      = Instantiate(Resources.Load("Model/" + cmd) as GameObject);
                go.name = cmd;
                break;

            case "抽拉底座":
                go      = Instantiate(Resources.Load("Model/" + cmd) as GameObject);
                go.name = cmd;
                break;

            case "立体库":
                go      = Instantiate(Resources.Load("Model/" + cmd) as GameObject);
                go.name = cmd;
                break;

            case "车床":
                go      = Instantiate(Resources.Load("Model/" + cmd) as GameObject);
                go.name = cmd;
                break;

            case "输送机":
                go      = Instantiate(Resources.Load("Model/" + cmd) as GameObject);
                go.name = cmd;
                break;

            case "铣床":
                go      = Instantiate(Resources.Load("Model/" + cmd) as GameObject);
                go.name = cmd;
                break;
                #endregion
            }

            if (go != null)
            {
                Vector3     pivot      = Vector3.zero;
                IScenePivot scenePivot = GetScenePivot();
                if (scenePivot != null)
                {
                    pivot = scenePivot.SecondaryPivot;
                }
                go.transform.position = pivot;
                go.AddComponent <ExposeToEditor>();

                Modle equipment = new Modle()
                {
                    modleName = go.name,
                    position  = Util.Vector3ToVector3d(go.transform.position),
                    rotation  = Util.Vector3ToVector3d(go.transform.localRotation.eulerAngles)
                };
                //go.AddComponent<Equipment>();

                go.SetActive(true);
                m_editor.RegisterCreatedObjects(new[] { go });

                RuntimeEditor.modelDic.Add(go, equipment);
                RuntimeEditor.solutionInfo.equipmentList.Add(equipment);
            }
        }