Пример #1
0
 public LoadedScene(ISceneController controller, SceneModel model, GameObject sceneRoot, SceneIndex id)
 {
     Controller      = controller;
     Model           = model;
     SceneIdentifier = id;
     Scene           = sceneRoot;
 }
Пример #2
0
 public SceneViewModel(SceneModel model)
 {
     Model       = model;
     Transitions = new List <TransitionViewModel>(Model.Transitions.Select(t => new TransitionViewModel(t, this)));
     OffsetX     = -Width / 2;
     OffsetY     = -Height / 2;
 }
Пример #3
0
        IEnumerator SaveFilesData()
        {
            Debug.Log("Saving...");
            var objsModel = GameManager.Instance.objsScene;
            var models    = new List <Model.Model>();

            objsModel.ForEach(x =>
            {
                models.Add(new Model.Model(x));
            });
            var newScene = new SceneModel()
            {
                Models = models
            };
            var now             = DateTime.Now;
            var fileName        = "save_" + now.Year + now.Month + now.Day + now.Hour + now.Millisecond;
            var jsonFormatScene = new SceneData(newScene);
            var json            = MonoUtils.ConvertToJsonData(jsonFormatScene);

            Debug.Log("Saving... Dir: " + _dirPath + @"/" + fileName + ".json");

            //write string to file
            System.IO.File.WriteAllText(_dirPath + @"/" + fileName + ".json", json);

            GameEvents.OnFilesOpFinished();
            yield return(null);
        }
Пример #4
0
        public JsonResult List()
        {
            var mongo  = new MongoHelper();
            var scenes = mongo.FindAll(Constant.SceneCollectionName);

            var list = new List <SceneModel>();

            foreach (var i in scenes)
            {
                var info = new SceneModel
                {
                    ID             = i["ID"].AsObjectId.ToString(),
                    Name           = i["Name"].AsString,
                    TotalPinYin    = i["TotalPinYin"].ToString(),
                    FirstPinYin    = i["FirstPinYin"].ToString(),
                    CollectionName = i["CollectionName"].AsString,
                    Version        = i["Version"].AsInt32,
                    CreateTime     = i["CreateTime"].ToUniversalTime(),
                    UpdateTime     = i["UpdateTime"].ToUniversalTime(),
                    Thumbnail      = i.Contains("Thumbnail") && !i["Thumbnail"].IsBsonNull ? i["Thumbnail"].ToString() : null
                };
                list.Add(info);
            }

            list = list.OrderByDescending(o => o.UpdateTime).ToList();

            return(Json(new
            {
                Code = 200,
                Msg = "获取成功!",
                Data = list
            }));
        }
        public static SceneModel Create(Scene scene, params string[] availableSceneBehaviors)
        {
            var availableSceneBehaviorNames = availableSceneBehaviors.Select(s => new SceneBehaviorName(s));

            var factoryProvider = Substitute.For <ISceneBehaviorFactoryProvider>();

            factoryProvider.Get(Arg.Any <string>()).ThrowsForAnyArgs(new InvalidOperationException("Missing substitute configuration."));

            foreach (var sceneBehaviorName in availableSceneBehaviors)
            {
                var factory = Substitute.For <ISceneBehaviorFactory>();
                factory.BehaviorName.Returns(sceneBehaviorName);
                factory.Create(scene).Returns(ci =>
                {
                    var sceneBehavior = Substitute.ForPartsOf <SceneBehavior>(scene);
                    sceneBehavior.Name.Returns(sceneBehaviorName);
                    return(sceneBehavior);
                });

                factoryProvider.Configure().Get(sceneBehaviorName).Returns(factory);
            }

            var sceneModel = new SceneModel(scene, availableSceneBehaviorNames, factoryProvider);

            return(sceneModel);
        }
        public SceneViewModel(SceneModel model)
        {
            this.Model = model;
            this.Items = new List <ItemViewModel>();
            foreach (ItemModel item in this.Model.Items)
            {
                switch (item.Type)
                {
                case ItemTypeEnum.Text:
                    this.Items.Add(new TextItemViewModel((TextItemModel)item));
                    break;

                case ItemTypeEnum.Image:
                    this.Items.Add(new ImageItemViewModel((ImageItemModel)item));
                    break;

                case ItemTypeEnum.Sound:
                    this.Items.Add(new SoundItemViewModel((SoundItemModel)item));
                    break;

                case ItemTypeEnum.Video:
                    this.Items.Add(new VideoItemViewModel((VideoItemModel)item));
                    break;
                }
            }
        }
Пример #7
0
        public ActionResult ApplyWithDraw()
        {
            var siteSetting = SiteSettingApplication.SiteSettings;

            if (string.IsNullOrWhiteSpace(siteSetting.WeixinAppId) || string.IsNullOrWhiteSpace(siteSetting.WeixinAppSecret))
            {
                throw new MallException("未配置公众号参数");
            }

            var token = AccessTokenContainer.TryGetAccessToken(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret);

            SceneModel scene = new SceneModel(QR_SCENE_Type.WithDraw)
            {
                Object = CurrentUser.Id.ToString()
            };
            SceneHelper helper  = new SceneHelper();
            var         sceneid = helper.SetModel(scene);
            var         ticket  = QrCodeApi.Create(token, 300, sceneid, Senparc.Weixin.MP.QrCode_ActionName.QR_LIMIT_SCENE, null);

            ViewBag.ticket  = ticket.ticket;
            ViewBag.Sceneid = sceneid;
            var balance = MemberCapitalApplication.GetBalanceByUserId(CurrentUser.Id);

            ViewBag.ApplyWithMoney = balance;
            var member = _iMemberService.GetMember(CurrentUser.Id);//CurrentUser对象有缓存,取不到最新数据

            ViewBag.IsSetPwd        = string.IsNullOrWhiteSpace(member.PayPwd) ? false : true;
            ViewBag.WithDrawMinimum = siteSetting.WithDrawMinimum;
            ViewBag.WithDrawMaximum = siteSetting.WithDrawMaximum;
            ViewBag.Keyword         = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword;
            ViewBag.Keywords        = SiteSettings.HotKeyWords;
            return(View());
        }
        public async Task <SceneModel> GetExperimentDetails(string participantId)
        {
            SceneModel model = null;

            if (!String.IsNullOrEmpty(participantId))
            {
                try
                {
                    using (HttpClient client = new HttpClient())
                    {
                        string url      = $"{ApiHost}/api/experiment?participantId={participantId}";
                        var    response = await client.GetAsync(url);

                        if (response.StatusCode == HttpStatusCode.OK)
                        {
                            string result = await response.Content.ReadAsStringAsync();

                            model = JsonConvert.DeserializeObject <SceneModel>(result);
                        }
                    }
                }
                catch (Exception ex)
                {
                    // _failures.Add(ex);
                }
            }
            return(model);
        }
        private void MakeEntrySceneFirstBuilt(List <EditorBuildSettingsScene> scenes)
        {
            SceneModel entryScene = serializedSceneManager.TargetManager.EntryScene;

            if (entryScene == null || scenes.Count == 0)
            {
                return;
            }

            if (scenes[0].path.Equals(entryScene.SceneAssetPath))
            {
                return;
            }

            int indexOfEntry = scenes.FindIndex((x) =>
                                                x.path.Equals(entryScene.SceneAssetPath));

            if (indexOfEntry < 0)
            {
                Debug.LogError("Failed to find Entry Scene, cannot set as first build scene");
                return;
            }

            scenes.SwapValues(indexOfEntry, 0);
        }
Пример #10
0
    private void Awake()
    {
        model       = GetComponent <SceneModel>();
        sceneChange = GetComponent <SceneChangeManager>();

        GameManager.Instance.SetCurrentState(GameState.Prepare);
    }
Пример #11
0
        public Scene.Scene CreateScene(SceneModel model)
        {
            IDictionary <string, Texture>  textures  = CreateTextures(model);
            IDictionary <string, Material> materials = CreateMaterials(model, textures);
            ICollection <ShapeBase>        shapes    = CreateShapes(model, materials);
            ICollection <LightBase>        lights    = CreateLights(model);
            IDictionary <string, Shader>   shaders   = CreateShaderPrograms(model);
            IDictionary <string, Mesh>     meshes    = CreateMeshes(model);
            Camera camera = CreateCamera(model, textures, materials);

            Scene.Scene result = new Scene.Scene
            {
                Textures  = textures,
                Materials = materials,
                Shapes    = shapes,
                Shaders   = shaders,
                Meshes    = meshes,
                Camera    = camera,
                Lights    = lights
            };

            result.Camera.Collider        = new ColliderCollection(result.Shapes.Cast <ICollider>());
            result.Camera.CollisionHelper = new CollisionHelper(result, result.Camera.Collider);
            result.Camera.SetRenderQueue(result.Camera.GetCollisions());

            return(result);
        }
Пример #12
0
        private IDictionary <string, Material> CreateMaterials(SceneModel model, IDictionary <string, Texture> textures)
        {
            Dictionary <string, Material> result = new Dictionary <string, Material>();

            logger.LogDebug("Creating materials...");
            foreach (MaterialModel material in model.Materials)
            {
                logger.LogDebug($"Creating material '{material.Name}'");
                if (result.ContainsKey(material.Name))
                {
                    logger.LogDebug($"A material with the name '{material.Name}' already exists. Skipping...");
                    continue;
                }

                if (string.IsNullOrWhiteSpace(material.Texture) || !textures.ContainsKey(material.Texture))
                {
                    logger.LogWarning($"Texture with name '{material.Texture}' does not exist. Skipping...");
                    continue;
                }

                result.Add(material.Name, new Material
                {
                    Colour         = material.Colour,
                    Reflectiveness = material.Reflectiveness,
                    Roughness      = material.Roughness,
                    Texture        = textures[material.Texture]
                });
            }

            return(result);
        }
Пример #13
0
    private void Awake()
    {
        Cinema.GvrHead.trackPosition        = false;
        Camera.main.transform.localPosition = Vector3.zero;

        SceneModel sceneModel     = GlobalVariable.GetSceneModel();
        bool       isInteractable = (sceneModel != SceneModel.IMAXTheater && sceneModel != SceneModel.Drive);

        CinemaPanel.ChangeSceneStyle(isInteractable, false);
        switch (sceneModel)
        {
        case SceneModel.Drive:
            DriveModelQuadScreenTrans();
            break;

        default:
            PlayerGameobjectControl.Instance.QuadScreen.transform.localPosition = ImaxQuadScreenPosition;
            PlayerGameobjectControl.Instance.QuadScreen.transform.localScale    = ImaxQuadScreenScale;
            break;
        }

        PlayerGameobjectControl.Instance.HemisphereScreen.transform.localPosition = HemisphereScreenPosition;
        PlayerGameobjectControl.Instance.HemisphereScreen.transform.localScale    = HemisphereScale;
        PlayerGameobjectControl.Instance.SphereScreen.transform.localPosition     = OctahedronSphereScreenPosition;
        PlayerGameobjectControl.Instance.SphereScreen.transform.localScale        = OctahedronSphereScale;
        //if (GvrViewer.Controller.Eyes.Length == 2)
        //{
        //    foreach (var item in GvrViewer.Controller.Eyes)
        //    {
        //        item.cam.clearFlags = CameraClearFlags.Depth;
        //    }
        //}

        CameraMaskControl.GetInstance().HideMask();
    }
Пример #14
0
    private void SetBtnStatus()
    {
        SceneModel sceneModel = GlobalVariable.GetSceneModel();

        if (sceneModel == SceneModel.Default)
        {
            DefaultBtn.SetSelected(true);
            StarrySkyBtn.SetSelected(false);
            ImaxTheaterBtn.SetSelected(false);
            DriveBtn.SetSelected(false);
        }
        else if (sceneModel == SceneModel.StarringNight)
        {
            StarrySkyBtn.SetSelected(true);
            DefaultBtn.SetSelected(false);
            ImaxTheaterBtn.SetSelected(false);
            DriveBtn.SetSelected(false);
        }
        else if (sceneModel == SceneModel.IMAXTheater)
        {
            ImaxTheaterBtn.SetSelected(true);
            StarrySkyBtn.SetSelected(false);
            DefaultBtn.SetSelected(false);
            DriveBtn.SetSelected(false);
        }
        else if (sceneModel == SceneModel.Drive)
        {
            DriveBtn.SetSelected(true);
            ImaxTheaterBtn.SetSelected(false);
            StarrySkyBtn.SetSelected(false);
            DefaultBtn.SetSelected(false);
        }
    }
Пример #15
0
 protected override void OnInit()
 {
     model       = SceneController.instance.GetModel <SceneModel>(SceneModel.name);
     syncModel   = SyncController.instance.GetModel <SyncModel>(SyncModel.name);
     playerModel = PlayerController.instance.GetModel <PlayerModel>(PlayerModel.name);
     AddCommand(LOAD_SCENE, LoadScene);
 }
Пример #16
0
        public ScenePropertiesEditorViewModel(SceneModel sceneModel)
        {
            _sceneModel    = sceneModel;
            _sceneBehavior = CreateProperty(nameof(SceneBehavior), _sceneModel.SceneBehavior);
            _sceneBehavior.Subscribe(sceneBehavior => _sceneModel.SceneBehavior = sceneBehavior);

            AvailableSceneBehaviors = _sceneModel.AvailableSceneBehaviors;
        }
Пример #17
0
 void OnGetData(SceneModel model)
 {
     scenes.Add(model);
     if (sceneToLoad == null)
     {
         sceneToLoad = model;
     }
 }
Пример #18
0
        public int SetModel(SceneModel model, int expireTime = 600)
        {
            int    hashCode = model.GetHashCode();
            string str      = CacheKeyCollection.SceneState(hashCode.ToString());

            Cache.Insert(str, model, expireTime);
            return(hashCode);
        }
Пример #19
0
 public GameStateModel()
 {
     GlobalFlags = new List <GameFlag> ();
     Scenes      = new List <SceneModel> ();
     PlayerState = new PlayerStateModel();
     NPCs        = new List <NPCStateModel>();
     Scene       = new SceneModel();
 }
        private IEnumerator LoadAdditiveScene(SceneIndex scene, SceneModel model)
        {
            OnLoadingStart?.Invoke();
            IsLoading = true;

            AsyncOperation loadSceneJob = SceneManager.LoadSceneAsync(scene.ToString(), LoadSceneMode.Additive);

            while (!loadSceneJob.isDone)
            {
                yield return(null);

                // Callback to update based on the async task progress
                OnLoadingUpdate?.Invoke(loadSceneJob.progress);
            }

            // Scene was done loading
            Scene loadedScene = SceneManager.GetSceneByName(scene.ToString());

            if (loadedScene.isLoaded)
            {
                SceneManager.MergeScenes(loadedScene, SceneManager.GetActiveScene());

                bool controllerFound = false;
                // Get the scene object to initialize the scene using the ISceneController interface
                GameObject[] rootObjects = loadedScene.GetRootGameObjects();
                foreach (GameObject rootObject in rootObjects)
                {
                    // Try to get the scene controller so we can initialize the scene
                    SceneController <SceneModel> sceneController = rootObject.GetComponent <SceneController <SceneModel> >();

                    // This object didn't have the scene controller
                    if (sceneController == null)
                    {
                        continue;
                    }

                    sceneController.BaseModel = model;

                    LoadedScene managedLoadedScene = new LoadedScene(sceneController, model, rootObject, scene);
                    _loadedScenes.Add(managedLoadedScene);

                    yield return(sceneController.Initialization());

                    sceneController.AfterInitialization();

                    controllerFound = true;
                }

                if (!controllerFound)
                {
                    Debug.LogError("[SceneTransitionManager] Could not find any object with component ISceneController in scene: "
                                   + loadedScene.name);
                }
            }

            OnLoadingFinished?.Invoke();
            IsLoading = false;
        }
Пример #21
0
 public static SceneModel FilterBy(this SceneModel model, SceneDataType sceneDataType)
 {
     if (sceneDataType.IsFlaggedExactly(SceneDataType.All))
     {
         return(model);
     }
     // TODO
     throw new NotImplementedException();
 }
        internal void DeleteSceneNode(int sceneId, bool addToExclusionFilter)
        {
            SceneModel model = TargetManager.scenes.Find((x) => x.SceneId == sceneId);

            if (sceneId == TargetManager.AnyScene.SceneId)
            {
                return;
            }

            if (model == null)
            {
                return;
            }

            Undo.SetCurrentGroupName("Delete Scene Node");
            int undoGroup = Undo.GetCurrentGroup();

            Undo.RegisterCompleteObjectUndo(SceneNodesObject.targetObject, "Scene Nodes");

            SerializedProperty scenesProperty = ScenesProp;

            for (int i = scenesProperty.arraySize - 1; i >= 0; i--)
            {
                SerializedSceneModel serializedScene = GetSerializedSceneModel(i);

                serializedScene.DeleteTransitionsInvolving(sceneId);

                if (serializedScene.SceneIdProp.intValue == sceneId)
                {
                    scenesProperty.DeleteArrayElementAtIndex(i);
                }
            }

            SerializedManager.ApplyModifiedProperties();

            for (int i = 0; i < SceneNodesProp.arraySize; i++)
            {
                if (GetSceneNodeIdProperty(i).intValue == sceneId)
                {
                    SceneNodesProp.DeleteArrayElementAtIndex(i);
                    break;
                }
            }

            SceneNodesObject.ApplyModifiedProperties();

            if (addToExclusionFilter)
            {
                SerializedProperty exclusion = SerializedSceneFilter.FindProperty("FilesToExclude");
                SerializedProperty newEntry  = exclusion.AddArrayElement();
                newEntry.stringValue = model.SceneAssetPath;
                SerializedSceneFilter.ApplyModifiedProperties();
            }

            Undo.CollapseUndoOperations(undoGroup);
        }
Пример #23
0
    void ModelUpdated(SceneModel model)
    {
        var mi = Get(model.CloudID);

        mi.hidden          = model.Hidden;
        mi.position        = new CloudAPI.Position();
        mi.position.GpsPos = model.Position;

        Save();
    }
Пример #24
0
        public SceneEditorViewModel(string sceneFilePath, IEventBus eventBus, ISceneLoader sceneLoader, ISceneModelFactory sceneModelFactory)
        {
            _sceneFilePath = sceneFilePath;
            _eventBus      = eventBus;
            _sceneLoader   = sceneLoader;

            _scene = _sceneLoader.Load(_sceneFilePath);

            _sceneModel = sceneModelFactory.Create(_scene);
        }
Пример #25
0
        private IDictionary <string, CompiledShader> CreateShaders(SceneModel scene)
        {
            Dictionary <string, CompiledShader> result = new Dictionary <string, CompiledShader>();

            logger.LogDebug("Creating shaders...");
            foreach (ShaderModel shader in scene.Shaders)
            {
                logger.LogDebug($"Creating shader '{shader.Name}'...");
                if (result.ContainsKey(shader.Name))
                {
                    logger.LogDebug($"Shader '{shader.Name}' has already been defined. Skipping...");
                    continue;
                }

                if (!File.Exists(shader.Source))
                {
                    logger.LogDebug($"Could not find file for shader '{shader.Name}'. Skipping...");
                    continue;
                }

                string source;
                try
                {
                    using (StreamReader sr = new StreamReader(shader.Source))
                    {
                        source = sr.ReadToEnd();
                    }
                }
                catch (Exception e)
                {
                    logger.LogDebug($"Attempted to read the source of shader '{shader.Name}', but failed: {e.Message}\n{e.StackTrace}");
                    continue;
                }

                int shaderPointer = GL.CreateShader(shader.Type);
                GL.ShaderSource(shaderPointer, source);
                GL.CompileShader(shaderPointer);
                string compileMessage = GL.GetShaderInfoLog(shaderPointer);
                if (!string.IsNullOrEmpty(compileMessage))
                {
                    logger.LogDebug($"shader {shader.Name} was not created:");
                    logger.LogDebug(compileMessage);
                    GL.DeleteShader(shaderPointer);
                    continue;
                }

                result.Add(shader.Name, new CompiledShader
                {
                    ShaderPointer = shaderPointer,
                    Type          = shader.Type
                });
            }

            return(result);
        }
Пример #26
0
    public override void FormUpdate(KEditorManager manager)
    {
        if (nextState != State.None)
        {
            currentState = nextState;
            nextState    = State.None;
        }
        switch (currentState)
        {
        case State.NoScenes:
            if (sceneModel == null)
            {
                sceneModel = new SceneModel();
            }
            break;

        case State.Init:
            // On Init, we need to load up the scene names.
            loadSceneNames();


            listStyle = new GUIStyle();
            listStyle.normal.textColor  = Color.white;
            listStyle.onHover.textColor = listStyle.hover.textColor = Color.black;

            listStyle.normal.background             = listStyle.onHover.background
                                                    = listStyle.hover.background = manager.getWhiteTexture();
            listStyle.padding.left                  = listStyle.padding.right = listStyle.padding.top = listStyle.padding.bottom = 4;


            if (sceneNames.Length == 0)
            {
                currentState = State.NoScenes;
            }
            else
            {
                if (sceneModel == null)
                {
                    sceneModel = new SceneModel();
                }
                //currentState = State.CreateForm;
                currentState = State.PickScene;
            }
            break;

        case State.SaveForm:
            Kat2DEditorUtiity.saveSceneModel(sceneModel);
            loadSceneNames();
            nextState = State.PickScene;
            break;

        case State.CreateForm:
            break;
        }
    }
Пример #27
0
        public ActionResult GetLoadedSceneJson(string fileName)
        {
            using (StreamReader rd = new StreamReader(@"C:\projects\Go\imgprocessing\puzzle_boards\" + fileName))
            {
                string     json  = rd.ReadToEnd();
                SceneModel scene = JsonConvert.DeserializeObject <SceneModel>(json);

                var jsonResult = Json(scene, JsonRequestBehavior.AllowGet);
                return(jsonResult);
            }
        }
Пример #28
0
    public SceneViewModel(IView view, SceneModel model) :
        base(view, model)
    {
        Model = model;
        Model.SetViewModel(this);

        Notify(NotificationName.NotifyViewSyncState,
               this,
               GameStateManager.Instance.ActiveScene.Name,
               GameStateManager.Instance.ActiveScene.CommandHints.Replace(";", " | "));
    }
Пример #29
0
        /// <summary>
        /// 设置场景Model
        /// </summary>
        /// <param name="model"></param>
        /// <param name="expireTime"></param>
        /// <returns>场景ID</returns>
        public int SetModel(SceneModel model, int expireTime = 600)
        {
            var sceneid  = model.GetHashCode();
            var cachekey = CacheKeyCollection.SceneState(sceneid.ToString());

            //Core.Cache.Insert( cachekey , model , expireTime );
            _cache.Insert(cachekey, model, null, DateTime.MaxValue, TimeSpan.FromSeconds(expireTime), System.Web.Caching.CacheItemPriority.NotRemovable, null);
            var sceneObj = Core.Cache.Get <SceneModel>(cachekey);

            return(sceneid);
        }
Пример #30
0
    /// <summary>
    /// 同步行为
    /// </summary>
    void OnObjectAction(byte[] data)
    {
        ProtoIntArray proto = ObjectPool.protoPool.GetOrCreate <ProtoIntArray>(ProtoPool.ProtoRecycleType.IntArray);

        if (proto.Parse(data))
        {
            int[]      ints       = proto.context;
            SceneModel sceneModel = SceneController.instance.GetModel <SceneModel>(SceneModel.name);
            sceneModel.SetSceneObjectAciton(data[0], ints);
        }
        proto.Recycle();
    }
Пример #31
0
    //-----------------------------------------------------
    void Awake()
    {
        cdm = new ContextDataModel ();
        sm = new SceneModel ();
        sum = new SceneUpgradeModel ();
        om = new ObjectsModel (this);

        UsefullEvents.OnResizingWindow  += RelocateUI;
        UsefullEvents.OnResizeWindowEnd += RelocateUI;

        #if UNITY_IPHONE
        EtceteraManager.mailComposerFinishedEvent += IOutils.EndMail;
        #endif
    }
Пример #32
0
    //-------------------------
    void Awake()
    {
        //		_hashTag = GetType().ToString()+"_"+(isGlobal? "G":"L")+"_"+id.ToString();

        //init
        _isSwitchedOn   	= false;
        //		_uiShowColors		= false;
        _idSelectedColor	= 0;
        _uiscrollPos 		= 0;
        _blank 				= (Texture2D)Resources.Load("gui/blank");

        //		BoxCollider bc = transform.GetComponentInChildren<BoxCollider>();
        //		x = bc.size.x;
        //		z = bc.size.z;
        //		ratio = x/z;
        //		size = x;
        sm = Montage.sm;

        //Errors
        if(colors.Length == 0)
        {
            _hasColors = false;
            Debug.LogWarning(DEBUGTAG +"No colors set > only Switch On/Off");
        }
        else
        {
            _hasColors = true;
        }

        if(refsName.Length == 0)
            Debug.LogError(DEBUGTAG +"refsName[]"+PC.MISSING_REF);
        else
            InitRefs();
        go = gameObject.name;

        UsefullEvents.ScaleChange += UpdateScale;
        //		UsefullEvents.NightMode += NigthModeUpdated;

        foreach(GameObject g in _modObjs)
        {

            if(isProjector)
            {
                foreach(Projector p in g.GetComponentsInChildren<Projector>(true))
                {
                    _baseProjIntensity = p.material.color;
                    UpdatePower();
                    return;
                }
            }
            else
            {
                foreach(Light l in g.GetComponentsInChildren<Light>(true))
                {
                    _baseLightIntensity = l.intensity;
                    UpdatePower();
                    return;
                }
            }
        }
    }
Пример #33
0
    //-----------------------------------------------------
    void Start()
    {
        //if((PC.DEBUG && DEBUG) || PC.DEBUGALL) Debug.Log(DEBUGTAG+"Start");

        if(m_mainScene == null)         Debug.LogError(DEBUGTAG+"MainScene"+        PC.MISSING_REF);
        if(m_mainNode == null)          Debug.LogError(DEBUGTAG+"MainNode"+         PC.MISSING_REF);
        if(m_avatar == null)            Debug.LogError(DEBUGTAG+"Avatar"+           PC.MISSING_REF);
        if(m_bgCam == null)             Debug.LogError(DEBUGTAG+"Background camera"+PC.MISSING_REF);
        if(m_toggleSkin == null)        Debug.LogError(DEBUGTAG+"MainScene"+        PC.MISSING_REF);
        if(m_maskCam == null)           Debug.LogError(DEBUGTAG+"MaskCam"+          PC.MISSING_REF);
        if(m_backgroundImg == null)     Debug.LogError(DEBUGTAG+"Background image"+ PC.MISSING_REF);
        if(m_beforeAfter == null)       Debug.LogError(DEBUGTAG+"Before after"+     PC.MISSING_REF);
        if(m_backGrid == null)          Debug.LogError(DEBUGTAG+"Back Grid"+        PC.MISSING_REF);
        if(m_mode2DTiledGrid == null)   Debug.LogError(DEBUGTAG+"Mode2D Tiled grid"+PC.MISSING_REF);
        if(m_eraserImages == null)      Debug.LogError(DEBUGTAG+"EraserImages"+     PC.MISSING_REF);
        if(m_grassImages == null)       Debug.LogError(DEBUGTAG+"GrassImages"+      PC.MISSING_REF);
        if(m_lineMgr == null)           Debug.LogError(DEBUGTAG+"LineMananger"+     PC.MISSING_REF);
        if(m_helpBgTex == null)         Debug.LogError(DEBUGTAG+"Help Bg Tex"+      PC.MISSING_REF);

        // -- Chargement auto des images d'aide, selon plateforme --
        string path = "";
        if(UnityEngine.Application.platform == RuntimePlatform.Android ||
           UnityEngine.Application.platform == RuntimePlatform.IPhonePlayer)
            path = "images_multilangue/"+PlayerPrefs.GetString("language")+"/"+m_helpTexTouchPath+"/";      // Aide Touchpad
        else
            path = "images_multilangue/"+PlayerPrefs.GetString("language")+"/"+m_helpTexMousePath+"/";      // Aide Souris

        m_helpTexObj = (Texture2D) Resources.Load(path+m_helpTexObjFile, typeof(Texture2D));
        if(m_helpTexObj == null)   Debug.LogError( DEBUGTAG+path+m_helpTexObjFile+" "+ PC.MISSING_RES);
        m_helpTexLin = (Texture2D) Resources.Load(path+m_helpTexLinFile, typeof(Texture2D));
        if(m_helpTexLin == null)   Debug.LogError(DEBUGTAG+path+m_helpTexLinFile+" "+ PC.MISSING_RES);

        // -- Initialisations --
        m_maskCreator       = (MaskCreator) m_maskCam.GetComponent<MaskCreator>();

        m_mainCam           = GetComponent<Camera>();

        m_movingObj         = false;
        m_invalidateClick   = false;

        m_zoomImage         = 1f;
        m_orgBgImgPixIn     = new Rect();
        m_oldScreenSize     = new Vector2();
        m_savedBgImgPixIn   = new Rect();

        // -- Scale list --
        m_scaleList         = new int[]{200, 500, 650};
        m_curScaleID        = 0;
        m_rescaleFactor     = 1f;

        m_zoomObjects       = m_scaleList[0]*m_rescaleFactor*(m_modePortrait ? c_scaleZoomFactorPortrait : c_scaleZoomFactor);
        m_rotationObjects   = 0f;
        m_locationObjects   = Vector3.zero;

        m_measuring         = false;

        m_iPadPath          = "";
        m_loadedBg          = null;
        m_newBgImgLoaded    = false;

        m_bkupAngle         = new Quaternion();
        m_bkupPivot         = transform.parent.transform;
        m_bkupPos           = new Vector3();
        m_bkupRenderZone    = new Rect();
        m_bkupAvatarEnabled = false;
        m_bkupSelected      = null;
        m_bkupBgImgColor    = new Color();
        m_bkupCullingMask   = m_mainCam.cullingMask;

        m_m2dObjs           = new List<Transform>();
        m_bkupObjScl        = new List<Vector3>();
        m_bkupObjPos        = new List<Vector3>();
        m_bkupObjRot        = new List<Quaternion>();
        //	m_objectsToHide 	= new List<GameObject>();

        m_hideUI            = false;
        GUIStyle style      = m_toggleSkin.GetStyle("toggle_2d3d");
        m_toggleRect        = new Rect(0, 0, style.fixedHeight, style.fixedWidth);
        float sw            = Screen.width;
        float sh            = Screen.height;

        // -- Load panel --
        m_loadPanelFromRightMenu = false;
        m_showLoadPanel     = false;
        m_loadPanelRect     = new Rect((sw-250f)/2f, (sh-350f)/2f, 250f, 320f);
        m_lpLabel1Rect      = new Rect( 20f,  20f, 210f,  40f);
        m_lpBtnLoadRect     = new Rect( 20f,  60f, 210f,  50f);
        m_lpTextRect        = new Rect( 20f, 110f, 210f,  20f);
        m_lpLabel2Rect      = new Rect( 20f, 140f, 210f,  40f);
        m_lpBtnScl1Rect     = new Rect( 20f, 180f,  70f,  30f);
        m_lpBtnScl2Rect     = new Rect( 90f, 180f,  70f,  30f);
        m_lpBtnScl3Rect     = new Rect(160f, 180f,  70f,  30f);
        m_lpBtnOKrect       = new Rect( 20f, 250f, 105f,  40f);
        m_lpBtnCancelrect   = new Rect(125f, 250f, 105f,  40f);

        // -- Right menu --
        int menuW           = 175;
        m_showRightMenu     = false;
        m_rBgTopRect       		= new Rect(menuW,   0f, -menuW, 150f);            // Menu de droite
        m_rTitleRect        	= new Rect(   0f, 100f,  menuW,  50f);

        m_rBtn1TxtRect      	= new Rect(   0f, 150f,  menuW,  50f);
        m_rBtn1Rect         	= new Rect(   0f, 150f,  menuW,  50f);

        m_rBtnTxtRectPlanManipulation 		= new Rect(   0f, 200f,  menuW,  50f);
        m_rBtnRectPlanManipulation 			= new Rect(   50f, 200f,  menuW,  50f);

        m_rBtnRectResetPlan		= new Rect(   0f, 250f,  menuW,  50f);
        m_rBtnTxtRectResetPlan	= new Rect(   0f, 250f,  menuW,  50f);

        m_rBtnRectDelete		= new Rect(   0f, 300f,  menuW,  50f);
        m_rBtnTxtRectDelete		= new Rect(   0f, 300f,  menuW,  50f);

        m_rObjectRect        	= new Rect(   0f, 350f,  menuW,  50f);

        m_rBtnTxtRectObjectsManipulation 	= new Rect(   0f, 400f,  menuW,  50f);
        m_rBtnRectObjectsManipulation 		= new Rect(   50f, 400f,  menuW,  50f);

        m_rBtnTxtRectRecenter	= new Rect(   0f, 450f,  menuW,  50f);
        m_rBtnRectRecenter		= new Rect(   0, 450f,  menuW,  50f);

        m_rBtn4TxtRect      	= new Rect(   0f, 500f,  menuW,  50f);
        m_rBtn4Rect         	= new Rect(   0f, 500f,  menuW,  50f);

        m_rImageRect        	= new Rect(   0f, 500f,  menuW,  50f);

        m_rBtn2TxtRect      	= new Rect(   0f, 550f,  menuW,  50f);
        m_rBtn2Rect         	= new Rect(   0f, 550f,  menuW,  50f);

        m_rBtn3Rect 			= new Rect(   0f, 600f,  menuW,  50f);
        m_rBtn3TxtRect  		= new Rect(   0f, 600f,  menuW,  50f);

        //m_validTexture=(Texture)Resources.Load("gui/check");
        #if UNITY_IPHONE || UNITY_ANDROID
            m_rBtn5Rect 	= new Rect(		0f, 700f,  menuW,  50f);
          	 	m_rBtn5TxtRect  = new Rect(    	0f, 700f,  menuW,  50f);
            m_rBgMidRect    = new Rect(	 menuW, 150f, -menuW, 550f);
            m_rBgBotRect    = new Rect(  menuW, 700f, -menuW, 150f);
            m_rGroupRect    = new Rect(		0f,   0f,  menuW, 800f);
        #else
            m_rBgMidRect    = new Rect( menuW, 150f, -menuW, 500f);
            m_rBgBotRect    = new Rect( menuW, 650f, -menuW, 150f);
            m_rGroupRect    = new Rect(    0f,   0f,  174, Screen.height);
        #endif

        // -- Rects UI --
        m_uiRects           = new Rect[2];
        for(int i=0; i<m_uiRects.Length; i++)
            m_uiRects[i] = new Rect(0f, 0f, 0f, 0f);

        // -- Warning --
        m_warningRect       = new Rect(0f, Screen.height*0.8f, Screen.width, 30f);
        m_showWarning       = false;
        m_warningTxt        = "";
        m_warningFading     = false;
        m_warningFadeTimer  = 0f;
        m_warningFadeStartCol = Color.clear;
        m_warningFadeEndCol = Color.clear;

        // -- Help --
        m_curHelpTex        = null;
        m_nextHelpTex       = null;
        m_helpRect          = new Rect();
        m_helpTimer         = 0f;
        m_displayHelp       = false;

        m_animHelp          = false;
        m_animHelpProg      = 0f;
        m_helpGUIalpha      = 0f;
        m_helpGUIaStart     = 0f;
        m_helpGUIaEnd       = 0f;
        m_helpCountdown     = false;

        m_resizeEnabled     = false;
        m_modePortrait      = false;
        ResizeRectsToScreen();

        m_sceneModel        = Montage.sm;
    }